Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,46 @@ jobs:
run: sh ./_test/check-exercise-crate.sh
continue-on-error: ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}

clippy:
name: Clippy
runs-on: ubuntu-latest

strategy:
matrix:
rust: ["stable", "beta"]

steps:
- name: Checkout master
uses: actions/checkout@v2
with:
ref: master

- name: Checkout code
uses: actions/checkout@v2

# We actually think explicitly installing Clippy isn't necessary,
# as it is currently installed by default.
# But we'll include this step anyway just in case that changes.
- name: Install Clippy
run: rustup component add clippy

- name: Setup toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
default: true

- name: Clippy tests
env:
CLIPPY: tests/
run: ./_test/check-exercises.sh

# Our examples currently have too much Clippy output to consider this.
# But maybe in the future.
#- name: Clippy examples
# env:
# CLIPPY: src/lib.rs
# run: ./_test/check-exercises.sh
nightly-compilation:
name: Check exercises on nightly (benchmark enabled)
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions _test/check-exercises.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ if [ ! -x "./bin/test-exercise" ]; then
exit 1
fi

# In DENYWARNINGS mode, do not set -e so that we run all tests.
# In DENYWARNINGS or CLIPPY mode, do not set -e so that we run all tests.
# This allows us to see all warnings.
if [ -z "$DENYWARNINGS" ]; then
# If we are in neither DENYWARNINGS nor CLIPPY mode, do set -e.
if [ -z "$DENYWARNINGS" ] && [ -z "$CLIPPY" ]; then
set -e
fi

Expand Down
17 changes: 15 additions & 2 deletions bin/test-exercise
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ done
# (use subshell so we auto-reset to current pwd after)
(
cd $exercise
# this is the last command; its exit code is what's passed on
time cargo $command "$@"
if [ -n "$CLIPPY" ]; then
cargo clippy --all-targets --color always "$@" 2>clippy.log
# Only consider it a failure if output contains the string in CLIPPY.
# For example, if we're only looking in tests, CLIPPY contains tests/
if grep -q $CLIPPY clippy.log; then
Comment on lines +87 to +89
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice! I have discovered that this has proven error-prone. I will be submitting a PR to correct that in a few hours.

cat clippy.log
exit 1
else
# Just to show progress
echo "clippy $exercise OK"
fi
else
# this is the last command; its exit code is what's passed on
time cargo $command "$@"
fi
)