Skip to content

Commit

Permalink
Merge pull request #1884 from fermyon/more-linting
Browse files Browse the repository at this point in the history
Run lints on Rust test cases
  • Loading branch information
rylev authored Oct 13, 2023
2 parents adc32ed + 6bdd0f8 commit 666f1c3
Show file tree
Hide file tree
Showing 11 changed files with 243 additions and 114 deletions.
29 changes: 5 additions & 24 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,18 @@ jobs:
rust-wasm: true
rust-cache: true

- name: Cargo Format
- name: Run lints
run:
BUILD_SPIN_EXAMPLES=0 cargo fmt --all -- --check
BUILD_SPIN_EXAMPLES=0 make lint

- name: Cargo Clippy
run:
BUILD_SPIN_EXAMPLES=0 cargo clippy --workspace --all-targets --features all-tests -- -D warnings
- name: Cancel everything if linting fails
if: failure()
uses: andymckay/[email protected]

## This is separated out to remove e2e-tests dependency on windows/mac builds
build-rust-ubuntu:
name: Build Spin Ubuntu
runs-on: ubuntu-latest
needs: [lint-rust]
steps:
- uses: actions/checkout@v3

Expand All @@ -72,7 +71,6 @@ jobs:
build-rust:
name: Build Spin
runs-on: ${{ matrix.os }}
needs: [lint-rust]
strategy:
matrix:
os: [windows-latest, macos-latest]
Expand Down Expand Up @@ -101,7 +99,6 @@ jobs:
test-rust:
name: Test Spin SDK - Rust
runs-on: ${{ matrix.runner }}
needs: [lint-rust]
strategy:
matrix:
runner: [ubuntu-22.04-4core-spin, macos-latest]
Expand Down Expand Up @@ -176,19 +173,3 @@ jobs:
chmod +x `pwd`/target/release/spin
export E2E_VOLUME_MOUNT="-v `pwd`/target/release/spin:/usr/local/bin/spin"
make run-test-spin-up
lint-examples:
name: Lint Examples
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3

- name: Set up dependencies
uses: ./.github/actions/spin-ci-dependencies
with:
rust: true
rust-wasm: true
rust-cache: true

- name: Lint examples
run: make check-rust-examples
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ install:
test: lint test-unit test-integration

.PHONY: lint
lint:
cargo clippy --all-targets --all-features -- -D warnings
lint: lint-rust-examples-and-testcases
cargo clippy --all --all-targets --features all-tests -- -D warnings
cargo fmt --all -- --check

.PHONY: check-rust-examples
check-rust-examples:
for manifest_path in examples/*/Cargo.toml; do \
.PHONY: lint-rust-examples-and-testcases
lint-rust-examples-and-testcases:
for manifest_path in $$(find examples tests/testcases -name Cargo.toml); do \
cargo clippy --manifest-path "$${manifest_path}" -- -D warnings \
&& cargo fmt --manifest-path "$${manifest_path}" -- --check \
|| exit 1 ; \
Expand Down
Loading

0 comments on commit 666f1c3

Please sign in to comment.