Skip to content

Commit d9699c1

Browse files
committed
2025 Rust starter kit upgrades
Starter kit content changes: * Changed 'wasm32-wasi' target to 'wasm32-wasip1' (requires Rust 1.78 or later and Fastly CLI 11.0 or later) * Changed rust-toolchain.toml to install 'stable' toolchain instead of '1.83.0' * Moved term.color=always from scripts.build in fastly.toml to .cargo/config.toml * Updated Rust edition from 2018 to 2021 * Changed Rust 'release' profile to use LTO * Removed unnecessary parameters from scripts.build in fastly.toml Other changes: * Switched to using a reusable workflow for CI
1 parent 4afa796 commit d9699c1

File tree

5 files changed

+29
-58
lines changed

5 files changed

+29
-58
lines changed

.cargo/config.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[build]
2-
target = "wasm32-wasi"
2+
target = "wasm32-wasip1"
3+
4+
[term]
5+
color = "always"

.github/workflows/test.yml

+11-50
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,14 @@
1-
on: pull_request
21
name: Test
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'Cargo.toml'
7+
- 'rust-toolchain.toml'
8+
- '.cargo/config.toml'
9+
- '.github/workflows/test.yml'
10+
- 'src/**'
11+
312
jobs:
413
test:
5-
strategy:
6-
matrix:
7-
rust-toolchain: [1.83.0]
8-
platform: [ubuntu-latest]
9-
runs-on: ${{ matrix.platform }}
10-
environment: test
11-
steps:
12-
- name: Checkout code
13-
uses: actions/checkout@v3
14-
- name: Install Rust
15-
uses: dtolnay/[email protected]
16-
- name: Add wasm32-wasi Rust target
17-
run: rustup target add wasm32-wasi --toolchain ${{ matrix.rust-toolchain }}
18-
- name: Cache cargo registry
19-
uses: actions/cache@v3
20-
with:
21-
path: ~/.cargo/registry
22-
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
23-
- name: Cache cargo index
24-
uses: actions/cache@v3
25-
with:
26-
path: ~/.cargo/git
27-
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
28-
- name: Cache cargo build
29-
uses: actions/cache@v3
30-
with:
31-
path: target
32-
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
33-
- name: Install fmt
34-
run: rustup component add rustfmt
35-
shell: bash
36-
- name: Install clippy
37-
run: rustup component add clippy
38-
shell: bash
39-
- name: Install audit
40-
run: cargo install cargo-audit
41-
shell: bash
42-
- name: Check binaries and format
43-
run: RUSTFLAGS="--deny warnings" cargo check --bins --target wasm32-wasi && cargo fmt -- --check
44-
shell: bash
45-
- name: clippy
46-
run: cargo clippy
47-
shell: bash
48-
- name: audit
49-
run: cargo audit
50-
shell: bash
51-
- name: build
52-
run: cargo build
53-
shell: bash
14+
uses: fastly/devex-reusable-workflows/.github/workflows/compute-starter-kit-rust-v1.yml@main

Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
[package]
22
name = "fastly-compute-project"
33
version = "0.1.0"
4+
authors = []
45
edition = "2021"
5-
# Remove this line if you want to be able to publish this crate as open source on crates.io.
6+
# Remove this line if you want to be able to publish this crate on crates.io.
67
# Otherwise, `publish = false` prevents an accidental `cargo publish` from revealing private source.
78
publish = false
89

910
[profile.release]
1011
debug = 1
12+
codegen-units = 1
13+
lto = "fat"
1114

1215
[dependencies]
1316
fastly = "0.11.0"

fastly.toml

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
authors = ["<[email protected]>"]
2-
description = "An empty starter kit project template."
1+
# This file describes a Fastly Compute package. To learn more visit:
2+
# https://www.fastly.com/documentation/reference/compute/fastly-toml/
3+
4+
name = "Empty starter for Rust"
5+
description = "Starter kit that provides an empty service."
6+
authors = ["<[email protected]>"]
37
language = "rust"
48
manifest_version = 3
5-
name = "Empty starter for Rust"
69

710
[scripts]
8-
build = "cargo build --bin fastly-compute-project --release --target wasm32-wasi --color always"
11+
build = "cargo build --profile release"

rust-toolchain.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[toolchain]
2-
channel = "1.83.0"
3-
targets = [ "wasm32-wasi" ]
2+
channel = "stable"
3+
targets = [ "wasm32-wasip1" ]
4+
profile = "default"

0 commit comments

Comments
 (0)