-
Notifications
You must be signed in to change notification settings - Fork 100
314 lines (295 loc) · 10.1 KB
/
rust.yml
File metadata and controls
314 lines (295 loc) · 10.1 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: Rust
on:
push:
branches: [main, release/**]
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_protected == 'true' && github.sha || github.ref }}-{{ github.event_name }}
cancel-in-progress: true
env:
ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS: 7
SOROBAN_SDK_BUILD_SYSTEM_SUPPORTS_SPEC_SHAKING_V2: 1
defaults:
run:
shell: bash
jobs:
complete:
if: always()
needs: [fmt, check-git-rev-deps, semver-checks, build, test, expand-test-wasms, build-fuzz, docs, readme, migration-docs]
runs-on: ubuntu-slim
steps:
- if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
setup:
runs-on: ubuntu-latest
outputs:
sys: ${{ steps.sys.outputs.sys }}
steps:
- id: sys
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
sys='[
{
"os": "ubuntu-latest",
"target": "x86_64-unknown-linux-gnu"
}
]'
else
sys='[
{
"os": "ubuntu-latest",
"target": "x86_64-unknown-linux-gnu"
},
{
"os": "ubuntu-24.04-arm",
"target": "aarch64-unknown-linux-gnu"
},
{
"os": "macos-15-intel",
"target": "x86_64-apple-darwin"
},
{
"os": "macos-latest",
"target": "aarch64-apple-darwin"
},
{
"os": "windows-latest",
"target": "x86_64-pc-windows-msvc"
}
]'
fi
echo "sys=$(<<< $sys jq -c)" >> $GITHUB_OUTPUT
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update
- run: cargo fmt --all --check
cargo-deny:
runs-on: ubuntu-latest
strategy:
matrix:
checks:
- advisories
- bans licenses sources
# Prevent sudden announcement of a new advisory from failing ci:
continue-on-error: ${{ matrix.checks == 'advisories' }}
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@3fd3802e88374d3fe9159b834c7714ec57d6c979
with:
command: check ${{ matrix.checks }}
check-git-rev-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-check-git-rev-deps@main
semver-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: rustup update stable
- name: Determine Rust n-2 version since cargo-semver-checks is rarely available for the latest version
id: rust-version
run: |
current_version=$(rustc +stable --version | grep -oE '[0-9]+\.[0-9]+' | head -1)
major=$(echo $current_version | cut -d. -f1)
minor=$(echo $current_version | cut -d. -f2)
prev_minor=$((minor - 2))
prev_version="${major}.${prev_minor}"
echo "Latest stable: $current_version, using n-2: $prev_version"
echo "version=$prev_version" >> $GITHUB_OUTPUT
- name: Install Rust ${{ steps.rust-version.outputs.version }}
run: |
rustup install ${{ steps.rust-version.outputs.version }}
rustup override set ${{ steps.rust-version.outputs.version }}
- name: Verify Rust version
run: |
rustc --version
cargo --version
- uses: stellar/binaries@v51
with:
name: cargo-semver-checks
version: 0.45.0
- run: >
cargo semver-checks
--exclude soroban-meta
--exclude soroban-token-spec
--exclude stellar-asset-spec
build:
needs: setup
strategy:
fail-fast: false
matrix:
rust: [msrv, latest]
sys: ${{ fromJSON(needs.setup.outputs.sys) }}
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v3
- name: Install minimum supported rust version
if: matrix.rust == 'msrv'
run: |
msrv="$(make msrv)"
rustup install $msrv
rustup component add --toolchain $msrv clippy rustfmt
rustup target add --toolchain $msrv ${{ matrix.sys.target }}
rustup target add --toolchain $msrv wasm32v1-none
- name: Install latest rust version
if: matrix.rust == 'latest'
run: |
rustup update
rustup target add ${{ matrix.sys.target }}
rustup target add wasm32v1-none
- name: Use the minimum supported rust version
if: matrix.rust == 'msrv'
run: echo RUSTUP_TOOLCHAIN="$(make msrv)" >> $GITHUB_ENV
- name: Set latest toolchain
if: matrix.rust == 'latest'
run: echo RUSTUP_TOOLCHAIN="$(rustup show active-toolchain | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: stellar/actions/rust-cache@main
- name: Error on warnings only for msrv
if: matrix.rust == 'msrv'
run: echo RUSTFLAGS='-Dwarnings' >> $GITHUB_ENV
- run: echo CARGO_BUILD_TARGET='${{ matrix.sys.target }}' >> $GITHUB_ENV
- uses: stellar/binaries@v45
with:
name: cargo-hack
version: 0.5.28
- run: cargo version
- run: make build-libs
- run: make build-test-wasms TEST_CRATES_RUSTUP_TOOLCHAIN=$RUSTUP_TOOLCHAIN
- name: Upload test wasms
uses: actions/upload-artifact@v4
with:
name: test-wasms-${{ matrix.rust }}-${{ matrix.sys.target }}
path: target/wasm32v1-none/release/test_*.wasm
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS_FOR_TEST_WASMS }}
test:
needs: [setup, build]
strategy:
fail-fast: false
matrix:
rust: [msrv, latest]
sys: ${{ fromJSON(needs.setup.outputs.sys) }}
runs-on: ${{ matrix.sys.os }}
steps:
- uses: actions/checkout@v3
- name: Install minimum supported rust version
if: matrix.rust == 'msrv'
run: |
msrv="$(make msrv)"
rustup install $msrv
rustup component add --toolchain $msrv clippy rustfmt
rustup target add --toolchain $msrv ${{ matrix.sys.target }}
rustup target add --toolchain $msrv wasm32v1-none
- name: Install latest rust version
if: matrix.rust == 'latest'
run: |
rustup update
rustup target add ${{ matrix.sys.target }}
rustup target add wasm32v1-none
- name: Use the minimum supported rust version
if: matrix.rust == 'msrv'
run: echo RUSTUP_TOOLCHAIN="$(make msrv)" >> $GITHUB_ENV
- name: Set latest toolchain
if: matrix.rust == 'latest'
run: echo RUSTUP_TOOLCHAIN="$(rustup show active-toolchain | cut -d' ' -f1)" >> $GITHUB_ENV
- uses: stellar/actions/rust-cache@main
- name: Error on warnings only for msrv
if: matrix.rust == 'msrv'
run: echo RUSTFLAGS='-Dwarnings' >> $GITHUB_ENV
- run: echo CARGO_BUILD_TARGET='${{ matrix.sys.target }}' >> $GITHUB_ENV
- uses: stellar/binaries@v45
with:
name: cargo-hack
version: 0.5.28
- name: Restore test wasms for tests from one of the msrv builds
uses: actions/download-artifact@v5
with:
name: test-wasms-msrv-x86_64-unknown-linux-gnu
path: target/wasm32v1-none/release/
- name: Clear test snapshots for checking no diffs exists after test run
run: rm -fr **/test_snapshots
- run: cargo version
- run: make test-only
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
build-fuzz:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- uses: stellar/binaries@v45
with:
name: cargo-fuzz
version: 0.13.1
- run: make build-fuzz
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- run: make doc
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
readme:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup install nightly
- run: make readme
- run: git add -N . && git diff HEAD --exit-code
migration-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: stellar/actions/rust-cache@main
- run: rustup update
- run: |
version="$(cargo metadata --format-version 1 --no-deps | jq -r '.packages[] | select(.name == "soroban-sdk") | .version | split("\\.";"")[0] | "v"+.')"
git grep "${version}" -- soroban-sdk/src/_migrating.rs \
|| (echo "The _migrating ${version} section is missing." && exit 1)
expand-test-wasms:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: stellar/actions/rust-cache@main
- name: Install minimum supported rust version
run: |
msrv="$(make msrv)"
rustup install $msrv
rustup target add --toolchain $msrv wasm32v1-none
rustup component add rustfmt
- uses: stellar/binaries@v45
with:
name: cargo-hack
version: 0.5.28
- uses: stellar/binaries@v45
with:
name: cargo-expand
version: 1.0.116
- run: make expand-tests
- name: Check no diffs exist
run: git add -N . && git diff HEAD --exit-code
publish-dry-run:
if: github.event_name == 'push' || startsWith(github.head_ref, 'release/')
strategy:
matrix:
sys:
- os: ubuntu-latest
target: wasm32v1-none
cargo-hack-feature-options: --manifest-path Cargo.toml --exclude soroban-meta --exclude soroban-spec --exclude soroban-spec-rust --exclude soroban-ledger-snapshot --exclude-features testutils,docs,default,std,experimental_spec_shaking_v2 --feature-powerset
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cargo-hack-feature-options: '--feature-powerset --exclude-features docs'
uses: stellar/actions/.github/workflows/rust-publish-dry-run.yml@main
with:
runs-on: ${{ matrix.sys.os }}
target: ${{ matrix.sys.target }}
cargo-hack-feature-options: ${{ matrix.sys.cargo-hack-feature-options }}