Skip to content

Commit ec7c6ae

Browse files
committed
Add CI
1 parent ea382fa commit ec7c6ae

File tree

2 files changed

+142
-0
lines changed

2 files changed

+142
-0
lines changed

.github/workflows/ci.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
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+
# smoelius: Not sure if this is necessary.
110+
# cp etc/rfc8032_test_vector.json ~/.config/solana/id.json
111+
112+
- name: Install CI tools
113+
run: |
114+
rustup +nightly component add clippy rustfmt
115+
cargo install cargo-dylint dylint-link || true
116+
cargo install cargo-hack || true
117+
cargo install cargo-udeps --locked || true
118+
cargo install group-runner || true
119+
120+
- name: Build
121+
run: cargo build
122+
123+
- name: Test
124+
run: |
125+
cargo test --config "$GROUP_RUNNER"
126+
127+
all-checks:
128+
needs: [test]
129+
130+
# smoelius: From "Defining prerequisite jobs"
131+
# (https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow#defining-prerequisite-jobs):
132+
# > If you would like a job to run even if a job it is dependent on did not succeed, use the
133+
# > `always()` conditional expression in `jobs.<job_id>.if`.
134+
if: ${{ always() }}
135+
136+
runs-on: ubuntu-latest
137+
138+
steps:
139+
- name: Check results
140+
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
141+
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)