2020-11-26 08:28:56 +00:00
|
|
|
# Main CI pipeline to validate PRs.
|
|
|
|
#
|
2020-11-21 20:28:46 +00:00
|
|
|
# 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
|
2022-05-01 19:47:30 +00:00
|
|
|
#
|
|
|
|
# CI pipeline should do:
|
2022-05-01 20:36:43 +00:00
|
|
|
# - cargo fmt on supported platforms
|
|
|
|
# - cargo test on supported platforms, cargo check on unsupported
|
|
|
|
# - cargo clippy after (apparently faster) on supported platforms
|
2020-11-21 20:28:46 +00:00
|
|
|
|
|
|
|
name: ci
|
2020-11-21 20:31:19 +00:00
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
2022-04-29 22:15:49 +00:00
|
|
|
env:
|
|
|
|
CARGO_INCREMENTAL: 0
|
|
|
|
CARGO_PROFILE_DEV_DEBUG: 0
|
2022-05-01 20:36:43 +00:00
|
|
|
CARGO_HUSKY_DONT_INSTALL_HOOKS: true
|
2022-04-29 22:15:49 +00:00
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
jobs:
|
|
|
|
rustfmt:
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
2021-05-14 03:20:08 +00:00
|
|
|
fail-fast: false
|
2020-11-21 20:28:46 +00:00
|
|
|
matrix:
|
|
|
|
os:
|
2021-05-13 03:21:09 +00:00
|
|
|
- ubuntu-latest
|
2020-11-21 20:28:46 +00:00
|
|
|
- macOS-latest
|
2020-11-21 20:31:19 +00:00
|
|
|
- windows-2019
|
2020-11-21 20:28:46 +00:00
|
|
|
steps:
|
2022-05-01 20:36:43 +00:00
|
|
|
- name: Check if this action should be skipped
|
|
|
|
id: skip_check
|
2021-12-22 22:29:50 +00:00
|
|
|
uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e
|
2021-11-27 11:39:22 +00:00
|
|
|
with:
|
|
|
|
concurrent_skipping: "same_content_newer"
|
|
|
|
skip_after_successful_duplicate: "true"
|
2021-11-28 09:04:23 +00:00
|
|
|
paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml"]'
|
2022-05-01 20:36:43 +00:00
|
|
|
do_not_skip: '["workflow_dispatch", "push"]'
|
2021-11-27 11:39:22 +00:00
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
- uses: actions/checkout@v2
|
2021-11-27 11:39:22 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
|
|
|
2021-12-22 22:29:50 +00:00
|
|
|
- uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746
|
2021-11-27 11:39:22 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2020-11-21 20:28:46 +00:00
|
|
|
with:
|
|
|
|
profile: minimal
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
components: rustfmt
|
2021-07-27 22:59:17 +00:00
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
- run: cargo fmt --all -- --check
|
2021-11-27 11:39:22 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2020-11-21 20:28:46 +00:00
|
|
|
|
2022-05-01 20:36:43 +00:00
|
|
|
# Runs tests + clippy on the main supported platforms.
|
|
|
|
supported:
|
|
|
|
needs: [rustfmt]
|
|
|
|
runs-on: ${{ matrix.triple.os }}
|
2020-11-21 20:28:46 +00:00
|
|
|
strategy:
|
2021-05-14 03:20:08 +00:00
|
|
|
fail-fast: false
|
2020-11-21 20:28:46 +00:00
|
|
|
matrix:
|
2022-05-01 20:36:43 +00:00
|
|
|
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",
|
|
|
|
]
|
2020-11-21 20:28:46 +00:00
|
|
|
steps:
|
2022-05-01 20:36:43 +00:00
|
|
|
- name: Check if this action should be skipped
|
|
|
|
id: skip_check
|
2021-12-22 22:29:50 +00:00
|
|
|
uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e
|
2021-11-27 11:39:22 +00:00
|
|
|
with:
|
|
|
|
concurrent_skipping: "same_content_newer"
|
|
|
|
skip_after_successful_duplicate: "true"
|
2021-11-28 09:04:23 +00:00
|
|
|
paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml"]'
|
2022-05-01 20:36:43 +00:00
|
|
|
do_not_skip: '["workflow_dispatch", "push"]'
|
2021-11-27 11:39:22 +00:00
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
- uses: actions/checkout@v2
|
2021-11-27 11:39:22 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2020-11-21 20:31:19 +00:00
|
|
|
|
2022-05-01 20:36:43 +00:00
|
|
|
- name: Setup Rust toolchain
|
2021-11-27 11:39:22 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2022-05-01 20:36:43 +00:00
|
|
|
uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746
|
2020-11-21 20:28:46 +00:00
|
|
|
with:
|
|
|
|
profile: minimal
|
|
|
|
toolchain: stable
|
|
|
|
override: true
|
|
|
|
components: clippy
|
2020-11-21 20:31:19 +00:00
|
|
|
|
2022-05-01 20:36:43 +00:00
|
|
|
- name: Enable Rust cache
|
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
|
|
uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0
|
|
|
|
|
|
|
|
- name: Build tests
|
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
|
|
|
run: cargo test --no-run --locked ${{ matrix.features }}
|
|
|
|
env:
|
|
|
|
RUST_BACKTRACE: full
|
|
|
|
|
|
|
|
- name: Run tests
|
2021-11-27 11:39:22 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2022-05-01 20:36:43 +00:00
|
|
|
run: cargo test --no-fail-fast ${{ matrix.features }} -- --nocapture --quiet
|
|
|
|
env:
|
|
|
|
RUST_BACKTRACE: full
|
2021-07-27 22:59:17 +00:00
|
|
|
|
2022-05-01 20:36:43 +00:00
|
|
|
- name: Run clippy
|
2021-11-27 11:39:22 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2022-05-01 20:36:43 +00:00
|
|
|
run: cargo clippy ${{ matrix.features }} --workspace -- -D warnings
|
2020-11-21 20:28:46 +00:00
|
|
|
|
2022-05-01 20:36:43 +00:00
|
|
|
# Run cargo check on all other platforms
|
|
|
|
other_check:
|
|
|
|
needs: [rustfmt]
|
2020-11-21 20:28:46 +00:00
|
|
|
runs-on: ${{ matrix.triple.os }}
|
2021-05-13 03:21:09 +00:00
|
|
|
continue-on-error: true
|
2020-11-21 20:28:46 +00:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
triple:
|
2021-10-03 21:49:29 +00:00
|
|
|
# x86 or x64
|
2020-11-21 20:28:46 +00:00
|
|
|
- {
|
2021-05-13 03:21:09 +00:00
|
|
|
os: "ubuntu-latest",
|
2020-11-21 20:28:46 +00:00
|
|
|
target: "i686-unknown-linux-gnu",
|
|
|
|
cross: true,
|
|
|
|
rust: stable,
|
|
|
|
}
|
2021-10-03 21:49:29 +00:00
|
|
|
- {
|
|
|
|
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,
|
|
|
|
}
|
2020-11-21 20:28:46 +00:00
|
|
|
- {
|
2020-11-21 20:31:19 +00:00
|
|
|
os: "windows-2019",
|
2021-07-13 03:02:48 +00:00
|
|
|
target: "i686-pc-windows-msvc",
|
2021-10-03 21:49:29 +00:00
|
|
|
cross: false,
|
|
|
|
rust: stable,
|
|
|
|
}
|
|
|
|
- {
|
|
|
|
os: "windows-2019",
|
|
|
|
target: "x86_64-pc-windows-gnu",
|
|
|
|
cross: false,
|
2020-11-21 20:28:46 +00:00
|
|
|
rust: stable,
|
|
|
|
}
|
|
|
|
|
2022-04-27 22:34:49 +00:00
|
|
|
# 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,
|
|
|
|
}
|
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
# armv7
|
|
|
|
- {
|
2021-05-13 03:21:09 +00:00
|
|
|
os: "ubuntu-latest",
|
2020-11-21 20:28:46 +00:00
|
|
|
target: "armv7-unknown-linux-gnueabihf",
|
|
|
|
cross: true,
|
|
|
|
rust: stable,
|
|
|
|
}
|
|
|
|
|
2021-03-04 19:24:21 +00:00
|
|
|
# armv6
|
|
|
|
- {
|
2021-05-13 03:21:09 +00:00
|
|
|
os: "ubuntu-latest",
|
2021-03-04 19:24:21 +00:00
|
|
|
target: "arm-unknown-linux-gnueabihf",
|
|
|
|
cross: true,
|
|
|
|
rust: stable,
|
|
|
|
}
|
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
# PowerPC 64 LE
|
|
|
|
- {
|
2021-05-13 03:21:09 +00:00
|
|
|
os: "ubuntu-latest",
|
2020-11-21 20:28:46 +00:00
|
|
|
target: "powerpc64le-unknown-linux-gnu",
|
|
|
|
cross: true,
|
|
|
|
rust: stable,
|
|
|
|
}
|
|
|
|
|
2021-07-31 20:24:16 +00:00
|
|
|
# Risc-V 64gc
|
|
|
|
- {
|
|
|
|
os: "ubuntu-latest",
|
|
|
|
target: "riscv64gc-unknown-linux-gnu",
|
|
|
|
cross: true,
|
|
|
|
rust: stable,
|
|
|
|
}
|
|
|
|
|
2021-03-04 19:24:21 +00:00
|
|
|
# macOS ARM
|
|
|
|
- {
|
|
|
|
os: "macOS-latest",
|
|
|
|
target: "aarch64-apple-darwin",
|
|
|
|
cross: true,
|
|
|
|
rust: stable,
|
|
|
|
}
|
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
steps:
|
2022-05-01 20:36:43 +00:00
|
|
|
- name: Check if this action should be skipped
|
|
|
|
id: skip_check
|
2021-12-22 22:29:50 +00:00
|
|
|
uses: fkirc/skip-duplicate-actions@38c3738dcac87b41e2b7038775457756c793566e # https://github.com/fkirc/skip-duplicate-actions/commit/38c3738dcac87b41e2b7038775457756c793566e
|
2021-11-27 11:27:51 +00:00
|
|
|
with:
|
|
|
|
concurrent_skipping: "same_content_newer"
|
|
|
|
skip_after_successful_duplicate: "true"
|
2021-11-28 09:04:23 +00:00
|
|
|
paths: '[".cargo/**", ".github/workflows/ci.yml", "sample_configs/**", "src/**", "tests/**", "build.rs", "Cargo.lock", "Cargo.toml", "clippy.toml", "rustfmt.toml"]'
|
2022-05-01 20:36:43 +00:00
|
|
|
do_not_skip: '["workflow_dispatch", "push"]'
|
2021-11-27 11:27:51 +00:00
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
- uses: actions/checkout@v2
|
2021-11-27 11:27:51 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2020-11-21 20:28:46 +00:00
|
|
|
|
|
|
|
- name: Install toolchain
|
2021-11-27 11:27:51 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2021-12-22 22:29:50 +00:00
|
|
|
uses: actions-rs/toolchain@88dc2356392166efad76775c878094f4e83ff746 # https://github.com/actions-rs/toolchain/commit/88dc2356392166efad76775c878094f4e83ff746
|
2020-11-21 20:28:46 +00:00
|
|
|
with:
|
|
|
|
profile: minimal
|
2020-11-21 20:31:19 +00:00
|
|
|
toolchain: ${{ matrix.triple.rust }}
|
2020-11-21 20:28:46 +00:00
|
|
|
override: true
|
2020-11-21 20:31:19 +00:00
|
|
|
target: ${{ matrix.triple.target }}
|
2020-11-21 20:28:46 +00:00
|
|
|
|
2022-05-01 19:47:30 +00:00
|
|
|
- uses: Swatinem/rust-cache@cb2cf0cc7c5198d3364b9630e2c3d457f160790c # 1.4.0
|
2021-11-27 11:27:51 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2021-07-31 20:24:16 +00:00
|
|
|
with:
|
|
|
|
key: ${{ matrix.triple.target }}
|
2021-03-13 02:41:48 +00:00
|
|
|
|
2020-11-21 20:28:46 +00:00
|
|
|
- name: Check
|
2021-11-27 11:27:51 +00:00
|
|
|
if: ${{ steps.skip_check.outputs.should_skip != 'true' }}
|
2020-11-21 20:28:46 +00:00
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
command: check
|
2022-04-29 22:15:49 +00:00
|
|
|
args: --all-targets --verbose --target=${{ matrix.triple.target }} --features "battery" --locked
|
2021-08-20 02:16:44 +00:00
|
|
|
use-cross: ${{ matrix.triple.cross }}
|