Add CI test for clippy

This commit is contained in:
oxalica
2021-04-18 17:08:12 +08:00
parent 5f2b3994c2
commit 488576377f

View File

@@ -104,7 +104,7 @@ jobs:
id: cache-drv-status
uses: actions/cache@v2
with:
key: successful-drv-rust-${{ steps.instantiate.outputs.drv_path }}
key: drv-check-build-0-${{ steps.instantiate.outputs.drv_path }}
path: successful
- name: Build Rust
if: steps.cache-drv-status.outputs.cache-hit != 'true'
@@ -114,13 +114,19 @@ jobs:
- name: Prepare nix-shell
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: nix-shell -p "$build_expr" --pure --command "exit"
- name: Check compile
- name: Check `rustc` works
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: |
echo 'fn main() { println!("hello, world"); }' >./test.rs
# Use nix-shell to bring propagatedBuildInputs into scope.
nix-shell -p "$build_expr" --pure --command "rustc test.rs -o test"
[[ "$(./test)" == "hello, world" ]]
- name: Check `clippy` works
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: |
echo 'fn main() { loop { break; } }' >./test.rs
nix-shell -p "$build_expr" --pure --command 'clippy-driver test.rs -W clippy::never-loop' 2>&1 | tee msg
[[ ${PIPESTATUS[0]} -eq 0 && "$(cat msg)" == *"warning: this loop never actually loops"* ]]
- name: Mark a successful build for cache
if: steps.cache-drv-status.outputs.cache-hit != 'true'
run: echo "1" >./successful