mirror of
https://github.com/imsnif/bandwhich.git
synced 2026-02-09 01:59:18 +08:00
Bumps the github-actions group with 3 updates in the / directory: [actions/checkout](https://github.com/actions/checkout), [taiki-e/cache-cargo-install-action](https://github.com/taiki-e/cache-cargo-install-action) and [actions/upload-artifact](https://github.com/actions/upload-artifact). Updates `actions/checkout` from 4 to 6 - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v4...v6) Updates `taiki-e/cache-cargo-install-action` from 2 to 3 - [Release notes](https://github.com/taiki-e/cache-cargo-install-action/releases) - [Changelog](https://github.com/taiki-e/cache-cargo-install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/cache-cargo-install-action/compare/v2...v3) Updates `actions/upload-artifact` from 4 to 6 - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v4...v6) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: taiki-e/cache-cargo-install-action dependency-version: '3' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions - dependency-name: actions/upload-artifact dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major dependency-group: github-actions ... Signed-off-by: dependabot[bot] <support@github.com>
199 lines
6.9 KiB
YAML
199 lines
6.9 KiB
YAML
name: ci
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
jobs:
|
|
get-msrv:
|
|
name: Get declared MSRV from Cargo.toml
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
msrv: ${{ steps.get_msrv.outputs.msrv }}
|
|
steps:
|
|
- name: Install ripgrep
|
|
run: sudo apt-get install -y ripgrep
|
|
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Get MSRV
|
|
id: get_msrv
|
|
run: rg '^\s*rust-version\s*=\s*"(\d+(\.\d+){0,2})"' --replace 'msrv=$1' Cargo.toml >> "$GITHUB_OUTPUT"
|
|
|
|
check-fmt:
|
|
name: Check code formatting
|
|
runs-on: ubuntu-latest
|
|
needs: get-msrv
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
rust:
|
|
- ${{ needs.get-msrv.outputs.msrv }}
|
|
- stable
|
|
- nightly
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
components: rustfmt
|
|
|
|
- name: Check formatting
|
|
run: cargo fmt --all -- --check
|
|
|
|
test:
|
|
name: Test on each target
|
|
needs: get-msrv
|
|
env:
|
|
# use sccache
|
|
# It's too much of a hassle to set up sccache in cross.
|
|
# See https://github.com/cross-rs/cross/wiki/Recipes#sccache.
|
|
SCCACHE_GHA_ENABLED: ${{ matrix.cargo == 'cargo' && 'true' || 'false'}}
|
|
RUSTC_WRAPPER: ${{ matrix.cargo == 'cargo' && 'sccache' || '' }}
|
|
# Emit backtraces on panics.
|
|
RUST_BACKTRACE: 1
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
build:
|
|
- android-aarch64
|
|
- linux-aarch64-gnu
|
|
- linux-aarch64-musl
|
|
- linux-armv7-gnueabihf
|
|
- linux-armv7-musleabihf
|
|
- linux-x64-gnu
|
|
- linux-x64-musl
|
|
- macos-aarch64
|
|
- macos-x64
|
|
- windows-x64-msvc
|
|
rust:
|
|
- ${{ needs.get-msrv.outputs.msrv }}
|
|
- stable
|
|
- nightly
|
|
include:
|
|
- os: ubuntu-latest # default
|
|
- cargo: cargo # default; overwrite with `cross` if necessary
|
|
- build: android-aarch64
|
|
target: aarch64-linux-android
|
|
cargo: cross
|
|
- build: linux-aarch64-gnu
|
|
target: aarch64-unknown-linux-gnu
|
|
cargo: cross
|
|
- build: linux-aarch64-musl
|
|
target: aarch64-unknown-linux-musl
|
|
cargo: cross
|
|
- build: linux-armv7-gnueabihf
|
|
target: armv7-unknown-linux-gnueabihf
|
|
cargo: cross
|
|
- build: linux-armv7-musleabihf
|
|
target: armv7-unknown-linux-musleabihf
|
|
cargo: cross
|
|
- build: linux-x64-gnu
|
|
target: x86_64-unknown-linux-gnu
|
|
- build: linux-x64-musl
|
|
target: x86_64-unknown-linux-musl
|
|
- build: macos-aarch64
|
|
# Go back ot `macos-latest` after migration is complete
|
|
# See https://github.blog/changelog/2024-04-01-macos-14-sonoma-is-generally-available-and-the-latest-macos-runner-image/.
|
|
os: macos-14
|
|
target: aarch64-apple-darwin
|
|
- build: macos-x64
|
|
os: macos-14
|
|
target: x86_64-apple-darwin
|
|
- build: windows-x64-msvc
|
|
os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Install Rust
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ matrix.rust }}
|
|
targets: ${{ matrix.target }}
|
|
components: clippy
|
|
|
|
- name: Set up sccache
|
|
# It's too much of a hassle to set up sccache in cross.
|
|
# See https://github.com/cross-rs/cross/wiki/Recipes#sccache.
|
|
if: matrix.cargo == 'cargo'
|
|
uses: mozilla-actions/sccache-action@v0.0.9
|
|
|
|
- name: Install cross
|
|
if: matrix.cargo == 'cross'
|
|
# The latest release of `cross` is not able to build/link for `aarch64-linux-android`
|
|
# See: https://github.com/cross-rs/cross/issues/1222
|
|
# This is fixed on `main` but not yet released. To avoid a breakage somewhen in the future
|
|
# pin the cross revision used to the latest HEAD at 04/2024.
|
|
# Go back to taiki-e/install-action once cross 0.3 is released.
|
|
uses: taiki-e/cache-cargo-install-action@v3
|
|
with:
|
|
tool: cross
|
|
git: https://github.com/cross-rs/cross.git
|
|
rev: 085092c
|
|
|
|
- name: Build
|
|
id: build
|
|
run: ${{ matrix.cargo }} build --verbose --target ${{ matrix.target }}
|
|
|
|
# This is useful for debugging problems when the expected build artifacts
|
|
# (like shell completions and man pages) aren't generated.
|
|
- name: Show build.rs stderr
|
|
shell: bash
|
|
run: |
|
|
# it's probably okay to assume no spaces?
|
|
STDERR_FILES=$(find "./target/debug" -name stderr | grep bandwhich || true)
|
|
for FILE in $STDERR_FILES; do
|
|
echo "::group::$FILE"
|
|
cat "$FILE"
|
|
echo "::endgroup::"
|
|
done
|
|
|
|
- name: Run clippy
|
|
run: ${{ matrix.cargo }} clippy --all-targets --target ${{ matrix.target }} -- -D warnings
|
|
|
|
- name: Install npcap on Windows
|
|
# PRs from other repositories cannot be trusted with repository secrets
|
|
if: matrix.os == 'windows-latest' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
|
|
env:
|
|
NPCAP_OEM_URL: ${{ secrets.NPCAP_OEM_URL }}
|
|
run: |
|
|
Invoke-WebRequest -Uri "$env:NPCAP_OEM_URL" -OutFile "$env:TEMP/npcap-oem.exe"
|
|
# for this ridiculous `&` syntax alone, I'd rather use COBOL than Powershell
|
|
# see https://stackoverflow.com/a/1674950/5637701
|
|
& "$env:TEMP/npcap-oem.exe" /S
|
|
|
|
- name: Run tests
|
|
id: run_tests
|
|
# npcap is needed to run tests on Windows, so unfortunately we cannot run tests
|
|
# on PRs from other repositories
|
|
if: matrix.os != 'windows-latest' || github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
|
env:
|
|
# make insta generate new snapshots in CI
|
|
INSTA_UPDATE: new
|
|
run: ${{ matrix.cargo }} test --all-targets --target ${{ matrix.target }}
|
|
|
|
- name: Upload snapshots of failed tests
|
|
if: ${{ failure() && steps.run_tests.outcome == 'failure' }}
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: ${{ matrix.os }}-${{ matrix.rust }}-failed_snapshots
|
|
path: '**/*.snap.new'
|
|
|
|
- name: Upload binaries
|
|
if: ${{ success() || steps.build.outcome == 'success' }}
|
|
uses: actions/upload-artifact@v6
|
|
with:
|
|
name: ${{ matrix.target }}-${{ matrix.rust }}
|
|
path: |
|
|
target/${{ matrix.target }}/debug/bandwhich
|
|
target/${{ matrix.target }}/debug/bandwhich.exe
|
|
target/${{ matrix.target }}/debug/bandwhich.pdb
|