Skip to content

Commit 93b29a9

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 * Added support for 'cargo run' to run service in Viceroy (similar to 'fastly compute serve') * Updated Rust edition from 2018 to 2021 * Changed Rust 'release' profile to use LTO * Removed unnecessary parameters from scripts.build in fastly.toml * Removed an extraneous blank line from src/main.rs to make 'cargo clippy' happy Other changes: * Switched to using a reusable workflow for CI
1 parent 2ffbbda commit 93b29a9

File tree

6 files changed

+29
-60
lines changed

6 files changed

+29
-60
lines changed

.cargo/config.toml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
[build]
2-
target = "wasm32-wasi"
2+
target = "wasm32-wasip1"
3+
4+
[term]
5+
color = "always"
6+
7+
[target.wasm32-wasip1]
8+
runner = "fastly compute serve --file"

.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-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
name = "fastly-compute-project"
33
version = "0.1.0"
44
authors = []
5-
edition = "2018"
6-
# Remove this line if you want to be able to publish this crate as open source on crates.io.
5+
edition = "2021"
6+
# Remove this line if you want to be able to publish this crate on crates.io.
77
# Otherwise, `publish = false` prevents an accidental `cargo publish` from revealing private source.
88
publish = false
99

1010
[profile.release]
1111
debug = 1
12+
codegen-units = 1
13+
lto = "fat"
1214

1315
[dependencies]
1416
fastly = "0.11.0"

fastly.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# This file describes a Fastly Compute package. To learn more visit:
2-
# https://developer.fastly.com/reference/fastly-toml/
2+
# https://www.fastly.com/documentation/reference/compute/fastly-toml/
33

4-
authors = ["<oss@fastly.com>"]
5-
description = "A basic starter kit that demonstrates routing, simple synthetic responses and overriding caching rules."
4+
authors = ["<devrel@fastly.com>"]
5+
description = "Starter kit that demonstrates routing, simple synthetic responses and overriding caching rules."
66
language = "rust"
77
manifest_version = 3
88
name = "Default starter for Rust"
99

1010
[scripts]
11-
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"

src/main.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use fastly::{mime, Error, Request, Response};
1010
/// make completely new requests, and/or generate synthetic responses.
1111
///
1212
/// If `main` returns an error, a 500 error response will be delivered to the client.
13-
1413
#[fastly::main]
1514
fn main(req: Request) -> Result<Response, Error> {
1615
// Log service version

0 commit comments

Comments
 (0)