Skip to content

Commit ff57afd

Browse files
authored
Update Rust edition to 2024 (#245)
1 parent 038e773 commit ff57afd

38 files changed

+837
-345
lines changed

.github/workflows/amd64.yml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v4
18+
- name: Update Rust
19+
run: rustup update
1820
- name: Build
1921
run: cargo build --all-features --verbose
2022
- name: Run tests

.github/workflows/coverage.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
sudo apt update && sudo apt install -y --no-install-recommends dotnet-sdk-8.0
3434
curl https://sh.rustup.rs -o rustup.sh && chmod +x rustup.sh && \
3535
./rustup.sh -y && rm rustup.sh
36-
rustup install nightly-2024-09-05
36+
rustup install nightly
3737
export PATH=/root/.cargo/bin:$PATH
3838
cargo install cargo-fuzz grcov
3939
- name: Build and Run Tests
@@ -44,9 +44,9 @@ jobs:
4444
LLVM_PROFILE_FILE: 'casr-%p-%m.profraw'
4545
run: |
4646
rustup component add llvm-tools-preview
47-
cargo +nightly-2024-09-05 build --all-features --verbose
48-
cargo +nightly-2024-09-05 test --verbose --lib -- --test-threads 1
49-
cargo +nightly-2024-09-05 test --verbose --package casr
47+
cargo +nightly build --all-features --verbose
48+
cargo +nightly test --verbose --lib -- --test-threads 1
49+
cargo +nightly test --verbose --package casr
5050
- name: Collect Coverage
5151
run: |
5252
mkdir target/coverage

.github/workflows/darwin-arm64.yml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
arch -x86_64 /usr/local/bin/brew update
2222
arch -x86_64 /usr/local/bin/brew install gdb curl python llvm \
2323
openjdk ca-certificates gnupg nodejs lua5.4 --overwrite
24+
- name: Update Rust
25+
run: rustup update
2426
- name: Build
2527
run: cargo build --all-features --verbose
2628
- name: NPM packages

.github/workflows/lint.yml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515

1616
steps:
1717
- uses: actions/checkout@v4
18+
- name: Update Rust
19+
run: rustup update
1820
- name: Code Style
1921
run: cargo fmt -- --check
2022
- name: Clippy

.github/workflows/release.yml

+108-72
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
# Copyright 2022-2023, axodotdev
1+
# This file was autogenerated by dist: https://opensource.axo.dev/cargo-dist/
2+
#
3+
# Copyright 2022-2024, axodotdev
24
# SPDX-License-Identifier: MIT or Apache-2.0
35
#
46
# CI that:
57
#
68
# * checks for a Git Tag that looks like a release
7-
# * builds artifacts with cargo-dist (archives, installers, hashes)
9+
# * builds artifacts with dist (archives, installers, hashes)
810
# * uploads those artifacts to temporary workflow zip
9-
# * on success, uploads the artifacts to a Github Release
11+
# * on success, uploads the artifacts to a GitHub Release
1012
#
11-
# Note that the Github Release will be created with a generated
13+
# Note that the GitHub Release will be created with a generated
1214
# title/body based on your changelogs.
13-
#
14-
# This file was generated by cargo dist init.
15-
# Some tips you could find here https://opensource.axo.dev/cargo-dist/book
1615

1716
name: Release
18-
1917
permissions:
20-
contents: write
18+
"contents": "write"
2119

2220
# This task will run whenever you push a git tag that looks like a version
2321
# like "1.0.0", "v0.1.0-prerelease.1", "my-app/0.1.0", "releases/v1.0.0", etc.
@@ -26,29 +24,30 @@ permissions:
2624
# must be a Cargo-style SemVer Version (must have at least major.minor.patch).
2725
#
2826
# If PACKAGE_NAME is specified, then the announcement will be for that
29-
# package (erroring out if it doesn't have the given version or isn't cargo-dist-able).
27+
# package (erroring out if it doesn't have the given version or isn't dist-able).
3028
#
3129
# If PACKAGE_NAME isn't specified, then the announcement will be for all
32-
# (cargo-dist-able) packages in the workspace with that version (this mode is
30+
# (dist-able) packages in the workspace with that version (this mode is
3331
# intended for workspaces with only one dist-able package, or with all dist-able
3432
# packages versioned/released in lockstep).
3533
#
3634
# If you push multiple tags at once, separate instances of this workflow will
37-
# spin up, creating an independent announcement for each one. However Github
35+
# spin up, creating an independent announcement for each one. However, GitHub
3836
# will hard limit this to 3 tags per commit, as it will assume more tags is a
3937
# mistake.
4038
#
4139
# If there's a prerelease-style suffix to the version, then the release(s)
4240
# will be marked as a prerelease.
4341
on:
42+
# pull_request:
4443
push:
4544
tags:
4645
- '**[0-9]+.[0-9]+.[0-9]+*'
4746

4847
jobs:
49-
# Run 'cargo dist plan' (or host) to determine what tasks we need to do
48+
# Run 'dist plan' (or host) to determine what tasks we need to do
5049
plan:
51-
runs-on: ubuntu-latest
50+
runs-on: "ubuntu-20.04"
5251
outputs:
5352
val: ${{ steps.plan.outputs.manifest }}
5453
tag: ${{ !github.event.pull_request && github.ref_name || '' }}
@@ -60,27 +59,34 @@ jobs:
6059
- uses: actions/checkout@v4
6160
with:
6261
submodules: recursive
63-
- name: Install cargo-dist
62+
- name: Update Rust
63+
run: rustup update
64+
- name: Install dist
6465
# we specify bash to get pipefail; it guards against the `curl` command
6566
# failing. otherwise `sh` won't catch that `curl` returned non-0
6667
shell: bash
67-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.0/cargo-dist-installer.sh | sh"
68+
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.28.0/cargo-dist-installer.sh | sh"
69+
- name: Cache dist
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: cargo-dist-cache
73+
path: ~/.cargo/bin/dist
6874
# sure would be cool if github gave us proper conditionals...
6975
# so here's a doubly-nested ternary-via-truthiness to try to provide the best possible
7076
# functionality based on whether this is a pull_request, and whether it's from a fork.
7177
# (PRs run on the *source* but secrets are usually on the *target* -- that's *good*
7278
# but also really annoying to build CI around when it needs secrets to work right.)
7379
- id: plan
7480
run: |
75-
cargo dist ${{ !github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name) || (github.event.pull_request.head.repo.fork && 'plan' || 'host --steps=check') }} --output-format=json > dist-manifest.json
76-
echo "cargo dist ran successfully"
77-
cat dist-manifest.json
78-
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
81+
dist ${{ (!github.event.pull_request && format('host --steps=create --tag={0}', github.ref_name)) || 'plan' }} --output-format=json > plan-dist-manifest.json
82+
echo "dist ran successfully"
83+
cat plan-dist-manifest.json
84+
echo "manifest=$(jq -c "." plan-dist-manifest.json)" >> "$GITHUB_OUTPUT"
7985
- name: "Upload dist-manifest.json"
80-
uses: actions/upload-artifact@v3
86+
uses: actions/upload-artifact@v4
8187
with:
82-
name: artifacts
83-
path: dist-manifest.json
88+
name: artifacts-plan-dist-manifest
89+
path: plan-dist-manifest.json
8490

8591
# Build and packages all the platform-specific things
8692
build-local-artifacts:
@@ -91,42 +97,55 @@ jobs:
9197
if: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix.include != null && (needs.plan.outputs.publishing == 'true' || fromJson(needs.plan.outputs.val).ci.github.pr_run_mode == 'upload') }}
9298
strategy:
9399
fail-fast: false
94-
# Target platforms/runners are computed by cargo-dist in create-release.
100+
# Target platforms/runners are computed by dist in create-release.
95101
# Each member of the matrix has the following arguments:
96102
#
97103
# - runner: the github runner
98-
# - dist-args: cli flags to pass to cargo dist
99-
# - install-dist: expression to run to install cargo-dist on the runner
104+
# - dist-args: cli flags to pass to dist
105+
# - install-dist: expression to run to install dist on the runner
100106
#
101107
# Typically there will be:
102108
# - 1 "global" task that builds universal installers
103109
# - N "local" tasks that build each platform's binaries and platform-specific installers
104110
matrix: ${{ fromJson(needs.plan.outputs.val).ci.github.artifacts_matrix }}
105111
runs-on: ${{ matrix.runner }}
112+
container: ${{ matrix.container && matrix.container.image || null }}
106113
env:
107114
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108115
BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json
109116
steps:
117+
- name: enable windows longpaths
118+
run: |
119+
git config --global core.longpaths true
110120
- uses: actions/checkout@v4
111121
with:
112122
submodules: recursive
113-
- uses: swatinem/rust-cache@v2
114-
- name: Install cargo-dist
115-
run: ${{ matrix.install_dist }}
123+
- name: Install Rust non-interactively if not already installed
124+
if: ${{ matrix.container }}
125+
run: |
126+
if ! command -v cargo > /dev/null 2>&1; then
127+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
128+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
129+
fi
130+
- name: Update Rust
131+
run: rustup update
132+
- name: Install dist
133+
run: ${{ matrix.install_dist.run }}
116134
# Get the dist-manifest
117135
- name: Fetch local artifacts
118-
uses: actions/download-artifact@v3
136+
uses: actions/download-artifact@v4
119137
with:
120-
name: artifacts
138+
pattern: artifacts-*
121139
path: target/distrib/
140+
merge-multiple: true
122141
- name: Install dependencies
123142
run: |
124143
${{ matrix.packages_install }}
125144
- name: Build artifacts
126145
run: |
127146
# Actually do builds and make zips and whatnot
128-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
129-
echo "cargo dist ran successfully"
147+
dist build ${{ needs.plan.outputs.tag-flag }} --print=linkage --output-format=json ${{ matrix.dist_args }} > dist-manifest.json
148+
echo "dist ran successfully"
130149
- id: cargo-dist
131150
name: Post-build
132151
# We force bash here just because github makes it really hard to get values up
@@ -136,14 +155,14 @@ jobs:
136155
run: |
137156
# Parse out what we just built and upload it to scratch storage
138157
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
139-
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
158+
dist print-upload-files-from-manifest --manifest dist-manifest.json >> "$GITHUB_OUTPUT"
140159
echo "EOF" >> "$GITHUB_OUTPUT"
141160
142161
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
143162
- name: "Upload artifacts"
144-
uses: actions/upload-artifact@v3
163+
uses: actions/upload-artifact@v4
145164
with:
146-
name: artifacts
165+
name: artifacts-build-local-${{ join(matrix.targets, '_') }}
147166
path: |
148167
${{ steps.cargo-dist.outputs.paths }}
149168
${{ env.BUILD_MANIFEST_NAME }}
@@ -161,30 +180,37 @@ jobs:
161180
- uses: actions/checkout@v4
162181
with:
163182
submodules: recursive
164-
- name: Install cargo-dist
165-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.0/cargo-dist-installer.sh | sh"
183+
- name: Update Rust
184+
run: rustup update
185+
- name: Install cached dist
186+
uses: actions/download-artifact@v4
187+
with:
188+
name: cargo-dist-cache
189+
path: ~/.cargo/bin/
190+
- run: chmod +x ~/.cargo/bin/dist
166191
# Get all the local artifacts for the global tasks to use (for e.g. checksums)
167192
- name: Fetch local artifacts
168-
uses: actions/download-artifact@v3
193+
uses: actions/download-artifact@v4
169194
with:
170-
name: artifacts
195+
pattern: artifacts-*
171196
path: target/distrib/
197+
merge-multiple: true
172198
- id: cargo-dist
173199
shell: bash
174200
run: |
175-
cargo dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
176-
echo "cargo dist ran successfully"
201+
dist build ${{ needs.plan.outputs.tag-flag }} --output-format=json "--artifacts=global" > dist-manifest.json
202+
echo "dist ran successfully"
177203
178204
# Parse out what we just built and upload it to scratch storage
179205
echo "paths<<EOF" >> "$GITHUB_OUTPUT"
180-
jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT"
206+
jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT"
181207
echo "EOF" >> "$GITHUB_OUTPUT"
182208
183209
cp dist-manifest.json "$BUILD_MANIFEST_NAME"
184210
- name: "Upload artifacts"
185-
uses: actions/upload-artifact@v3
211+
uses: actions/upload-artifact@v4
186212
with:
187-
name: artifacts
213+
name: artifacts-build-global
188214
path: |
189215
${{ steps.cargo-dist.outputs.paths }}
190216
${{ env.BUILD_MANIFEST_NAME }}
@@ -205,29 +231,57 @@ jobs:
205231
- uses: actions/checkout@v4
206232
with:
207233
submodules: recursive
208-
- name: Install cargo-dist
209-
run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.8.0/cargo-dist-installer.sh | sh"
234+
- name: Update Rust
235+
run: rustup update
236+
- name: Install cached dist
237+
uses: actions/download-artifact@v4
238+
with:
239+
name: cargo-dist-cache
240+
path: ~/.cargo/bin/
241+
- run: chmod +x ~/.cargo/bin/dist
210242
# Fetch artifacts from scratch-storage
211243
- name: Fetch artifacts
212-
uses: actions/download-artifact@v3
244+
uses: actions/download-artifact@v4
213245
with:
214-
name: artifacts
246+
pattern: artifacts-*
215247
path: target/distrib/
216-
# This is a harmless no-op for Github Releases, hosting for that happens in "announce"
248+
merge-multiple: true
217249
- id: host
218250
shell: bash
219251
run: |
220-
cargo dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
252+
dist host ${{ needs.plan.outputs.tag-flag }} --steps=upload --steps=release --output-format=json > dist-manifest.json
221253
echo "artifacts uploaded and released successfully"
222254
cat dist-manifest.json
223255
echo "manifest=$(jq -c "." dist-manifest.json)" >> "$GITHUB_OUTPUT"
224256
- name: "Upload dist-manifest.json"
225-
uses: actions/upload-artifact@v3
257+
uses: actions/upload-artifact@v4
226258
with:
227-
name: artifacts
259+
# Overwrite the previous copy
260+
name: artifacts-dist-manifest
228261
path: dist-manifest.json
262+
# Create a GitHub Release while uploading all files to it
263+
- name: "Download GitHub Artifacts"
264+
uses: actions/download-artifact@v4
265+
with:
266+
pattern: artifacts-*
267+
path: artifacts
268+
merge-multiple: true
269+
- name: Cleanup
270+
run: |
271+
# Remove the granular manifests
272+
rm -f artifacts/*-dist-manifest.json
273+
- name: Create GitHub Release
274+
env:
275+
PRERELEASE_FLAG: "${{ fromJson(steps.host.outputs.manifest).announcement_is_prerelease && '--prerelease' || '' }}"
276+
ANNOUNCEMENT_TITLE: "${{ fromJson(steps.host.outputs.manifest).announcement_title }}"
277+
ANNOUNCEMENT_BODY: "${{ fromJson(steps.host.outputs.manifest).announcement_github_body }}"
278+
RELEASE_COMMIT: "${{ github.sha }}"
279+
run: |
280+
# Write and read notes from a file to avoid quoting breaking things
281+
echo "$ANNOUNCEMENT_BODY" > $RUNNER_TEMP/notes.txt
282+
283+
gh release create "${{ needs.plan.outputs.tag }}" --target "$RELEASE_COMMIT" $PRERELEASE_FLAG --title "$ANNOUNCEMENT_TITLE" --notes-file "$RUNNER_TEMP/notes.txt" artifacts/casr-*
229284
230-
# Create a Github Release while uploading all files to it
231285
announce:
232286
needs:
233287
- plan
@@ -243,21 +297,3 @@ jobs:
243297
- uses: actions/checkout@v4
244298
with:
245299
submodules: recursive
246-
- name: "Download Github Artifacts"
247-
uses: actions/download-artifact@v3
248-
with:
249-
name: artifacts
250-
path: artifacts
251-
- name: Cleanup
252-
run: |
253-
# Remove the granular manifests
254-
rm -f artifacts/*-dist-manifest.json
255-
- name: Create Github Release
256-
uses: ncipollo/release-action@v1
257-
with:
258-
tag: ${{ needs.plan.outputs.tag }}
259-
name: ${{ fromJson(needs.host.outputs.val).announcement_title }}
260-
body: ${{ fromJson(needs.host.outputs.val).announcement_github_body }}
261-
prerelease: ${{ fromJson(needs.host.outputs.val).announcement_is_prerelease }}
262-
# Upload only binary release and checksum for it.
263-
artifacts: "artifacts/casr-x86_64-unknown-linux-gnu.tar.xz*"

.github/workflows/trivy.yml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
- name: Checkout code
1313
uses: actions/checkout@v4
1414

15+
- name: Update Rust
16+
run: rustup update
17+
1518
- name: Get Cargo.lock
1619
# According to this https://aquasecurity.github.io/trivy/v0.44/docs/scanner/vulnerability/language/rust/
1720
# Cargo.lock needs to be next to Cargo.toml (works for packages not for

0 commit comments

Comments
 (0)