Skip to content

Commit aa26ba0

Browse files
committed
Add CI
1 parent 0caa526 commit aa26ba0

File tree

2 files changed

+161
-0
lines changed

2 files changed

+161
-0
lines changed

.github/workflows/ci.yml

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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: Test with `macos-latest` once the repository is made public.
57+
environment: [ubuntu-latest]
58+
# smoelius: Test with Anchor 0.31.0 once the following issue is resolved:
59+
# https://github.com/solana-foundation/anchor/issues/3643
60+
anchor-version: [0.30.1]
61+
62+
runs-on: ${{ matrix.environment }}
63+
64+
defaults:
65+
run:
66+
shell: bash
67+
68+
env:
69+
GROUP_RUNNER: target.'cfg(all())'.runner = 'group-runner'
70+
71+
steps:
72+
- uses: actions/checkout@v4
73+
74+
- uses: actions/cache/restore@v4
75+
id: cache-restore
76+
with:
77+
path: |
78+
~/.avm
79+
~/.cargo/bin/
80+
~/.cargo/registry/index/
81+
~/.cargo/registry/cache/
82+
~/.cargo/git/db/
83+
~/.dylint_drivers/
84+
~/.rustup/toolchains/
85+
agave/
86+
target/dylint/
87+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
88+
89+
- name: Rustup
90+
run: rustup update
91+
92+
- name: Install Agave prerequisites
93+
run: sudo apt install libclang-dev libudev-dev llvm protobuf-compiler
94+
95+
- name: Install Agave
96+
run: |
97+
if ! ./agave/bin/agave-validator --version; then
98+
git clone https://github.com/anza-xyz/agave
99+
cd agave
100+
git checkout 86faa211d988143483adbe4c0cf16bb5e5798582
101+
sed -i '/^\[patch\.crates-io\]$/a solana-sbpf = { git = "https://github.com/trail-of-forks/sbpf-coverage" }' Cargo.toml
102+
./scripts/cargo-install-all.sh .
103+
cd ..
104+
fi
105+
echo "$PWD/agave/bin" >> "$GITHUB_PATH"
106+
107+
# smoelius: https://www.anchor-lang.com/docs/installation
108+
- name: Install Anchor
109+
run: |
110+
mkdir ~/.config/solana
111+
cp etc/rfc8032_test_vector.json ~/.config/solana/id.json
112+
if [[ "$(anchor --version)" != 'anchor-cli ${{ matrix.anchor-version }}' ]]; then
113+
cargo install --git https://github.com/coral-xyz/anchor --tag v${{ matrix.anchor-version }} anchor-cli --force
114+
fi
115+
116+
- name: Install CI tools
117+
run: |
118+
rustup +nightly component add clippy rustfmt
119+
cargo install cargo-dylint dylint-link || true
120+
cargo install cargo-hack || true
121+
cargo install cargo-udeps --locked || true
122+
cargo install group-runner || true
123+
124+
- name: Build
125+
run: cargo build
126+
127+
- name: Test
128+
run: |
129+
cargo test --config "$GROUP_RUNNER"
130+
131+
- uses: actions/cache/save@v4
132+
if: always() && steps.cache-restore.cache-hit != 'true'
133+
with:
134+
path: |
135+
~/.avm
136+
~/.cargo/bin/
137+
~/.cargo/registry/index/
138+
~/.cargo/registry/cache/
139+
~/.cargo/git/db/
140+
~/.dylint_drivers/
141+
~/.rustup/toolchains/
142+
agave/
143+
target/dylint/
144+
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
145+
146+
all-checks:
147+
needs: [test]
148+
149+
# smoelius: From "Defining prerequisite jobs"
150+
# (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs):
151+
# > If you would like a job to run even if a job it is dependent on did not succeed, use the
152+
# > `always()` conditional expression in `jobs.<job_id>.if`.
153+
if: ${{ always() }}
154+
155+
runs-on: ubuntu-latest
156+
157+
steps:
158+
- name: Check results
159+
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
160+
run: exit 1

etc/rfc8032_test_vector.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[157,97,177,157,239,253,90,96,186,132,74,244,146,236,44,196,68,73,197,105,123,50,105,25,112,59,172,3,28,174,127,96,215,90,152,1,130,177,10,183,213,75,254,211,201,100,7,58,14,225,114,243,218,166,35,37,175,2,26,104,247,7,81,26]

0 commit comments

Comments
 (0)