mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-26 22:20:18 +00:00
510aa5c404
Uses a personal action for simpler invocations of cargo/cross commands.
254 lines
8.2 KiB
YAML
254 lines
8.2 KiB
YAML
# Main CI pipeline to validate PRs.
|
|
#
|
|
# CI pipeline based on:
|
|
# - https://github.com/heim-rs/heim/blob/master/.github/workflows/ci.yml
|
|
# - https://github.com/BurntSushi/ripgrep/blob/master/.github/workflows/ci.yml
|
|
# - https://www.reillywood.com/blog/rust-faster-ci/
|
|
#
|
|
# CI pipeline should do:
|
|
# - cargo fmt on supported platforms
|
|
# - cargo test on supported platforms, cargo check on unsupported
|
|
# - cargo clippy after (apparently faster) on supported platforms
|
|
|
|
name: ci
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
env:
|
|
CARGO_INCREMENTAL: 0
|
|
CARGO_PROFILE_DEV_DEBUG: 0
|
|
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
|
|
|
|
jobs:
|
|
# Runs rustfmt + tests + clippy on the main supported platforms.
|
|
supported:
|
|
runs-on: ${{ matrix.info.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
info:
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "x86_64-unknown-linux-gnu",
|
|
cross: false,
|
|
}
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "aarch64-unknown-linux-gnu",
|
|
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",
|
|
"--no-default-features",
|
|
]
|
|
steps:
|
|
- 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", "push"]'
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
|
|
- name: Set up Rust toolchain
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
uses: dtolnay/rust-toolchain@88e7c2e1da2693cf72d58fce9416206818e61dea # https://github.com/dtolnay/rust-toolchain/commit/88e7c2e1da2693cf72d58fce9416206818e61dea
|
|
with:
|
|
toolchain: stable
|
|
components: rustfmt, clippy
|
|
target: ${{ matrix.info.target }}
|
|
|
|
- name: Enable Rust cache
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0
|
|
|
|
- name: Check cargo fmt
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
run: cargo fmt --all -- --check
|
|
|
|
- name: Build tests
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
uses: ClementTsang/cargo-action@v0.0.2
|
|
with:
|
|
command: test
|
|
args: --no-run --locked ${{ matrix.features }} --target=${{ matrix.info.target }}
|
|
use-cross: ${{ matrix.info.cross }}
|
|
cross-version: 0.2.4
|
|
env:
|
|
RUST_BACKTRACE: full
|
|
|
|
- name: Run tests
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
uses: ClementTsang/cargo-action@v0.0.2
|
|
with:
|
|
command: test
|
|
args: --no-fail-fast ${{ matrix.features }} --target=${{ matrix.info.target }} -- --nocapture --quiet
|
|
use-cross: ${{ matrix.info.cross }}
|
|
cross-version: 0.2.4
|
|
env:
|
|
RUST_BACKTRACE: full
|
|
|
|
- name: Run clippy
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
uses: ClementTsang/cargo-action@v0.0.2
|
|
with:
|
|
command: clippy
|
|
args: ${{ matrix.features }} --all-targets --workspace --target=${{ matrix.info.target }} -- -D warnings
|
|
use-cross: ${{ matrix.info.cross }}
|
|
cross-version: 0.2.4
|
|
env:
|
|
RUST_BACKTRACE: full
|
|
|
|
# Run cargo check on all other platforms
|
|
other_check:
|
|
runs-on: ${{ matrix.info.os }}
|
|
continue-on-error: true
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
info:
|
|
# x86 or x64
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "i686-unknown-linux-gnu",
|
|
cross: true,
|
|
rust: stable,
|
|
}
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "x86_64-unknown-linux-musl",
|
|
cross: false,
|
|
rust: stable,
|
|
}
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "i686-unknown-linux-musl",
|
|
cross: true,
|
|
rust: stable,
|
|
}
|
|
- {
|
|
os: "windows-2019",
|
|
target: "i686-pc-windows-msvc",
|
|
cross: false,
|
|
rust: stable,
|
|
}
|
|
- {
|
|
os: "windows-2019",
|
|
target: "x86_64-pc-windows-gnu",
|
|
cross: false,
|
|
rust: stable,
|
|
}
|
|
|
|
# Beta; should be allowed to fail.
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "x86_64-unknown-linux-gnu",
|
|
cross: false,
|
|
rust: beta,
|
|
}
|
|
- {
|
|
os: "macOS-latest",
|
|
target: "x86_64-apple-darwin",
|
|
cross: false,
|
|
rust: beta,
|
|
}
|
|
- {
|
|
os: "windows-2019",
|
|
target: "x86_64-pc-windows-msvc",
|
|
cross: false,
|
|
rust: beta,
|
|
}
|
|
|
|
# armv7
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "armv7-unknown-linux-gnueabihf",
|
|
cross: true,
|
|
rust: stable,
|
|
}
|
|
|
|
# armv6
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "arm-unknown-linux-gnueabihf",
|
|
cross: true,
|
|
rust: stable,
|
|
}
|
|
|
|
# PowerPC 64 LE
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "powerpc64le-unknown-linux-gnu",
|
|
cross: true,
|
|
rust: stable,
|
|
}
|
|
|
|
# Risc-V 64gc
|
|
- {
|
|
os: "ubuntu-latest",
|
|
target: "riscv64gc-unknown-linux-gnu",
|
|
cross: true,
|
|
rust: stable,
|
|
}
|
|
|
|
# macOS ARM
|
|
- {
|
|
os: "macOS-latest",
|
|
target: "aarch64-apple-darwin",
|
|
cross: true,
|
|
rust: stable,
|
|
}
|
|
|
|
steps:
|
|
- 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", "push"]'
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
|
|
- name: Set up Rust toolchain
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
uses: dtolnay/rust-toolchain@88e7c2e1da2693cf72d58fce9416206818e61dea # https://github.com/dtolnay/rust-toolchain/commit/88e7c2e1da2693cf72d58fce9416206818e61dea
|
|
with:
|
|
toolchain: ${{ matrix.info.rust }}
|
|
target: ${{ matrix.info.target }}
|
|
|
|
- name: Enable Rust cache
|
|
uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
with:
|
|
key: ${{ matrix.info.target }}
|
|
|
|
- name: Check
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
uses: ClementTsang/cargo-action@v0.0.2
|
|
with:
|
|
command: check
|
|
args: --all-targets --verbose --target=${{ matrix.info.target }} --locked
|
|
use-cross: ${{ matrix.info.cross }}
|
|
cross-version: 0.2.4
|