-
Notifications
You must be signed in to change notification settings - Fork 143
280 lines (237 loc) · 8.36 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
275
276
277
278
279
280
name: CI
on:
push:
branches:
- master
pull_request:
release:
types: [published]
env:
CARGO_TERM_COLOR: always
RUST_VERSION_COV: nightly-2024-06-05
REGISTRY: ghcr.io
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
check-scripts:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run shellcheck and shfmt on all scripts
uses: luizm/action-sh-checker@master
env:
SHELLCHECK_OPTS: -e SC3043 # exclude 'local' is undefined
SHFMT_OPTS: -i 4 -ci
with:
sh_checker_comment: false
sh_checker_exclude: "src"
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@v3
- name: Install latest Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION_COV }}
- name: Install cargo-llvm-codecov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Code coverage report
run: cargo +${{ env.RUST_VERSION_COV }} 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
try-run-fuelup-init:
needs: cancel-previous-runs
if: github.event_name != 'release' || github.event.action != 'published'
name: Try fuelup installation with fuelup-init
strategy:
matrix:
job:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.job.os }}
steps:
- uses: actions/checkout@v3
- name: Attempt to install fuelup through fuelup-init.sh
run: ./fuelup-init.sh
cargo-clippy:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v1
- name: Check Clippy Linter
run: cargo clippy --locked --all-features --all-targets -- -D warnings
cargo-fmt-check:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- name: Check Formatting
run: cargo fmt --all -- --check
cargo-test-workspace:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run tests
run: cargo test --locked --workspace
lint-toml-files:
needs: cancel-previous-runs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install toolchain
uses: dtolnay/rust-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
publish-check:
# Only do this job if publishing a release
needs:
[cancel-previous-runs, cargo-clippy, cargo-fmt-check, lint-toml-files]
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- 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: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v1
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 fuelup 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: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.job.target }}
- 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 fuelup
run: |
cross build --profile=release --target ${{ matrix.job.target }} -p fuelup
- name: Strip release binary x86_64-linux-gnu
if: matrix.job.target == 'x86_64-unknown-linux-gnu'
run: strip "target/${{ matrix.job.target }}/release/fuelup"
- 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/fuelup
- name: Strip release binary mac
if: matrix.job.os == 'macos-latest'
run: strip -x "target/${{ matrix.job.target }}/release/fuelup"
- name: Prep assets
id: prep_assets
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
run: |
# Get tag name
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027
FUELUP_VERSION="${GITHUB_REF#refs/tags/}"
# trim v from tag prefix
FUELUP_VERSION="${FUELUP_VERSION#v}"
echo "version is: $FUELUP_VERSION"
# setup artifact filename
ARTIFACT="fuelup-$FUELUP_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/fuelup" "$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
post-release-checks:
name: Do post-release checks
needs: [cancel-previous-runs, build-release]
if: github.event_name == 'release' && github.event.action == 'published'
strategy:
matrix:
job:
- os: ubuntu-latest
- os: macos-latest
runs-on: ${{ matrix.job.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Try fuelup installation with fuelup-init
run: ./fuelup-init.sh