Skip to content

Commit b90804f

Browse files
committed
Add CI
1 parent 3e86d18 commit b90804f

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed

.github/workflows/ci.yml

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