chore: where possible replace async-trait
with native async trait support in 1.75+
#516
Workflow file for this run
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 | |
- 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 }} | |
# 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: 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 | |
# 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 |