Skip to content

chore: extract InteractiveShell as trait + refactor #355

chore: extract InteractiveShell as trait + refactor

chore: extract InteractiveShell as trait + refactor #355

Workflow file for this run

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:
strategy:
matrix:
include:
- host: "ubuntu-latest"
os: "linux"
arch: "x86_64"
- host: "macos-latest"
os: "macos"
arch: "aarch64"
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
- name: Enable cargo cache
uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --release
- name: "Upload binaries"
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.arch }}-${{ matrix.os }}
path: target/release/brush
build_cross:
name: "Build (${{ matrix.arch }}/${{ matrix.os }})"
runs-on: ubuntu-latest
strategy:
matrix:
include:
- target: "aarch64-unknown-linux-gnu"
arch: "aarch64"
os: "Linux"
binary_name: "brush"
- target: "wasm32-wasip1"
arch: "wasm32"
os: "WASI-0.1"
binary_name: "brush.wasm"
- target: "x86_64-pc-windows-gnu"
arch: "x86_64"
os: "Windows"
binary_name: "brush.exe"
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 native prerequisites
run: sudo apt-get update -y && sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Install cross-compilation toolchain
uses: taiki-e/install-action@v2
with:
tool: cross
- name: Build
run: cross build --release --target=${{ matrix.target }}
- name: "Upload binaries"
uses: actions/upload-artifact@v4
with:
name: binaries-${{ matrix.target }}
path: target/${{ matrix.target }}/release/${{ matrix.binary_name }}
test:
name: "Test"
runs-on: ubuntu-latest
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-llvm-cov
uses: taiki-e/install-action@v2
with:
tool: cargo-llvm-cov
- name: Test
run: |
set -euxo pipefail
source <(cargo llvm-cov show-env --export-prefix)
cargo llvm-cov clean --workspace
result=0
RUSTC_BOOTSTRAP=1 BRUSH_TEST_REPORT=0 cargo test --workspace -- -Z unstable-options --format junit >raw-test-output.txt 2>test-errors.txt || result=$?
if [[ -f test-errors.txt ]]; then
cat test-errors.txt
fi
cargo llvm-cov report --cobertura --output-path ./codecov.xml
# Process raw test output
n=1
while IFS= read -r line
do
if [[ ${line} == "<?xml"* ]]; then
((n++))
fi
echo "${line}" >>"test-results-${n}.xml"
done <raw-test-output.txt
exit ${result}
- name: "Upload test results"
uses: actions/upload-artifact@v4
if: always()
with:
name: test-reports
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"
filename: "codecov.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
path: code-coverage-results.md
- name: "Upload event file"
uses: actions/upload-artifact@v4
with:
name: event-file
path: ${{ github.event_path }}
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
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