-
Notifications
You must be signed in to change notification settings - Fork 97
235 lines (197 loc) · 7.08 KB
/
Copy pathsolana.yml
File metadata and controls
235 lines (197 loc) · 7.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
name: Solana CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- dev
# Cancel in-progress runs on new commits to same PR/branch
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: ./solana
jobs:
# Linting runs on standard ubuntu runner (no need for tilt-kube-public)
lint:
name: Solana Lint
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v6
- name: Get rust toolchain version
id: toolchain
run: |
RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' rust-toolchain)"
echo "version=${RUST_VERSION}" >> $GITHUB_OUTPUT
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@0b1efabc08b657293548b77fb76cc02d26091c7e
with:
toolchain: ${{ steps.toolchain.outputs.version }}
components: "clippy,rustfmt"
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: "solana"
- name: Run `cargo fmt`
run: cargo fmt --check --all --manifest-path Cargo.toml
- name: Run `cargo check`
run: cargo check --workspace --tests --manifest-path Cargo.toml --features mainnet
- name: Run `cargo clippy`
run: cargo clippy --workspace --tests --manifest-path Cargo.toml --features mainnet -- -Dclippy::cast_possible_truncation
# SBF build and tests require Solana tools
# Note: This doesn't need tilt-kube-public - standard ubuntu runner works fine
solana-sbf:
name: Solana Cargo SBF
runs-on: ubuntu-latest
env:
RUSTFLAGS: -Dwarnings
steps:
- uses: actions/checkout@v6
- name: Get rust toolchain version
id: toolchain
run: |
RUST_VERSION="$(awk '/channel =/ { print substr($3, 2, length($3)-2) }' rust-toolchain)"
echo "version=${RUST_VERSION}" >> $GITHUB_OUTPUT
- name: Get solana version
id: solana
run: |
SOLANA_VERSION="$(awk '/solana-program =/ { print substr($3, 3, length($3)-3) }' Cargo.toml)"
echo "version=${SOLANA_VERSION}" >> $GITHUB_OUTPUT
- name: Restore cached SBF artifacts
id: cache-sbf
uses: actions/cache/restore@v5
with:
path: solana/target/deploy
key: solana-sbf-${{ steps.solana.outputs.version }}-${{ hashFiles('solana/Cargo.lock', 'solana/programs/**/*.rs', 'solana/modules/**/*.rs') }}
- name: Verify cache contains .so files
id: verify-cache
run: |
if [ -d "target/deploy" ] && ls target/deploy/*.so 1>/dev/null 2>&1; then
echo "Cache contains valid .so files"
ls -la target/deploy/*.so
echo "valid=true" >> $GITHUB_OUTPUT
else
echo "Cache is empty or missing .so files, will rebuild"
echo "valid=false" >> $GITHUB_OUTPUT
fi
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@55c7845fad90d0ae8b2e83715cb900e5e861e8cb
with:
toolchain: ${{ steps.toolchain.outputs.version }}
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: "solana"
- name: Cache solana tools
id: cache-solana
uses: actions/cache@v5
env:
cache-name: solana-tools
with:
path: |
~/.local/share/solana/install/
~/.cache/solana/
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ steps.solana.outputs.version }}
- name: Install solana tools
if: steps.cache-solana.outputs.cache-hit != 'true'
env:
SOLANA_VERSION: ${{ steps.solana.outputs.version }}
run: |
sh -c "$(curl -sSfL https://release.anza.xyz/v${SOLANA_VERSION}/install)"
~/.local/share/solana/install/active_release/bin/sdk/sbf/scripts/install.sh
- name: Build SBF programs
if: steps.verify-cache.outputs.valid != 'true'
env:
RUST_BACKTRACE: "1"
run: |
export BPF_OUT_DIR="$(pwd)/target/deploy"
export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
mkdir -p "${BPF_OUT_DIR}"
cargo build-sbf --features "mainnet"
- name: Save SBF artifacts to cache
if: steps.verify-cache.outputs.valid != 'true'
uses: actions/cache/save@v5
with:
path: solana/target/deploy
key: solana-sbf-${{ steps.solana.outputs.version }}-${{ hashFiles('solana/Cargo.lock', 'solana/programs/**/*.rs', 'solana/modules/**/*.rs') }}
- name: Run tests in parallel
env:
RUST_BACKTRACE: "1"
run: |
export BPF_OUT_DIR="$(pwd)/target/deploy"
export PATH="${HOME}/.local/share/solana/install/active_release/bin:${PATH}"
# Run test-sbf for both packages in parallel, plus native tests
cargo test-sbf -p "example-native-token-transfers" --features "mainnet" &
pid1=$!
cargo test-sbf -p "ntt-transceiver" --features "mainnet,testing" &
pid2=$!
cargo test --features "mainnet" &
pid3=$!
# Wait for all and capture exit codes
wait $pid1 || exit 1
wait $pid2 || exit 1
wait $pid3 || exit 1
check-version:
name: Check version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: ./scripts/sync-versions --check
shell: bash
anchor-test:
name: Anchor Test
runs-on: ubuntu-latest
env:
node-version: "24"
solana-cli-version: "1.18.26"
anchor-version: "0.29.0"
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup-anchor
with:
anchor-version: ${{ env.anchor-version }}
solana-cli-version: ${{ env.solana-cli-version }}
node-version: ${{ env.node-version }}
- name: Cache node_modules
uses: actions/cache@v5
with:
path: ./solana/node_modules/
key: node-modules-${{ runner.os }}-build-${{ env.node-version }}
- name: Install node_modules
run: make node_modules
shell: bash
- name: Create keypair
run: solana-keygen new --no-bip39-passphrase
shell: bash
- name: Make Anchor.toml compatible with runner
run: sed -i 's:/user/:/runner/:' Anchor.toml
shell: bash
- name: Install Cargo toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
components: rustc
- name: Cache Cargo dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: "solana"
- name: Setup SDK
run: make sdk
shell: bash
- name: Check idl
run: |
git diff --exit-code ts/idl
- name: Set default Rust toolchain
run: rustup default stable
shell: bash
- name: Run anchor lint
run: make anchor-lint
shell: bash
- name: Run tests
run: anchor test --skip-build
shell: bash