Skip to content

CI

CI #473

Workflow file for this run

name: CI
on:
merge_group:
pull_request:
schedule:
- cron: "0 3 * * tue"
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
check-up-to-dateness:
outputs:
is-up-to-date: ${{ steps.main.outputs.is-up-to-date }}
runs-on: ubuntu-latest
steps:
- id: main
uses: trailofbits/check-up-to-dateness@v1
test:
needs: [check-up-to-dateness]
if: needs.check-up-to-dateness.outputs.is-up-to-date != 'true'
strategy:
fail-fast: ${{ github.event_name == 'merge_group' }}
matrix:
# smoelius: Test with `macos-latest` once the repository is made public.
environment: [ubuntu-latest]
anchor-version: [0.32.1]
runs-on: ${{ matrix.environment }}
defaults:
run:
shell: bash
env:
GROUP_RUNNER: target.'cfg(all())'.runner = 'group-runner'
steps:
- name: Free up space on Ubuntu
if: ${{ matrix.environment == 'ubuntu-latest' }}
run: |
# https://github.com/actions/runner-images/issues/2606#issuecomment-772683150
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/share/swift
# du -sh /usr/*/* 2>/dev/null | sort -h || true
- uses: actions/checkout@v5
- uses: actions/cache/restore@v4
id: cache-restore
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
path: |
~/.avm
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.dylint_drivers/
~/.rustup/toolchains/
agave/
target/dylint/
- name: Rustup
run: rustup update
- name: Install Agave prerequisites
run: |
sudo apt update
sudo apt install libclang-dev libudev-dev llvm protobuf-compiler
- name: Install Agave
run: |
if ! ./agave/bin/solana-test-validator --version; then
git clone https://github.com/anza-xyz/agave
cd agave
# smoelius: The next commit merges `SBPF v0.12.2`: https://github.com/anza-xyz/agave/pull/7498
git checkout cd291424d3d71c1a3be0c2c919916dcaa272d162
sed -i '/^\[patch\.crates-io\]$/a solana-sbpf = { git = "https://github.com/trail-of-forks/sbpf-coverage" }' Cargo.toml
# smoelius: `solana` is not used directly, but it is called by `anchor`.
sed -i '/^binArgs=()$/i BINS=(cargo-build-sbf solana-test-validator solana); DCOU_BINS=()' scripts/cargo-install-all.sh
./scripts/cargo-install-all.sh .
cd ..
fi
echo "$PWD/agave/bin" >> "$GITHUB_PATH"
# smoelius: https://www.anchor-lang.com/docs/installation
- name: Install Anchor
run: |
mkdir ~/.config/solana
cp etc/rfc8032_test_vector.json ~/.config/solana/id.json
if [[ "$(anchor --version)" != 'anchor-cli ${{ matrix.anchor-version }}' ]]; then
cargo install --git https://github.com/coral-xyz/anchor --tag v${{ matrix.anchor-version }} anchor-cli --force
fi
- uses: taiki-e/install-action@v2
with:
tool: cargo-hack, cargo-udeps
- name: Install CI tools
run: |
rustup +nightly component add clippy rustfmt
cargo install cargo-dylint dylint-link || true
cargo install group-runner || true
- name: Build
run: cargo build
- name: Sanity test fixtures
run: |
for X in fixtures/*; do
pushd "$X" && yarn && anchor test && popd
done
- name: Test
run: |
cargo test --config "$GROUP_RUNNER"
# https://github.com/actions/cache/tree/main/save#always-save-cache
- uses: actions/cache/save@v4
# smoelius: Update the cache regardless of whether a cache hit occurred, in case further
# progress was made.
if: always() # && steps.cache-restore.outputs.cache-hit != 'true'
with:
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
path: |
~/.avm
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.dylint_drivers/
~/.rustup/toolchains/
agave/
target/dylint/
all-checks:
needs: [test]
# smoelius: From "Defining prerequisite jobs"
# (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs):
# > If you would like a job to run even if a job it is dependent on did not succeed, use the
# > `always()` conditional expression in `jobs.<job_id>.if`.
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Check results
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1