build(deps): bump the cargo group with 3 updates (#258) #656
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "CI" | |
on: | |
pull_request: | |
paths-ignore: | |
- "release-plz.toml" | |
push: | |
paths-ignore: | |
- "docs/**" | |
- "**.md" | |
- "LICENSE" | |
- "release-plz.toml" | |
branches: | |
- main | |
env: | |
RUST_BACKTRACE: 1 | |
CARGO_TERM_COLOR: always | |
CLICOLOR: 1 | |
CLICOLOR_FORCE: 1 | |
permissions: | |
actions: read | |
contents: read | |
jobs: | |
# Build and upload release binaries for all relevant architectures. | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# Build for x86_64/linux target on native host. | |
- host: "ubuntu-latest" | |
target: "" | |
os: "linux" | |
arch: "x86_64" | |
binary_name: "brush" | |
# Build for aarch64/macos target on native host. | |
- host: "macos-latest" | |
target: "" | |
os: "macos" | |
arch: "aarch64" | |
required_tools: "" | |
binary_name: "brush" | |
# Build for aarch64/linux target on x86_64/linux host. | |
- host: "ubuntu-latest" | |
target: "aarch64-unknown-linux-gnu" | |
os: "linux" | |
arch: "aarch64" | |
required_tools: "gcc-aarch64-linux-gnu" | |
binary_name: "brush" | |
# Build for WASI-0.1 target on x86_64/linux host. | |
- host: "ubuntu-latest" | |
target: "wasm32-wasip1" | |
os: "wasi-0.1" | |
arch: "wasm32" | |
required_tools: "" | |
binary_name: "brush.wasm" | |
# Build for x86_64/windows target on x86_64/linux host. | |
- host: "ubuntu-latest" | |
target: "x86_64-pc-windows-gnu" | |
os: "windows" | |
arch: "x86_64" | |
required_tools: "" | |
binary_name: "brush.exe" | |
name: "Build (${{ matrix.arch }}/${{ matrix.os }})" | |
runs-on: ${{ matrix.host }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
targets: ${{ matrix.target }} | |
- name: Enable cargo cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
key: "${{ matrix.target }}" | |
- name: Install additional prerequisite tools | |
if: ${{ matrix.required_tools != '' }} | |
run: sudo apt-get update -y && sudo apt-get install -y ${{ matrix.required_tools }} | |
- name: Install cross-compilation toolchain | |
if: ${{ matrix.target != '' }} | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cross | |
- name: "Build (native)" | |
if: ${{ matrix.target == '' }} | |
run: cargo build --release --all-targets | |
- name: "Build (cross)" | |
if: ${{ matrix.target != '' }} | |
run: cross build --release --target=${{ matrix.target }} | |
- name: "Upload binaries" | |
uses: actions/upload-artifact@v4 | |
with: | |
name: binaries-${{ matrix.arch }}-${{ matrix.os }} | |
path: target/${{ matrix.target }}/release/${{ matrix.binary_name }} | |
- name: "Upload integration test binaries" | |
if: ${{ matrix.target == '' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: integration-tests-${{ matrix.arch }}-${{ matrix.os }} | |
path: | | |
target/${{ matrix.target }}/release/deps/brush_*_tests-* | |
!**/*.d | |
# Test functional correctness | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- host: "ubuntu-latest" | |
variant: "linux" | |
artifact_suffix: "" | |
name_suffix: "(linux)" | |
- host: "macos-latest" | |
variant: "macos" | |
artifact_suffix: "-macos" | |
name_suffix: "(macOS)" | |
name: "Test ${{ matrix.name_suffix }}" | |
runs-on: ${{ matrix.host }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
components: llvm-tools-preview | |
- name: Enable cargo cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
# Needed to make sure cargo-deny is correctly cached. | |
cache-all-crates: true | |
- name: Install cargo-nextest | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-nextest | |
- name: Install cargo-llvm-cov | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-llvm-cov | |
- name: Set up Homebrew | |
id: set-up-homebrew | |
uses: Homebrew/actions/setup-homebrew@master | |
with: | |
stable: true | |
- name: "Install recent bash for tests" | |
run: | | |
brew install bash | |
BASH_PATH="$(brew --prefix bash)/bin/bash" | |
echo "Using bash from: ${BASH_PATH}" | |
echo "bash version:" | |
${BASH_PATH} --version | |
echo "BASH_PATH=${BASH_PATH}">>$GITHUB_ENV | |
- name: "Download recent bash-completion sources for tests" | |
uses: actions/checkout@v4 | |
with: | |
repository: "scop/bash-completion" | |
ref: "2.14.0" | |
path: "bash-completion" | |
- name: "Setup bash-completion" | |
run: | | |
echo "BASH_COMPLETION_PATH=${GITHUB_WORKSPACE}/bash-completion/bash_completion">>$GITHUB_ENV | |
- name: Test | |
run: | | |
set -euxo pipefail | |
# Set us up to use cargo-llvm-cov | |
source <(cargo llvm-cov show-env --export-prefix) | |
cargo llvm-cov clean --workspace | |
# Run the tests | |
result=0 | |
cargo nextest run --workspace --no-fail-fast || result=$? | |
# Generate code coverage report | |
cargo llvm-cov report --cobertura --output-path ./codecov-${{ matrix.variant }}.xml || result=$? | |
# Rename test results. | |
mv target/nextest/default/test-results.xml ./test-results-${{ matrix.variant }}.xml | |
# Report the actual test results | |
exit ${result} | |
- name: "Upload test results" | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: test-reports${{ matrix.artifact_suffix }} | |
path: test-results-*.xml | |
- name: "Generate code coverage report" | |
uses: clearlyip/code-coverage-report-action@v5 | |
if: always() | |
id: "code_coverage_report" | |
with: | |
artifact_download_workflow_names: "CI" | |
artifact_name: coverage-%name%${{ matrix.artifact_suffix }} | |
filename: codecov-${{ matrix.variant }}.xml | |
overall_coverage_fail_threshold: 70 | |
only_list_changed_files: ${{ github.event_name == 'pull_request' }} | |
fail_on_negative_difference: true | |
negative_difference_by: "overall" | |
negative_difference_threshold: 5 | |
- name: "Upload code coverage report" | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: codecov-reports${{ matrix.artifact_suffix }} | |
path: code-coverage-results.md | |
# Static analysis of the code. | |
check: | |
name: "Source code checks" | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# Test latest stable as well as MSRV. | |
rust-version: ["stable", "1.75.0"] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up rust toolchain (${{ matrix.rust-version }}) | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ matrix.rust-version }} | |
components: clippy, rustfmt | |
- name: Enable cargo cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
# Needed to make sure cargo-deny is correctly cached. | |
cache-all-crates: true | |
- name: Format check | |
run: cargo fmt --check --all | |
- name: Check | |
run: cargo check --all-features --all-targets | |
- name: Install cargo-deny | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-deny | |
- name: Deny check | |
run: cargo deny --all-features check all | |
- name: Clippy check | |
if: matrix.rust-version == 'stable' | |
run: cargo clippy --all-features --all-targets | |
# Check for unneeded dependencies. | |
check-deps: | |
name: "Check for unneeded dependencies" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up nightly rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: nightly | |
- name: Install cargo-udeps | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-udeps | |
- name: Check for unused dependencies | |
run: cargo udeps --workspace --all-targets --all-features | |
# Performance analysis of the code. | |
benchmark: | |
if: github.event_name == 'pull_request' | |
name: "Benchmarks" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: pr | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: main | |
ref: main | |
- name: Set up rust toolchain | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Enable cargo cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
./pr | |
./main | |
- name: Performance analysis on PR | |
run: cargo bench --workspace -- --output-format bencher | tee benchmarks.txt | |
working-directory: pr | |
- name: Performance analysis on main | |
run: cargo bench --workspace -- --output-format bencher | tee benchmarks.txt | |
working-directory: main | |
- name: Compare benchmark results | |
run: | | |
./pr/scripts/compare-benchmark-results.py -b main/benchmarks.txt -t pr/benchmarks.txt >benchmark-results.md | |
- name: Upload performance results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: perf-reports | |
path: | | |
pr/benchmarks.txt | |
main/benchmarks.txt | |
benchmark-results.md | |
# Test release binary on a variety of OS platforms. | |
os-tests: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
# N.B. We don't include Ubuntu because it's already covered by the initial test job. | |
- container: "fedora:latest" | |
description: "Fedora/latest" | |
prereqs_command: "dnf install -y bash-completion iputils grep less sed util-linux" | |
- container: "debian:latest" | |
description: "Debian/latest" | |
prereqs_command: "apt-get update -y && apt-get install -y bash-completion bsdmainutils iputils-ping grep less sed" | |
- container: "archlinux:latest" | |
description: "Arch Linux/latest" | |
prereqs_command: "pacman -Sy --noconfirm bash-completion iputils grep less sed util-linux" | |
name: "OS target tests (${{ matrix.description }})" | |
runs-on: ubuntu-latest | |
container: ${{ matrix.container }} | |
needs: build | |
steps: | |
# Checkout sources for YAML-based test cases | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: sources | |
- name: Download binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: binaries-x86_64-linux | |
path: binaries | |
- name: Download integration test binaries | |
uses: actions/download-artifact@v4 | |
with: | |
name: integration-tests-x86_64-linux | |
path: binaries | |
- name: Setup downloads | |
run: | | |
# N.B. Can't use -o pipefail because it's not supported on Debian. | |
set -eux | |
chmod +x binaries/* | |
ls -l -R sources/brush-shell/tests | |
ls -l binaries | |
- name: Install prerequisites | |
if: ${{ matrix.prereqs_command != '' }} | |
run: ${{ matrix.prereqs_command }} | |
- name: Run tests | |
run: | | |
export BRUSH_PATH=$PWD/binaries/brush | |
export BRUSH_COMPAT_TEST_CASES=$PWD/sources/brush-shell/tests/cases | |
export BRUSH_VERBOSE=true | |
result=0 | |
for test_name in binaries/*tests*; do | |
# TODO: Re-enable interactive tests. | |
if [[ ${test_name} == *interactive* ]]; then | |
echo "WARNING: skipping interactive test: ${test_name}" | |
continue | |
fi | |
echo "Running test: ${test_name}" | |
chmod +x ${test_name} | |
${test_name} || result=$? | |
done | |
exit ${result} |