File tree Expand file tree Collapse file tree 3 files changed +58
-4
lines changed Expand file tree Collapse file tree 3 files changed +58
-4
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,46 @@ jobs:
121
121
run : sh ./_test/check-exercise-crate.sh
122
122
continue-on-error : ${{ matrix.rust == 'beta' && matrix.deny_warnings == '1' }}
123
123
124
+ clippy :
125
+ name : Clippy
126
+ runs-on : ubuntu-latest
127
+
128
+ strategy :
129
+ matrix :
130
+ rust : ["stable", "beta"]
131
+
132
+ steps :
133
+ - name : Checkout master
134
+ uses : actions/checkout@v2
135
+ with :
136
+ ref : master
137
+
138
+ - name : Checkout code
139
+ uses : actions/checkout@v2
140
+
141
+ # We actually think explicitly installing Clippy isn't necessary,
142
+ # as it is currently installed by default.
143
+ # But we'll include this step anyway just in case that changes.
144
+ - name : Install Clippy
145
+ run : rustup component add clippy
146
+
147
+ - name : Setup toolchain
148
+ uses : actions-rs/toolchain@v1
149
+ with :
150
+ toolchain : ${{ matrix.rust }}
151
+ default : true
152
+
153
+ - name : Clippy tests
154
+ env :
155
+ CLIPPY : tests/
156
+ run : ./_test/check-exercises.sh
157
+
158
+ # Our examples currently have too much Clippy output to consider this.
159
+ # But maybe in the future.
160
+ # - name: Clippy examples
161
+ # env:
162
+ # CLIPPY: src/lib.rs
163
+ # run: ./_test/check-exercises.sh
124
164
nightly-compilation :
125
165
name : Check exercises on nightly (benchmark enabled)
126
166
runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -11,9 +11,10 @@ if [ ! -x "./bin/test-exercise" ]; then
11
11
exit 1
12
12
fi
13
13
14
- # In DENYWARNINGS mode, do not set -e so that we run all tests.
14
+ # In DENYWARNINGS or CLIPPY mode, do not set -e so that we run all tests.
15
15
# This allows us to see all warnings.
16
- if [ -z " $DENYWARNINGS " ]; then
16
+ # If we are in neither DENYWARNINGS nor CLIPPY mode, do set -e.
17
+ if [ -z " $DENYWARNINGS " ] && [ -z " $CLIPPY " ]; then
17
18
set -e
18
19
fi
19
20
Original file line number Diff line number Diff line change 82
82
# (use subshell so we auto-reset to current pwd after)
83
83
(
84
84
cd $exercise
85
- # this is the last command; its exit code is what's passed on
86
- time cargo $command " $@ "
85
+ if [ -n " $CLIPPY " ]; then
86
+ cargo clippy --all-targets --color always " $@ " 2> clippy.log
87
+ # Only consider it a failure if output contains the string in CLIPPY.
88
+ # For example, if we're only looking in tests, CLIPPY contains tests/
89
+ if grep -q $CLIPPY clippy.log; then
90
+ cat clippy.log
91
+ exit 1
92
+ else
93
+ # Just to show progress
94
+ echo " clippy $exercise OK"
95
+ fi
96
+ else
97
+ # this is the last command; its exit code is what's passed on
98
+ time cargo $command " $@ "
99
+ fi
87
100
)
You can’t perform that action at this time.
0 commit comments