From 8cc361e443aaebe804df0c2cbe3e2e7d3b22057a Mon Sep 17 00:00:00 2001 From: ClementTsang Date: Sun, 1 May 2022 16:36:43 -0400 Subject: [PATCH] ci: clean up ci workflow --- .github/workflows/ci.yml | 237 +++++++++------------------------ .github/workflows/coverage.yml | 3 +- 2 files changed, 62 insertions(+), 178 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 355310c7..d88b88d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,9 @@ # - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml # # CI pipeline should do: -# 1. cargo fmt -# 2. cargo build +# - cargo fmt on supported platforms +# - cargo test on supported platforms, cargo check on unsupported +# - cargo clippy after (apparently faster) on supported platforms name: ci @@ -20,6 +21,7 @@ on: env: CARGO_INCREMENTAL: 0 CARGO_PROFILE_DEV_DEBUG: 0 + CARGO_HUSKY_DONT_INSTALL_HOOKS: true jobs: rustfmt: @@ -32,13 +34,14 @@ jobs: - macOS-latest - windows-2019 steps: - - id: skip_check + - name: Check if this action should be skipped + id: skip_check uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e with: concurrent_skipping: "same_content_newer" skip_after_successful_duplicate: "true" paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml"]' - do_not_skip: '["workflow_dispatch"]' + do_not_skip: '["workflow_dispatch", "push"]' - uses: actions/checkout@v2 if: ${{ steps.skip_check.outputs.should_skip != 'true' }} @@ -57,44 +60,81 @@ jobs: - run: cargo fmt --all -- --check if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - clippy: - runs-on: ${{ matrix.os }} + # Runs tests + clippy on the main supported platforms. + supported: + needs: [rustfmt] + runs-on: ${{ matrix.triple.os }} strategy: fail-fast: false matrix: - os: - - ubuntu-latest - - macOS-latest - - windows-2019 + triple: + - { + os: "ubuntu-latest", + target: "x86_64-unknown-linux-gnu", + cross: false, + } + - { + os: "ubuntu-latest", + target: "armv7-unknown-linux-gnueabihf", + cross: true, + } + - { os: "macOS-latest", target: "x86_64-apple-darwin", cross: false } + - { + os: "windows-2019", + target: "x86_64-pc-windows-msvc", + cross: false, + } + features: [ + "--all-features", + # "--features battery", + # "--features gpu", # Think it's fine to skip this specific test. + "--no-default-features", + ] steps: - - id: skip_check + - name: Check if this action should be skipped + id: skip_check uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e with: concurrent_skipping: "same_content_newer" skip_after_successful_duplicate: "true" paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml"]' - do_not_skip: '["workflow_dispatch"]' + do_not_skip: '["workflow_dispatch", "push"]' - uses: actions/checkout@v2 if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 + - name: Setup Rust toolchain if: ${{ steps.skip_check.outputs.should_skip != 'true' }} + uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 with: profile: minimal toolchain: stable override: true components: clippy - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 + - name: Enable Rust cache if: ${{ steps.skip_check.outputs.should_skip != 'true' }} + uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - - run: cargo clippy --all-targets --workspace -- -D warnings + - name: Build tests if: ${{ steps.skip_check.outputs.should_skip != 'true' }} + run: cargo test --no-run --locked ${{ matrix.features }} + env: + RUST_BACKTRACE: full - # Run cargo --check on all platforms - check: - needs: [rustfmt, clippy] + - name: Run tests + if: ${{ steps.skip_check.outputs.should_skip != 'true' }} + run: cargo test --no-fail-fast ${{ matrix.features }} -- --nocapture --quiet + env: + RUST_BACKTRACE: full + + - name: Run clippy + if: ${{ steps.skip_check.outputs.should_skip != 'true' }} + run: cargo clippy ${{ matrix.features }} --workspace -- -D warnings + + # Run cargo check on all other platforms + other_check: + needs: [rustfmt] runs-on: ${{ matrix.triple.os }} continue-on-error: true strategy: @@ -102,12 +142,6 @@ jobs: matrix: triple: # x86 or x64 - - { - os: "ubuntu-latest", - target: "x86_64-unknown-linux-gnu", - cross: false, - rust: stable, - } - { os: "ubuntu-latest", target: "i686-unknown-linux-gnu", @@ -126,18 +160,6 @@ jobs: cross: true, rust: stable, } - - { - os: "macOS-latest", - target: "x86_64-apple-darwin", - cross: false, - rust: stable, - } - - { - os: "windows-2019", - target: "x86_64-pc-windows-msvc", - cross: false, - rust: stable, - } - { os: "windows-2019", target: "i686-pc-windows-msvc", @@ -171,14 +193,6 @@ jobs: rust: beta, } - # aarch64 - - { - os: "ubuntu-latest", - target: "aarch64-unknown-linux-gnu", - cross: true, - rust: stable, - } - # armv7 - { os: "ubuntu-latest", @@ -220,13 +234,14 @@ jobs: } steps: - - id: skip_check + - name: Check if this action should be skipped + id: skip_check uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e with: concurrent_skipping: "same_content_newer" skip_after_successful_duplicate: "true" paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml"]' - do_not_skip: '["workflow_dispatch"]' + do_not_skip: '["workflow_dispatch", "push"]' - uses: actions/checkout@v2 if: ${{ steps.skip_check.outputs.should_skip != 'true' }} @@ -252,133 +267,3 @@ jobs: command: check args: --all-targets --verbose --target=${{ matrix.triple.target }} --features "battery" --locked use-cross: ${{ matrix.triple.cross }} - - # Check without the battery feature enabled on x86-64 for supported operating systems - check-without-battery: - needs: [rustfmt, clippy] - runs-on: ${{ matrix.triple.os }} - continue-on-error: true - strategy: - fail-fast: false - matrix: - triple: - - { - os: "ubuntu-latest", - target: "x86_64-unknown-linux-gnu", - cross: false, - rust: stable, - } - - { - os: "macOS-latest", - target: "x86_64-apple-darwin", - cross: false, - rust: stable, - } - - { - os: "windows-2019", - target: "x86_64-pc-windows-msvc", - cross: false, - rust: stable, - } - - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e - with: - concurrent_skipping: "same_content_newer" - skip_after_successful_duplicate: "true" - paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml"]' - do_not_skip: '["workflow_dispatch"]' - - - uses: actions/checkout@v2 - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - - - name: Install toolchain - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 - with: - profile: minimal - toolchain: ${{ matrix.triple.rust }} - override: true - target: ${{ matrix.triple.target }} - - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - with: - key: ${{ matrix.triple.target }} - - - name: Check without battery feature on the main 3 - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - uses: actions-rs/cargo@v1 - with: - command: check - args: --all-targets --verbose --target=${{ matrix.triple.target }} --no-default-features --locked - use-cross: ${{ matrix.triple.cross }} - - # Run tests x86-64 for supported operating systems - test: - needs: [rustfmt, clippy] - runs-on: ${{ matrix.triple.os }} - continue-on-error: true - strategy: - fail-fast: false - matrix: - triple: - - { - os: "ubuntu-latest", - target: "x86_64-unknown-linux-gnu", - cross: false, - rust: stable, - } - - { - os: "macOS-latest", - target: "x86_64-apple-darwin", - cross: false, - rust: stable, - } - - { - os: "windows-2019", - target: "x86_64-pc-windows-msvc", - cross: false, - rust: stable, - } - - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e - with: - concurrent_skipping: "same_content_newer" - skip_after_successful_duplicate: "true" - paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml"]' - do_not_skip: '["workflow_dispatch"]' - - - uses: actions/checkout@v2 - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - - - name: Install toolchain - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746 - with: - profile: minimal - toolchain: ${{ matrix.triple.rust }} - override: true - target: ${{ matrix.triple.target }} - - - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - with: - key: ${{ matrix.triple.target }} - - - name: Build tests - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - run: cargo test --no-run --locked - env: - CARGO_HUSKY_DONT_INSTALL_HOOKS: true - RUST_BACKTRACE: full - - - name: Run tests - if: ${{ steps.skip_check.outputs.should_skip != 'true' }} - run: cargo test --no-fail-fast -- --nocapture --quiet - env: - CARGO_HUSKY_DONT_INSTALL_HOOKS: true - RUST_BACKTRACE: full diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 2a88232f..2df56f08 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: with: concurrent_skipping: "same_content_newer" skip_after_successful_duplicate: "false" - do_not_skip: '["workflow_dispatch"]' + do_not_skip: '["workflow_dispatch", "push"]' coverage: needs: pre_job @@ -37,7 +37,6 @@ jobs: profile: minimal toolchain: stable override: true - components: rustfmt - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 with: