forked from FuelLabs/fuels-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
212 lines (189 loc) · 7.38 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
name: CI
on:
push:
branches:
- master
pull_request:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
DASEL_VERSION: https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64
RUSTFLAGS: "-D warnings"
RUST_VERSION: 1.61.0
FORC_VERSION: 0.15.1
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
setup-test-projects:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ env.RUST_VERSION }}
override: true
# 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@v1
- name: Set git config
run: |
git config --global core.bigfilethreshold 100m
- name: Install Forc
run: |
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
- name: Build Sway Examples
uses: actions-rs/cargo@v1
with:
command: run
args: --bin build-test-projects
- uses: actions/upload-artifact@v2
with:
retention-days: 2
name: sway-examples
# cache only the sway build artifacts, skip all test_project src files
path: |
packages/fuels-abigen-macro/tests/test_projects
!packages/fuels-abigen-macro/tests/test_projects/**/*.sw
!packages/fuels-abigen-macro/tests/test_projects/**/Forc.toml
!packages/fuels-abigen-macro/tests/test_projects/**/Forc.lock
!packages/fuels-abigen-macro/tests/test_projects/**/.gitignore
get-workspace-members:
needs: cancel-previous-runs
runs-on: ubuntu-latest
outputs:
members: ${{ steps.set-members.outputs.members }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- 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 -L 1 basename | jq -R '[.]' | jq -s -c 'add')
echo "::set-output name=members::$members"
verify-rust-version:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# 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 packages/fuels/Cargo.toml | dasel -r toml '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"
cargo-verifications:
needs:
- setup-test-projects
- verify-rust-version
- get-workspace-members
runs-on: ubuntu-latest
strategy:
matrix:
command: [check]
args: [--all-features]
package: ${{fromJSON(needs.get-workspace-members.outputs.members)}}
include:
- command: fmt
args: --all --verbose -- --check
- command: clippy
args: --all-targets --all-features
- command: test
args: --all-targets --all-features
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.RUST_VERSION }}
override: true
# 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@v1
continue-on-error: true
with:
key: "${{ matrix.command }} ${{ matrix.args }} ${{ matrix.package }}"
- name: Add WASM target
if: ${{ matrix.command == 'test' }}
run: rustup target add wasm32-unknown-unknown
- name: Install WebAssembly Test harness
if: ${{ matrix.command == 'test' }}
uses: actions-rs/cargo@v1
with:
command: install
args: webassembly-test-runner
- name: Test WASM package
if: ${{ matrix.command == 'test' }}
run: |
cd packages/wasm-tests
cargo test --target wasm32-unknown-unknown --all-targets --all-features
cargo test --target wasm32-unknown-unknown --all-targets --no-default-features
- name: Install rustfmt
if: ${{ matrix.command == 'fmt' }}
run: rustup component add rustfmt
- name: Install clippy
if: ${{ matrix.command == 'clippy' }}
run: rustup component add clippy
- name: Download sway example artifacts
if: ${{ matrix.command == 'test' || matrix.command == 'clippy' }}
uses: actions/download-artifact@v3
with:
name: sway-examples
path: packages/fuels-abigen-macro/tests/test_projects/
- name: Cargo (workspace-level)
if: ${{ !matrix.package }}
uses: actions-rs/cargo@v1
with:
command: ${{ matrix.command }}
args: ${{ matrix.args }}
- name: Cargo (package-level)
if: ${{ matrix.package }}
uses: actions-rs/cargo@v1
with:
command: ${{ matrix.command }}
args: ${{ matrix.args }}
publish:
needs: cargo-verifications
# 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@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- 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 }} packages/fuels-contract/Cargo.toml
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} packages/fuels-core/Cargo.toml
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} packages/fuels-abigen-macro/Cargo.toml
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} packages/fuels/Cargo.toml
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} packages/fuels-types/Cargo.toml
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} packages/fuels-test-helpers/Cargo.toml
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }} tools/fuels-abi-cli/Cargo.toml
- name: Publish crate
uses: katyo/publish-crates@v1
with:
publish-delay: 30000
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}