diff --git a/.github/workflows/ci-pr.yml b/.github/workflows/ci-pr.yml index ce33d0c6b94..dc960a10567 100644 --- a/.github/workflows/ci-pr.yml +++ b/.github/workflows/ci-pr.yml @@ -15,38 +15,12 @@ jobs: run: exit 0 test-minimal: name: Tests (Minimal) - env: - FLAGS: --no-default-features --features 'std cargo' strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest] rust: [stable] - runs-on: ${{ matrix.os }} - steps: - - name: Install rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true - - name: Cache Builds - uses: Swatinem/rust-cache@v1 - - name: Checkout - uses: actions/checkout@v2 - - name: Compile - run: cargo test --no-run ${{ env.FLAGS }} - - name: Test - run: cargo test ${{ env.FLAGS }} - test-full: - name: Tests (Full) - env: - FLAGS: --features 'wrap_help yaml regex unstable-replace' - strategy: - fail-fast: false - matrix: + features: [minimal, full] os: [ubuntu-latest, windows-latest] - rust: [stable] runs-on: ${{ matrix.os }} steps: - name: Install rust @@ -59,10 +33,11 @@ jobs: uses: Swatinem/rust-cache@v1 - name: Checkout uses: actions/checkout@v2 + - name: Compile - run: cargo test --no-run ${{ env.FLAGS }} + run: make build-${{ matrix.features} - name: Test - run: cargo test ${{ env.FLAGS }} + run: make test-${{ matrix.features} msrv: name: "Check MSRV: 1.54.0" runs-on: ubuntu-latest @@ -77,11 +52,15 @@ jobs: uses: Swatinem/rust-cache@v1 - name: Checkout uses: actions/checkout@v2 + + - name: Minimal features + run: make check-minimal + - name: Default features - run: cargo check --all-targets + run: make check-default + - name: All features + Debug - run: cargo check --all-targets --features "wrap_help yaml regex unstable-replace debug" - - name: No features - run: cargo check --all-targets --no-default-features --features "std cargo" + run: make check-debug + - name: UI Tests run: cargo test --package clap_derive -- ui diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08b8df7e1c2..c377a2f7b94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: fail-fast: false matrix: rust: [1.54.0, stable, beta] + features: [minimal, full, release] os: [windows-latest, macos-latest, ubuntu-latest] target: - i686-pc-windows-msvc @@ -25,10 +26,6 @@ jobs: - x86_64-unknown-linux-gnu - i686-unknown-linux-gnu - x86_64-apple-darwin - features: - - none - - all - - release exclude: - features: release rust: stable @@ -71,6 +68,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.target }} override: true + - name: Cache Builds + uses: Swatinem/rust-cache@v1 - name: Checkout uses: actions/checkout@v2 - name: Install linker @@ -86,39 +85,21 @@ jobs: run: | sudo apt-get update sudo apt-get install gcc-multilib - - name: Test almost no features - uses: actions-rs/cargo@v1 - if: matrix.features == 'none' - with: - command: test - args: --target ${{ matrix.target }} --no-default-features --features "std cargo" -p clap:3.0.0-beta.4 - - name: Test all features - uses: actions-rs/cargo@v1 - if: matrix.features == 'all' - with: - command: test - args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace" - - name: Check debug - uses: actions-rs/cargo@v1 - if: matrix.features == 'all' - with: - command: check - args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace debug" - - name: Test release - uses: actions-rs/cargo@v1 + + - name: Check Debug if: matrix.features == 'release' - with: - command: test - args: --target ${{ matrix.target }} --features "wrap_help yaml regex unstable-replace" --release + run: make check-debug TOOLCHAIN_TARGET=${{matrix.target} + + - name: Compile + run: make build-${{ matrix.features} TOOLCHAIN_TARGET=${{matrix.target} + - name: Test + run: make test-${{ matrix.features} TOOLCHAIN_TARGET=${{matrix.target} nightly: name: Nightly Tests strategy: fail-fast: false matrix: - features: - - none - - all - - release + features: [minimal, full, release] runs-on: ubuntu-latest steps: - name: Install rust @@ -126,32 +107,15 @@ jobs: with: toolchain: nightly override: true + - name: Cache Builds + uses: Swatinem/rust-cache@v1 - name: Checkout uses: actions/checkout@v2 - - name: Test almost no features - uses: actions-rs/cargo@v1 - if: matrix.features == 'none' - with: - command: test - args: --no-default-features --features "std cargo" -p clap:3.0.0-beta.4 - - name: Test all features - uses: actions-rs/cargo@v1 - if: matrix.features == 'all' - with: - command: test - args: --features "wrap_help yaml regex unstable-replace" - - name: Check debug - uses: actions-rs/cargo@v1 - if: matrix.features == 'all' - with: - command: check - args: --features "wrap_help yaml regex unstable-replace debug" - - name: Test release - uses: actions-rs/cargo@v1 - if: matrix.features == 'release' - with: - command: test - args: --features "wrap_help yaml regex unstable-replace" --release + + - name: Compile + run: make build-${{ matrix.features} TOOLCHAIN_TARGET=${{matrix.target} + - name: Test + run: make test-${{ matrix.features} TOOLCHAIN_TARGET=${{matrix.target} wasm: name: Wasm Check runs-on: ubuntu-latest @@ -166,10 +130,9 @@ jobs: toolchain: 1.54.0 target: ${{ matrix.target }} override: true + - name: Cache Builds + uses: Swatinem/rust-cache@v1 - name: Checkout uses: actions/checkout@v2 - name: Check - uses: actions-rs/cargo@v1 - with: - command: check - args: --target ${{ matrix.target }} --features "yaml regex unstable-replace" + run: make check-wasm TOOLCHAIN_TARGET=${{matrix.target} diff --git a/Makefile b/Makefile new file mode 100644 index 00000000000..91d5824bc3a --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +# CI Steps +# +# Considerations +# - Easy to debug: show the command being run +# - Leverage CI features: Only run individual steps so we can use features like reporting elapsed time per step + +TOOLCHAIN_TARGET ?= +ifneq (${TOOLCHAIN_TARGET},) + _TARGET_ARG =--target ${TOOLCHAIN_TARGET} +endif +_TARGET_ARG ?= + +_FEATURES = minimal default wasm full release +_FEATURES_minimal = --no-default-features --features "std cargo" +_FEATURES_default = +_FEATURES_wasm = --features "yaml regex unstable-replace" +_FEATURES_full = --features "yaml regex unstable-replace wrap_help" +_FEATURES_debug = ${_FEATURES_full} --features debug +_FEATURES_release = ${_FEATURES_full} --release + +check-%: + cargo check --all-targets ${_RELEASE_ARG} ${_TARGET_ARG} ${_FEATURES_${@:check-%=%}} + +build-%: + cargo test --no-run ${_RELEASE_ARG} ${_TARGET_ARG} ${_FEATURES_${@:build-%=%}} + +test-%: + cargo test ${_RELEASE_ARG} ${_TARGET_ARG} ${_FEATURES_${@:test-%=%}} diff --git a/justfile b/justfile deleted file mode 100644 index d58c534518b..00000000000 --- a/justfile +++ /dev/null @@ -1,41 +0,0 @@ -run-test TESTG TEST="": - cargo test --test {{TESTG}} -- {{TEST}} - -debug TESTG TEST="": - cargo test --test {{TESTG}} --features debug -- {{TEST}} - -run-tests: - cargo test --features "wrap_help yaml regex unstable-replace" - -@bench: - cargo bench - -@lint: - rustup component add clippy - rustup component add rustfmt - cargo clippy --features "wrap_help yaml regex unstable-replace" -- -D warnings - cargo fmt -- --check - -clean: - cargo clean - find . -type f -name "*.orig" -exec rm {} \; - find . -type f -name "*.bk" -exec rm {} \; - find . -type f -name ".*~" -exec rm {} \; - -top-errors NUM="95": - @cargo check 2>&1 | head -n {{NUM}} - -count-errors: - @cargo check 2>&1 | grep -e '^error' | wc -l - -find-errors: - @cargo check 2>&1 | grep --only-matching -e '-->[^:]*' | sort | uniq -c | sort -nr - -count-warnings: - @cargo check 2>&1 | grep -e '^warning' | wc -l - -find-warnings: - @cargo check 2>&1 | grep -A1 -e 'warning' | grep --only-matching -e '-->[^:]*' | sort | uniq -c | sort -nr - -@count-failures: - ./count-tests.sh