-
Notifications
You must be signed in to change notification settings - Fork 1.3k
274 lines (243 loc) · 9.75 KB
/
ci.yml
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
name: CI
on:
push:
branches:
- master
pull_request:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
DASEL_VERSION: https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64
RUSTFLAGS: "-D warnings"
FUEL_CORE_VERSION: 0.20.4
RUST_VERSION: 1.71.1
FORC_VERSION: 0.45.0
FORC_PATCH_BRANCH: ""
FORC_PATCH_REVISION: ""
jobs:
setup-test-projects:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
# selecting a toolchain either by action or manual `rustup` calls should happen
# before the cache plugin, as it uses the current rustc version as its cache key
- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v1-rust"
- name: Set git config
run: |
git config --global core.bigfilethreshold 100m
- name: Install forc and forc-fmt
run: |
if [[ -n $FORC_PATCH_BRANCH ]]; then
cargo install --locked forc forc-fmt --git https://github.com/FuelLabs/sway --branch $FORC_PATCH_BRANCH
elif [[ -n $FORC_PATCH_REVISION ]]; then
cargo install --locked forc forc-fmt --git https://github.com/FuelLabs/sway --rev $FORC_PATCH_REVISION
else
curl -sSLf https://github.com/FuelLabs/sway/releases/download/v${{ env.FORC_VERSION }}/forc-binaries-linux_amd64.tar.gz -L -o forc.tar.gz
tar -xvf forc.tar.gz
chmod +x forc-binaries/forc
mv forc-binaries/forc /usr/local/bin/forc
mv forc-binaries/forc-fmt /usr/local/bin/forc-fmt
fi
- name: Check format of Sway test projects
run: forc fmt --check
working-directory: packages/fuels
- name: Build Sway test projects
run: forc build --terse --error-on-warnings
working-directory: packages/fuels
- uses: actions/upload-artifact@v2
with:
retention-days: 2
name: sway-examples
# cache only the sway build artifacts, skip all src files
path: |
packages/fuels/tests
!packages/fuels/tests/*.rs
!packages/fuels/tests/**/*.rs
!packages/fuels/tests/**/*.sw
!packages/fuels/tests/**/Forc.toml
!packages/fuels/tests/**/Forc.lock
!packages/fuels/tests/.gitignore
# TODO: To be removed once https://github.com/FuelLabs/fuels-rs/issues/881 is unblocked.
- name: Build Sway test projects w type paths
run: forc build --terse --json-abi-with-callpaths
working-directory: packages/fuels
- uses: actions/upload-artifact@v2
with:
retention-days: 2
name: sway-examples-w-type-paths
# cache only the sway build artifacts, skip all src files
path: |
packages/fuels/tests
!packages/fuels/tests/*.rs
!packages/fuels/tests/**/*.rs
!packages/fuels/tests/**/*.sw
!packages/fuels/tests/**/Forc.toml
!packages/fuels/tests/**/Forc.lock
!packages/fuels/tests/.gitignore
get-workspace-members:
runs-on: ubuntu-latest
outputs:
members: ${{ steps.set-members.outputs.members }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- id: set-members
run: |
# install dasel
curl -sSLf "$DASEL_VERSION" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
members=$(cat Cargo.toml | dasel -r toml -w json 'workspace.members' | jq -r ".[]" | xargs -I '{}' dasel -f {}/Cargo.toml 'package.name' | jq -R '[.]' | jq -s -c 'add')
echo "members=$members" >> $GITHUB_OUTPUT
verify-rust-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Ensure CI is using the same minimum toolchain specified in fuels Cargo.toml
- run: |
curl -sSLf "$DASEL_VERSION" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
MIN_VERSION=$(cat Cargo.toml | dasel -r toml 'workspace.package.rust-version')
RUST_VERSION="${{ env.RUST_VERSION }}"
echo "Comparing minimum supported toolchain ($MIN_VERSION) with ci toolchain (RUST_VERSION)"
test "$MIN_VERSION" == "$RUST_VERSION"
# Ensure workspace is publishable
publish-crates-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Publish crate check
uses: katyo/publish-crates@v2
with:
dry-run: true
check-repo: false
ignore-unpublished-changes: true
cargo-verifications:
needs:
- setup-test-projects
- verify-rust-version
- get-workspace-members
- publish-crates-check
runs-on: ubuntu-latest
strategy:
matrix:
cargo_command: [check]
args: [--all-features]
package: ${{fromJSON(needs.get-workspace-members.outputs.members)}}
include:
- cargo_command: fmt
args: --all --verbose -- --check
- cargo_command: clippy
args: --all-targets
download_sway_artifacts: sway-examples
- cargo_command: clippy
args: --all-targets --features "default fuel-core-lib test-type-paths"
download_sway_artifacts: sway-examples-w-type-paths
- cargo_command: nextest
args: run --all-targets --features "default fuel-core-lib test-type-paths" --workspace
download_sway_artifacts: sway-examples-w-type-paths
install_fuel_core: true
- cargo_command: nextest
args: run --all-targets --workspace
download_sway_artifacts: sway-examples
install_fuel_core: true
- cargo_command: test
args: --doc --workspace
- command: test_wasm
args:
- command: check_doc_anchors_valid
args:
- command: check_doc_unresolved_links
args:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
components: clippy,rustfmt
# selecting a toolchain either by action or manual `rustup` calls should happen
# before the cache plugin, as it uses the current rustc version as its cache key
- uses: Swatinem/[email protected]
continue-on-error: true
with:
key: "${{ matrix.cargo_command }} ${{ matrix.args }} ${{ matrix.package }}"
- name: Install Fuel Core
if: ${{ matrix.install_fuel_core }}
run: |
curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ env.FUEL_CORE_VERSION }}/fuel-core-${{ env.FUEL_CORE_VERSION }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz
tar -xvf fuel-core.tar.gz
chmod +x fuel-core-${{ env.FUEL_CORE_VERSION }}-x86_64-unknown-linux-gnu/fuel-core
mv fuel-core-${{ env.FUEL_CORE_VERSION }}-x86_64-unknown-linux-gnu/fuel-core /usr/local/bin/fuel-core
- name: Download sway example artifacts
if: ${{ matrix.download_sway_artifacts }}
uses: actions/download-artifact@v3
with:
name: ${{ matrix.download_sway_artifacts }}
path: packages/fuels/tests/
- name: Install nextest
if: ${{ matrix.cargo_command == 'nextest' }}
uses: taiki-e/install-action@nextest
- name: Cargo (workspace-level)
if: ${{ matrix.cargo_command && !matrix.package }}
run: cargo ${{ matrix.cargo_command }} ${{ matrix.args }}
- name: Cargo (package-level)
if: ${{ matrix.cargo_command && matrix.package }}
run: cargo ${{ matrix.cargo_command }} -p ${{ matrix.package }} ${{ matrix.args }}
- name: Install NodeJS for WASM testing
if: ${{ matrix.command == 'test_wasm' }}
uses: actions/setup-node@v3
with:
node-version: 18
- name: Test WASM
if: ${{ matrix.command == 'test_wasm' }}
run: |
rustup target add wasm32-unknown-unknown
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
cd packages/wasm-tests
wasm-pack test --node
- name: Check for invalid documentation anchors
if: ${{ matrix.command == 'check_doc_anchors_valid' }}
run: cargo run --bin check-docs
- name: Check for unresolved documentation links
if: ${{ matrix.command == 'check_doc_unresolved_links' }}
run: |
! cargo doc --document-private-items |& grep -A 6 "warning: unresolved link to"
publish:
needs:
- cargo-verifications
- publish-crates-check
# Only do this job if publishing a release
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Verify tag version
run: |
curl -sSLf "$DASEL_VERSION" -L -o dasel && chmod +x dasel
mv ./dasel /usr/local/bin/dasel
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} Cargo.toml
- name: Publish crate
uses: katyo/publish-crates@v2
with:
publish-delay: 30000
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}