Skip to content

Commit 86595ca

Browse files
committed
feat: linting
Signed-off-by: Andrew Steurer <94206073+asteurer@users.noreply.github.com>
1 parent 0d6a753 commit 86595ca

File tree

28 files changed

+323
-238
lines changed

28 files changed

+323
-238
lines changed

.devcontainer/setup.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ echo "export PATH=$DOTNET_PATH:\$PATH" >> ~/.bashrc
2727
# Moonbit
2828
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
2929
echo 'export PATH="$HOME/.moon/bin:$PATH"' >> ~/.bashrc
30+
31+
# Go
32+
curl -OL https://go.dev/dl/go1.25.5.linux-amd64.tar.gz
33+
tar xf go1.25.5.linux-amd64.tar.gz
34+
echo "export PATH=$HOME/go1.25.5.linux-amd64/bin:\$PATH" >> ~/.bashrc
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: 'Install Rust toolchain'
2+
description: 'Install a rust toolchain'
3+
4+
inputs:
5+
toolchain:
6+
description: 'Default toolchan to install'
7+
required: false
8+
default: 'stable'
9+
10+
runs:
11+
using: composite
12+
steps:
13+
- name: Install Rust
14+
shell: bash
15+
id: select
16+
run: |
17+
# Determine MSRV as N in `1.N.0` by looking at the `rust-version`
18+
# located in the root `Cargo.toml`.
19+
msrv=$(grep 'rust-version.*1' Cargo.toml | sed 's/.*\.\([0-9]*\)\..*/\1/')
20+
21+
if [ "${{ inputs.toolchain }}" = "msrv" ]; then
22+
echo "version=1.$msrv.0" >> "$GITHUB_OUTPUT"
23+
else
24+
echo "version=${{ inputs.toolchain }}" >> "$GITHUB_OUTPUT"
25+
fi
26+
27+
- name: Install Rust
28+
shell: bash
29+
run: |
30+
rustup set profile minimal
31+
rustup update "${{ steps.select.outputs.version }}" --no-self-update
32+
rustup default "${{ steps.select.outputs.version }}"
33+
34+
# Save disk space by avoiding incremental compilation. Also turn down
35+
# debuginfo from 2 to 0 to help save disk space.
36+
cat >> "$GITHUB_ENV" <<EOF
37+
CARGO_INCREMENTAL=0
38+
CARGO_PROFILE_DEV_DEBUG=0
39+
CARGO_PROFILE_TEST_DEBUG=0
40+
EOF
41+
42+
# Deny warnings on CI to keep our code warning-free as it lands in-tree.
43+
echo RUSTFLAGS="-D warnings" >> "$GITHUB_ENV"
44+
45+
- run: rustup target add wasm32-wasip2
46+
if: inputs.toolchain != 'msrv'
47+
shell: bash
48+
49+
- run: |
50+
curl -L -o wasi-sdk.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-linux.tar.gz
51+
tar xf wasi-sdk.tar.gz
52+
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-27.0-x86_64-linux" >> $GITHUB_ENV
53+
if: runner.os == 'Linux'
54+
shell: bash
55+
working-directory: ${{ runner.tool_cache }}
56+
- run: |
57+
curl -L -o wasi-sdk.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-macos.tar.gz
58+
tar xf wasi-sdk.tar.gz
59+
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-27.0-x86_64-macos" >> $GITHUB_ENV
60+
if: runner.os == 'macOS'
61+
shell: bash
62+
working-directory: ${{ runner.tool_cache }}
63+
- run: |
64+
curl -L -o wasi-sdk.tar.gz https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-27/wasi-sdk-27.0-x86_64-windows.tar.gz
65+
tar xf wasi-sdk.tar.gz
66+
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-27.0-x86_64-windows" >> $GITHUB_ENV
67+
if: runner.os == 'Windows'
68+
shell: bash
69+
working-directory: ${{ runner.tool_cache }}
70+
- name: Setup `wasmtime`
71+
uses: bytecodealliance/actions/wasmtime/setup@v1
72+
with:
73+
version: "v40.0.0"

.github/workflows/main.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ jobs:
114114
# Run all runtime tests for this language, and also enable Rust in case this
115115
# language only implements either the runner or test component
116116
- run: |
117-
cargo run test --languages rust,${{ matrix.lang }} tests/runtime \
117+
cargo run test --languages ${{ matrix.lang }} tests/runtime \
118118
--artifacts target/artifacts \
119119
--rust-wit-bindgen-path ./crates/guest-rust
120120
@@ -262,3 +262,11 @@ jobs:
262262
- name: Report failure on cancellation
263263
if: ${{ contains(needs.*.result, 'cancelled') || cancelled() }}
264264
run: exit 1
265+
266+
clippy:
267+
runs-on: ubuntu-latest
268+
steps:
269+
- uses: actions/checkout@v6
270+
- uses: ./.github/actions/install-rust
271+
- run: rustup component add clippy
272+
- run: cargo clippy --workspace --all-targets

Cargo.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ description = """
1111
CLI tool to generate bindings for WIT documents and the component model.
1212
"""
1313

14+
[lints]
15+
workspace = true
16+
1417
[workspace]
1518
resolver = "2"
1619

@@ -52,6 +55,21 @@ wit-bindgen-go = { path = 'crates/go', version = '0.50.0' }
5255
wit-bindgen = { path = 'crates/guest-rust', version = '0.50.0', default-features = false }
5356
wit-bindgen-test = { path = 'crates/test', version = '0.50.0' }
5457

58+
[workspace.lints.clippy]
59+
# The default set of lints in Clippy is viewed as "too noisy" right now so
60+
# they're all turned off by default. Selective lints are then enabled below as
61+
# necessary.
62+
all = { level = 'allow', priority = -1 }
63+
clone_on_copy = 'warn'
64+
map_clone = 'warn'
65+
unnecessary_to_owned = 'warn'
66+
manual_strip = 'warn'
67+
uninlined_format_args = 'warn'
68+
unnecessary_mut_passed = 'warn'
69+
unnecessary_fallible_conversions = 'warn'
70+
unnecessary_cast = 'warn'
71+
allow_attributes_without_reason = 'warn'
72+
5573
[[bin]]
5674
name = "wit-bindgen"
5775

0 commit comments

Comments
 (0)