ci: clean up ci workflow

This commit is contained in:
ClementTsang 2022-05-01 16:36:43 -04:00
parent a9da449cef
commit 8cc361e443
2 changed files with 62 additions and 178 deletions

View File

@ -5,8 +5,9 @@
# - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml # - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml
# #
# CI pipeline should do: # CI pipeline should do:
# 1. cargo fmt # - cargo fmt on supported platforms
# 2. cargo build # - cargo test on supported platforms, cargo check on unsupported
# - cargo clippy after (apparently faster) on supported platforms
name: ci name: ci
@ -20,6 +21,7 @@ on:
env: env:
CARGO_INCREMENTAL: 0 CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 0 CARGO_PROFILE_DEV_DEBUG: 0
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
jobs: jobs:
rustfmt: rustfmt:
@ -32,13 +34,14 @@ jobs:
- macOS-latest - macOS-latest
- windows-2019 - windows-2019
steps: 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 uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e
with: with:
concurrent_skipping: "same_content_newer" concurrent_skipping: "same_content_newer"
skip_after_successful_duplicate: "true" 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"]' 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 - uses: actions/checkout@v2
if: ${{ steps.skip_check.outputs.should_skip != 'true' }} if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
@ -57,44 +60,81 @@ jobs:
- run: cargo fmt --all -- --check - run: cargo fmt --all -- --check
if: ${{ steps.skip_check.outputs.should_skip != 'true' }} if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
clippy: # Runs tests + clippy on the main supported platforms.
runs-on: ${{ matrix.os }} supported:
needs: [rustfmt]
runs-on: ${{ matrix.triple.os }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: triple:
- ubuntu-latest - {
- macOS-latest os: "ubuntu-latest",
- windows-2019 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: 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 uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e
with: with:
concurrent_skipping: "same_content_newer" concurrent_skipping: "same_content_newer"
skip_after_successful_duplicate: "true" 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"]' 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 - uses: actions/checkout@v2
if: ${{ steps.skip_check.outputs.should_skip != 'true' }} 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' }} if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746
with: with:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
components: clippy components: clippy
- uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - name: Enable Rust cache
if: ${{ steps.skip_check.outputs.should_skip != 'true' }} 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' }} 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 - name: Run tests
check: if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
needs: [rustfmt, clippy] 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 }} runs-on: ${{ matrix.triple.os }}
continue-on-error: true continue-on-error: true
strategy: strategy:
@ -102,12 +142,6 @@ jobs:
matrix: matrix:
triple: triple:
# x86 or x64 # x86 or x64
- {
os: "ubuntu-latest",
target: "x86_64-unknown-linux-gnu",
cross: false,
rust: stable,
}
- { - {
os: "ubuntu-latest", os: "ubuntu-latest",
target: "i686-unknown-linux-gnu", target: "i686-unknown-linux-gnu",
@ -126,18 +160,6 @@ jobs:
cross: true, cross: true,
rust: stable, 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", os: "windows-2019",
target: "i686-pc-windows-msvc", target: "i686-pc-windows-msvc",
@ -171,14 +193,6 @@ jobs:
rust: beta, rust: beta,
} }
# aarch64
- {
os: "ubuntu-latest",
target: "aarch64-unknown-linux-gnu",
cross: true,
rust: stable,
}
# armv7 # armv7
- { - {
os: "ubuntu-latest", os: "ubuntu-latest",
@ -220,13 +234,14 @@ jobs:
} }
steps: 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 uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e
with: with:
concurrent_skipping: "same_content_newer" concurrent_skipping: "same_content_newer"
skip_after_successful_duplicate: "true" 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"]' 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 - uses: actions/checkout@v2
if: ${{ steps.skip_check.outputs.should_skip != 'true' }} if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
@ -252,133 +267,3 @@ jobs:
command: check command: check
args: --all-targets --verbose --target=${{ matrix.triple.target }} --features "battery" --locked args: --all-targets --verbose --target=${{ matrix.triple.target }} --features "battery" --locked
use-cross: ${{ matrix.triple.cross }} 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

View File

@ -23,7 +23,7 @@ jobs:
with: with:
concurrent_skipping: "same_content_newer" concurrent_skipping: "same_content_newer"
skip_after_successful_duplicate: "false" skip_after_successful_duplicate: "false"
do_not_skip: '["workflow_dispatch"]' do_not_skip: '["workflow_dispatch", "push"]'
coverage: coverage:
needs: pre_job needs: pre_job
@ -37,7 +37,6 @@ jobs:
profile: minimal profile: minimal
toolchain: stable toolchain: stable
override: true override: true
components: rustfmt
- uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0 - uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0
with: with: