Skip to content

Commit a89fbab

Browse files
committed
ci: harden Rust CI/CD
- Add rust-toolchain.toml pinning to 1.91 - Standardize CI workflow (fmt + clippy -D warnings + test, Swatinem/rust-cache) - Align cargo-dist 0.31.0 config (where applicable) - Add tag-based crate publish workflow (where applicable) - Adopt dolos docker tag convention for services/backends (where applicable) - Add cliff.toml + cargo-release pre-release-hook
1 parent 6524b5d commit a89fbab

7 files changed

Lines changed: 118 additions & 94 deletions

File tree

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUSTFLAGS: -D warnings
12+
13+
jobs:
14+
fmt:
15+
name: cargo fmt
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: dtolnay/rust-toolchain@1.91
20+
with:
21+
components: rustfmt
22+
- run: cargo fmt --all -- --check
23+
24+
clippy:
25+
name: cargo clippy
26+
runs-on: ubuntu-latest
27+
env:
28+
SQLX_OFFLINE: true
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: dtolnay/rust-toolchain@1.91
32+
with:
33+
components: clippy
34+
- uses: Swatinem/rust-cache@v2
35+
- run: cargo clippy --all-targets --all-features -- -D warnings
36+
37+
test:
38+
name: cargo test
39+
runs-on: ${{ matrix.os }}
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
os: [ubuntu-latest, macos-latest, windows-latest]
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: dtolnay/rust-toolchain@1.91
47+
- uses: Swatinem/rust-cache@v2
48+
- run: cargo test --all-targets --all-features
49+
50+
integration:
51+
name: integration tests
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
- run: test/integration.sh

.github/workflows/clippy.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ jobs:
5656
env:
5757
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5858
steps:
59-
- uses: actions/checkout@v4
59+
- uses: actions/checkout@v6
6060
with:
6161
persist-credentials: false
6262
submodules: recursive
6363
- name: Install Rust
64-
run: rustup update "1.88.0" --no-self-update && rustup default "1.88.0"
64+
run: rustup update "1.91" --no-self-update && rustup default "1.91"
6565
- name: Install dist
6666
# we specify bash to get pipefail; it guards against the `curl` command
6767
# failing. otherwise `sh` won't catch that `curl` returned non-0
6868
shell: bash
69-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.30.3/cargo-dist-installer.sh | sh"
69+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.31.0/cargo-dist-installer.sh | sh"
7070
- name: Cache dist
71-
uses: actions/upload-artifact@v4
71+
uses: actions/upload-artifact@v6
7272
with:
7373
name: cargo-dist-cache
7474
path: ~/.cargo/bin/dist
@@ -84,7 +84,7 @@ jobs:
8484
cat plan-dist-manifest.json
8585
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
8686
- name: "Upload dist-manifest.json"
87-
uses: actions/upload-artifact@v4
87+
uses: actions/upload-artifact@v6
8888
with:
8989
name: artifacts-plan-dist-manifest
9090
path: plan-dist-manifest.json
@@ -118,7 +118,7 @@ jobs:
118118
- name: enable windows longpaths
119119
run: |
120120
git config --global core.longpaths true
121-
- uses: actions/checkout@v4
121+
- uses: actions/checkout@v6
122122
with:
123123
persist-credentials: false
124124
submodules: recursive
@@ -130,12 +130,12 @@ jobs:
130130
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
131131
fi
132132
- name: Use rustup to set correct Rust version
133-
run: rustup update "1.88.0" --no-self-update && rustup default "1.88.0"
133+
run: rustup update "1.91" --no-self-update && rustup default "1.91"
134134
- name: Install dist
135135
run: ${{ matrix.install_dist.run }}
136136
# Get the dist-manifest
137137
- name: Fetch local artifacts
138-
uses: actions/download-artifact@v4
138+
uses: actions/download-artifact@v7
139139
with:
140140
pattern: artifacts-*
141141
path: target/distrib/
@@ -162,7 +162,7 @@ jobs:
162162
163163
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
164164
- name: "Upload artifacts"
165-
uses: actions/upload-artifact@v4
165+
uses: actions/upload-artifact@v6
166166
with:
167167
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
168168
path: |
@@ -179,21 +179,21 @@ jobs:
179179
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
180180
BUILD_MANIFEST_NAME: target/distrib/global-dist-manifest.json
181181
steps:
182-
- uses: actions/checkout@v4
182+
- uses: actions/checkout@v6
183183
with:
184184
persist-credentials: false
185185
submodules: recursive
186186
- name: Install Rust
187-
run: rustup update "1.88.0" --no-self-update && rustup default "1.88.0"
187+
run: rustup update "1.91" --no-self-update && rustup default "1.91"
188188
- name: Install cached dist
189-
uses: actions/download-artifact@v4
189+
uses: actions/download-artifact@v7
190190
with:
191191
name: cargo-dist-cache
192192
path: ~/.cargo/bin/
193193
- run: chmod +x ~/.cargo/bin/dist
194194
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
195195
- name: Fetch local artifacts
196-
uses: actions/download-artifact@v4
196+
uses: actions/download-artifact@v7
197197
with:
198198
pattern: artifacts-*
199199
path: target/distrib/
@@ -211,7 +211,7 @@ jobs:
211211
212212
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
213213
- name: "Upload artifacts"
214-
uses: actions/upload-artifact@v4
214+
uses: actions/upload-artifact@v6
215215
with:
216216
name: artifacts-build-global
217217
path: |
@@ -231,21 +231,21 @@ jobs:
231231
outputs:
232232
val: ${{ steps.host.outputs.manifest }}
233233
steps:
234-
- uses: actions/checkout@v4
234+
- uses: actions/checkout@v6
235235
with:
236236
persist-credentials: false
237237
submodules: recursive
238238
- name: Install Rust
239-
run: rustup update "1.88.0" --no-self-update && rustup default "1.88.0"
239+
run: rustup update "1.91" --no-self-update && rustup default "1.91"
240240
- name: Install cached dist
241-
uses: actions/download-artifact@v4
241+
uses: actions/download-artifact@v7
242242
with:
243243
name: cargo-dist-cache
244244
path: ~/.cargo/bin/
245245
- run: chmod +x ~/.cargo/bin/dist
246246
# Fetch artifacts from scratch-storage
247247
- name: Fetch artifacts
248-
uses: actions/download-artifact@v4
248+
uses: actions/download-artifact@v7
249249
with:
250250
pattern: artifacts-*
251251
path: target/distrib/
@@ -258,14 +258,14 @@ jobs:
258258
cat dist-manifest.json
259259
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
260260
- name: "Upload dist-manifest.json"
261-
uses: actions/upload-artifact@v4
261+
uses: actions/upload-artifact@v6
262262
with:
263263
# Overwrite the previous copy
264264
name: artifacts-dist-manifest
265265
path: dist-manifest.json
266266
# Create a GitHub Release while uploading all files to it
267267
- name: "Download GitHub Artifacts"
268-
uses: actions/download-artifact@v4
268+
uses: actions/download-artifact@v7
269269
with:
270270
pattern: artifacts-*
271271
path: artifacts
@@ -298,14 +298,14 @@ jobs:
298298
GITHUB_EMAIL: "admin+bot@axo.dev"
299299
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
300300
steps:
301-
- uses: actions/checkout@v4
301+
- uses: actions/checkout@v6
302302
with:
303303
persist-credentials: true
304304
repository: "txpipe/homebrew-tap"
305305
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
306306
# So we have access to the formula
307307
- name: Fetch homebrew formulae
308-
uses: actions/download-artifact@v4
308+
uses: actions/download-artifact@v7
309309
with:
310310
pattern: artifacts-*
311311
path: Formula/
@@ -332,20 +332,49 @@ jobs:
332332
done
333333
git push
334334
335+
publish-npm:
336+
needs:
337+
- plan
338+
- host
339+
runs-on: "ubuntu-22.04"
340+
env:
341+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
342+
PLAN: ${{ needs.plan.outputs.val }}
343+
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
344+
steps:
345+
- name: Fetch npm packages
346+
uses: actions/download-artifact@v7
347+
with:
348+
pattern: artifacts-*
349+
path: npm/
350+
merge-multiple: true
351+
- uses: actions/setup-node@v6
352+
with:
353+
node-version: '20.x'
354+
registry-url: 'https://registry.npmjs.org'
355+
- run: |
356+
for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith("-npm-package.tar.gz")] | any)'); do
357+
pkg=$(echo "$release" | jq '.artifacts[] | select(endswith("-npm-package.tar.gz"))' --raw-output)
358+
npm publish --access public "./npm/${pkg}"
359+
done
360+
env:
361+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
362+
335363
announce:
336364
needs:
337365
- plan
338366
- host
339367
- publish-homebrew-formula
368+
- publish-npm
340369
# use "always() && ..." to allow us to wait for all publish jobs while
341370
# still allowing individual publish jobs to skip themselves (for prereleases).
342371
# "host" however must run to completion, no skipping allowed!
343-
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
372+
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.publish-npm.result == 'skipped' || needs.publish-npm.result == 'success') }}
344373
runs-on: "ubuntu-22.04"
345374
env:
346375
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
347376
steps:
348-
- uses: actions/checkout@v4
377+
- uses: actions/checkout@v6
349378
with:
350379
persist-credentials: false
351380
submodules: recursive

.github/workflows/test.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ lto = "thin"
6666
[workspace.metadata.release]
6767
push = false
6868
publish = false
69+
tag-name = "v{{version}}"
6970
pre-release-hook = [
7071
"git",
7172
"cliff",
7273
"-o",
7374
"CHANGELOG.md",
74-
"--tag",
75-
"{{version}}",
75+
"--latest",
7676
]

dist-workspace.toml

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,24 @@ members = ["cargo:."]
33

44
# Config for 'dist'
55
[dist]
6-
# The preferred dist version to use in CI (Cargo.toml SemVer syntax)
7-
cargo-dist-version = "0.30.3"
8-
# CI backends to support
6+
cargo-dist-version = "0.31.0"
97
ci = "github"
10-
# The installers to generate for each app
118
installers = ["shell", "powershell", "npm", "homebrew"]
12-
# A GitHub repo to push Homebrew formulas to
139
tap = "txpipe/homebrew-tap"
14-
# Target platforms to build apps for (Rust target-triple syntax)
1510
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
16-
# Publish jobs to run in CI
17-
publish-jobs = ["homebrew"]
18-
# Which actions to run on pull requests
11+
publish-jobs = ["homebrew", "npm"]
12+
publish-prereleases = true
1913
pr-run-mode = "plan"
20-
# Whether to install an updater program
2114
install-updater = false
22-
# The preferred Rust toolchain to use in CI (rustup toolchain syntax)
23-
rust-toolchain-version = "1.88.0"
24-
# The archive format to use for windows builds (defaults .zip)
15+
rust-toolchain-version = "1.91"
2516
windows-archive = ".tar.gz"
26-
# The archive format to use for non-windows builds (defaults .tar.xz)
2717
unix-archive = ".tar.gz"
28-
# A namespace to use when publishing this package to the npm registry
2918
npm-scope = "@txpipe"
30-
# Path that installers should place binaries in
3119
install-path = "CARGO_HOME"
3220

3321
[dist.github-custom-runners]
3422
global = "ubuntu-22.04"
3523
x86_64-unknown-linux-gnu = "ubuntu-22.04"
36-
aarch64-apple-darwin = "macos-14"
37-
x86_64-apple-darwin = "macos-13"
24+
aarch64-apple-darwin = "macos-15"
25+
x86_64-pc-windows-msvc = "windows-2022"
3826
aarch64-unknown-linux-gnu = "ubuntu-22.04-arm"

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "1.91"

0 commit comments

Comments
 (0)