|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + merge_group: |
| 5 | + pull_request: |
| 6 | + schedule: |
| 7 | + - cron: "0 3 * * tue" |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ci-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +env: |
| 15 | + CARGO_TERM_COLOR: always |
| 16 | + |
| 17 | +jobs: |
| 18 | + maybe-expedite: |
| 19 | + outputs: |
| 20 | + value: ${{ steps.expedite.outputs.value }} |
| 21 | + |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Log github refs |
| 26 | + run: | |
| 27 | + echo '```' >> "$GITHUB_STEP_SUMMARY" |
| 28 | + echo 'github.ref: ${{ github.ref }}' >> "$GITHUB_STEP_SUMMARY" |
| 29 | + echo 'github.sha: ${{ github.sha }}' >> "$GITHUB_STEP_SUMMARY" |
| 30 | + echo '```' >> "$GITHUB_STEP_SUMMARY" |
| 31 | +
|
| 32 | + - uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + fetch-depth: 0 |
| 35 | + |
| 36 | + - name: Check if merging an up-to-date branch |
| 37 | + if: ${{ github.event_name == 'merge_group' }} |
| 38 | + id: expedite |
| 39 | + run: | |
| 40 | + N="$(expr "${{ github.ref }}" : '.*-\([0-9]\+\)-[^-]*$')" |
| 41 | + BASE_SHA="$(gh api /repos/${{ github.repository }}/pulls/"$N" | jq -r '.base.sha')" |
| 42 | + if git diff --quiet ${{ github.event.merge_group.base_sha }} "$BASE_SHA"; then |
| 43 | + echo "value=1" >> "$GITHUB_OUTPUT" |
| 44 | + fi |
| 45 | + env: |
| 46 | + GH_TOKEN: ${{ github.token }} |
| 47 | + |
| 48 | + test: |
| 49 | + needs: [maybe-expedite] |
| 50 | + |
| 51 | + if: ${{ ! needs.maybe-expedite.outputs.value }} |
| 52 | + |
| 53 | + strategy: |
| 54 | + fail-fast: ${{ github.event_name == 'merge_group' }} |
| 55 | + matrix: |
| 56 | + # smoelius: Disable `macos-latest` for now. |
| 57 | + environment: [ubuntu-latest] # , macos-latest] |
| 58 | + anchor-version: [0.30.1, 0.31.0] |
| 59 | + |
| 60 | + runs-on: ${{ matrix.environment }} |
| 61 | + |
| 62 | + defaults: |
| 63 | + run: |
| 64 | + shell: bash |
| 65 | + |
| 66 | + env: |
| 67 | + GROUP_RUNNER: target.'cfg(all())'.runner = 'group-runner' |
| 68 | + |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - uses: actions/cache@v4 |
| 73 | + with: |
| 74 | + path: | |
| 75 | + ~/.avm |
| 76 | + ~/.cargo/bin/ |
| 77 | + ~/.cargo/registry/index/ |
| 78 | + ~/.cargo/registry/cache/ |
| 79 | + ~/.cargo/git/db/ |
| 80 | + ~/.dylint_drivers/ |
| 81 | + ~/.rustup/toolchains/ |
| 82 | + agave/ |
| 83 | + target/dylint/ |
| 84 | + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} |
| 85 | + |
| 86 | + - name: Rustup |
| 87 | + run: rustup update |
| 88 | + |
| 89 | + - name: Install Agave prerequisites |
| 90 | + run: sudo apt install libclang-dev libudev-dev llvm protobuf-compiler |
| 91 | + |
| 92 | + - name: Install Agave |
| 93 | + run: | |
| 94 | + if ! ./agave/bin/agave-validator --version; then |
| 95 | + git clone https://github.com/anza-xyz/agave |
| 96 | + cd agave |
| 97 | + git checkout 86faa211d988143483adbe4c0cf16bb5e5798582 |
| 98 | + sed -i '/^\[patch\.crates-io\]$/a solana-sbpf = { git = "https://github.com/trail-of-forks/sbpf-coverage" }' Cargo.toml |
| 99 | + ./scripts/cargo-install-all.sh . |
| 100 | + echo "$PWD/bin" >> "$GITHUB_PATH" |
| 101 | + fi |
| 102 | +
|
| 103 | + # smoelius: https://www.anchor-lang.com/docs/installation |
| 104 | + - name: Install Anchor |
| 105 | + run: | |
| 106 | + if [[ "$(anchor --version)" != 'anchor-cli ${{ matrix.anchor-version }}' ]]; then |
| 107 | + cargo install --git https://github.com/coral-xyz/anchor --tag v${{ matrix.anchor-version }} anchor-cli --force |
| 108 | + fi |
| 109 | +
|
| 110 | + - name: Install CI tools |
| 111 | + run: | |
| 112 | + rustup +nightly component add clippy rustfmt |
| 113 | + cargo install cargo-dylint dylint-link || true |
| 114 | + cargo install cargo-hack || true |
| 115 | + cargo install cargo-udeps --locked || true |
| 116 | + cargo install group-runner || true |
| 117 | +
|
| 118 | + - name: Build |
| 119 | + run: cargo build |
| 120 | + |
| 121 | + - name: Test |
| 122 | + run: | |
| 123 | + cargo test --config "$GROUP_RUNNER" |
| 124 | +
|
| 125 | + all-checks: |
| 126 | + needs: [test] |
| 127 | + |
| 128 | + # smoelius: From "Defining prerequisite jobs" |
| 129 | + # (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs): |
| 130 | + # > If you would like a job to run even if a job it is dependent on did not succeed, use the |
| 131 | + # > `always()` conditional expression in `jobs.<job_id>.if`. |
| 132 | + if: ${{ always() }} |
| 133 | + |
| 134 | + runs-on: ubuntu-latest |
| 135 | + |
| 136 | + steps: |
| 137 | + - name: Check results |
| 138 | + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} |
| 139 | + run: exit 1 |
0 commit comments