Skip to content

Rust

Rust #1078

Workflow file for this run

name: Rust
on:
merge_group:
pull_request:
workflow_dispatch:
concurrency:
group: rust-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: sudo apt-get install llvm
- name: Cargo sort
run: cargo install cargo-sort && cargo sort --check .
- name: Format
run: cargo fmt && git diff --exit-code
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
build:
strategy:
fail-fast: ${{ github.event_name == 'merge_group' }}
matrix:
environment: [ubuntu-latest, ubuntu-24.04, macos-latest]
toolchain: [stable, nightly]
plugins: [true, false]
cc: [cc, clang]
exclude:
- environment: macos-latest
plugins: true
- toolchain: stable
plugins: true
include:
- cc: cc
cxx: c++
- cc: clang
cxx: clang++
runs-on: ${{ matrix.environment }}
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Rustup
run: rustup default ${{ matrix.toolchain }}
- name: Install LLVM
run: |
LLVM_VERSION="$(rustc --version -v | grep '^LLVM version:' | grep -o '[0-9]\+' | head -n 1)"
if [[ ${{ matrix.environment }} = 'macos-latest' ]]; then
# smoelius: Around the time Rust 1.80 was released, running `brew update` would be
# followed by "cargo: command not found" errors.
# brew update
brew install llvm@"$LLVM_VERSION" || true
echo "/usr/local/opt/llvm/bin" >> "$GITHUB_PATH"
else
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh "$LLVM_VERSION"
fi
env:
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
- name: Build
run: cargo build -vv
- name: Run `cargo afl config`
run: |
PLUGINS="$(${{ matrix.plugins }} && echo --plugins)" || true
cargo run -- afl config --build $PLUGINS
- name: Run afl-system-config
run: cargo run -- afl system-config
- name: Build examples (with AFL instrumentation)
run: cargo run -- afl build --examples -vv
- name: Run tests
run: cargo test -p cargo-afl -vv
all-checks:
needs: [lint, build]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Check results
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1