Skip to content

Commit

Permalink
ci: move custom lint from ci.yaml to lint.sh.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed May 19, 2023
1 parent 98c1f3d commit 791be4b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
23 changes: 1 addition & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,8 @@ jobs:
run: rustfmt --check tests/ui/**/*.rs
- name: Check docs are valid
run: RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps
- name: Clippy
- name: Clippy & custom lints
run: .github/workflows/lint.sh
# HACK(eddyb) see `docs/src/codegen-args.md` for more context around this,
# but basically we're implementing a custom "lint" to ban `std::env` usage,
# which could be disastrous because env vars access can't be tracked by
# `rustc`, unlike its CLI flags (which are integrated with incremental).
- name: Disallow `std::env` (mis)use from `rustc_codegen_spirv``
run: |
if (
egrep -r '::\s*env|env\s*::' crates/rustc_codegen_spirv/src/ |
# HACK(eddyb) exclude the one place in `rustc_codegen_spirv`
# needing access to an env var (only for codegen args `--help`).
egrep -v '^crates/rustc_codegen_spirv/src/codegen_cx/mod.rs: let help_flag_comes_from_spirv_builder_env_var = std::env::var\(spirv_builder_env_var\)$'
); then
echo '^^^'
echo '!!! Found disallowed `std::env` usage in `rustc_codegen_spirv` !!!'
echo ' ("codegen args" should be used instead of environment variables)'
echo
echo 'For more details on "codegen args", see: docs/src/codegen-args.md'
echo ' (and/or https://github.com/EmbarkStudios/rust-gpu/pull/959)'
echo
exit 1
fi

cargo-deny:
runs-on: ubuntu-20.04
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,27 @@ clippy examples/runners/wgpu
clippy_no_features examples/runners/cpu
clippy_no_features examples/shaders/sky-shader
clippy_no_features examples/shaders/simplest-shader

# Custom lints

# 1. Disallow `std::env` (mis)use from `rustc_codegen_spirv`

# HACK(eddyb) see `docs/src/codegen-args.md` for more context around this,
# but basically we're implementing a custom "lint" to ban `std::env` usage,
# which could be disastrous because env vars access can't be tracked by
# `rustc`, unlike its CLI flags (which are integrated with incremental).
if (
egrep -r '::\s*env|env\s*::' crates/rustc_codegen_spirv/src/ |
# HACK(eddyb) exclude the one place in `rustc_codegen_spirv`
# needing access to an env var (only for codegen args `--help`).
egrep -v '^crates/rustc_codegen_spirv/src/codegen_cx/mod.rs: let help_flag_comes_from_spirv_builder_env_var = std::env::var\(spirv_builder_env_var\)$'
); then
echo '^^^'
echo '!!! Found disallowed `std::env` usage in `rustc_codegen_spirv` !!!'
echo ' ("codegen args" should be used instead of environment variables)'
echo
echo 'For more details on "codegen args", see: docs/src/codegen-args.md'
echo ' (and/or https://github.com/EmbarkStudios/rust-gpu/pull/959)'
echo
exit 1
fi

0 comments on commit 791be4b

Please sign in to comment.