Skip to content

CI for continuous fuzzing #7

CI for continuous fuzzing

CI for continuous fuzzing #7

Workflow file for this run

name: sbpf
on:
push:
branches:
- main
tags:
- v*.*.*
pull_request:
branches:
- main
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
rust: [stable, beta, nightly]
steps:
- uses: actions/checkout@v1
- name: Setup Rust (rustup)
run: |
rustup update ${{ matrix.rust }} --no-self-update
rustup default ${{ matrix.rust }}
rustup component add clippy
rustup component add rustfmt
shell: bash
- name: Lint
run: |
cargo fmt --all -- --check
cargo clippy --all --tests -- --deny=warnings
if: matrix.rust == 'nightly'
shell: bash
- name: Build and test
run: |
export RUSTFLAGS="-D warnings"
cargo build --verbose
cargo build --features="shuttle-test"
cargo test --verbose
cargo test --test exercise_instructions --verbose
shell: bash
- name: CLI - Lint
run: |
cargo fmt --all --manifest-path cli/Cargo.toml -- --check
cargo clippy --all --tests --manifest-path cli/Cargo.toml -- --deny=warnings
if: matrix.rust == 'nightly'
shell: bash
- name: CLI - Build and test
run: |
export RUSTFLAGS="-D warnings"
cargo build --manifest-path cli/Cargo.toml --verbose
cargo test --manifest-path cli/Cargo.toml --verbose
shell: bash
- name: Check fuzz
run: |
export RUSTFLAGS="-D warnings"
cargo install cargo-fuzz
cargo fuzz build
if: matrix.rust == 'nightly' && matrix.os != 'windows-latest'
shell: bash
- name: Benchmark
run: RUSTFLAGS="-D warnings" cargo bench -- --nocapture
if: matrix.rust == 'nightly' && matrix.os != 'windows-latest'
shell: bash
- name: (Continuous Fuzzing) Get commit hash
id: get-commit-hash
shell: bash
run: echo "commit_hash=$(git rev-parse HEAD 2>/dev/null)" >> $GITHUB_OUTPUT
if: matrix.rust == 'nightly' && matrix.os == 'ubuntu-latest'
- name: (Continuous Fuzzing) Upload fuzzers as GitHub Artifact
uses: actions/upload-artifact@v4
id: zip-upload-sbpf-fuzzers
with:
path: ./fuzz/target/x86_64-unknown-linux-gnu/release/
name: "artifact-rbpf-${{ matrix.os }}-${{github.run_id}}"
retention-days: 2
if: matrix.rust == 'nightly' && matrix.os == 'ubuntu-latest'
- name: (Continuous Fuzzing) Ping Fuzz Infrastructure
run: |
curl -L \
-X POST \
https://api.github.com/repos/asymmetric-research/FuzzCorp-bundler/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H "Authorization: Bearer ${{ secrets.PAT }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
--data '{"event_type": "rbpf_main", "client_payload":{"artifact_id": "${{steps.zip-upload-sbpf-fuzzers.outputs.artifact-id }}", "bundle_type": "${{ matrix.os }}", "hash":"${{ steps.get-commit-hash.outputs.commit_hash }}", "run_id":"${{ github.run_id}}", "name":"artifact-rbpf-${{ matrix.os }}-${{github.run_id}}"}}'
if: matrix.rust == 'nightly' && matrix.os == 'ubuntu-latest'
coverage:
name: Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup Rust (rustup)
run: |
rustup update nightly --no-self-update
rustup default nightly
rustup component add llvm-tools-preview
shell: bash
- name: Install cargo-llvm-cov
run: cargo install cargo-llvm-cov
shell: bash
- name: Generate test coverage
run: |
cargo llvm-cov --lcov --output-path coverage.info
shell: bash
- name: Upload test coverage
run: bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports"
shell: bash
release:
name: Release
needs: test
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v1
- name: Doc and package
run: |
cargo doc
cargo package
shell: bash
- name: Publish
env:
CRATES_IO_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
run: cargo publish --token "$CRATES_IO_TOKEN"