@@ -41,9 +41,6 @@ function execute {
41
41
" scan" )
42
42
scanImages
43
43
;;
44
- " test" )
45
- runTests
46
- ;;
47
44
* )
48
45
printUsage
49
46
;;
@@ -190,144 +187,6 @@ function scanImage {
190
187
docker run --rm -v /tmp/trivy:/root/.cache/ aquasec/trivy " $tag "
191
188
}
192
189
193
- function runTests {
194
- log " Run tests…"
195
-
196
- pullImagesForTesting
197
- installNodePackages
198
- auditNodePackages
199
- lintMarkdownFiles
200
- lintYAMLFiles
201
- lintDockerfiles
202
- lintShellScripts
203
- testExecutableBits
204
- }
205
-
206
- function pullImagesForTesting {
207
- log " Pull Docker images…"
208
-
209
- pullImage hadolint/hadolint:latest
210
- pullImage koalaman/shellcheck:latest
211
- pullImage node:lts
212
- pullImage cytopia/yamllint:latest
213
- pullImage aquasec/trivy:latest
214
- }
215
-
216
- function installNodePackages {
217
- log " Install Node packages…"
218
-
219
- docker run --rm --name idoitdocker-npm \
220
- -v " $PWD " :/usr/src/app -w /usr/src/app node:lts \
221
- npm install || abort " No good"
222
- }
223
-
224
- function auditNodePackages {
225
- docker run --rm --name idoitdocker-npm \
226
- -v " $PWD " :/usr/src/app -w /usr/src/app node:lts \
227
- npm audit || abort " No good"
228
- }
229
-
230
- function lintMarkdownFiles {
231
- while read -r filePath; do
232
- lintMarkdownFile " $filePath "
233
- done < <(
234
- find " $( git rev-parse --show-toplevel) " \
235
- -type f -name " *.md" -not \
236
- -exec git check-ignore -q {} \; -printf ' %P\n'
237
- )
238
- }
239
-
240
- function lintMarkdownFile {
241
- local filePath=" $1 "
242
-
243
- log " Lint markdown file $filePath "
244
-
245
- docker run --rm --name idoitdocker-npm \
246
- -v " $PWD " :/usr/src/app -w /usr/src/app node:lts \
247
- ./node_modules/.bin/remark \
248
- --frail --quiet < " $filePath " > /dev/null || \
249
- abort " No good"
250
- }
251
-
252
- function lintYAMLFiles {
253
- while read -r filePath; do
254
- lintYAMLFile " $filePath "
255
- done < <(
256
- find " $( git rev-parse --show-toplevel) " \
257
- -type f -name " *.y*ml" -not \
258
- -exec git check-ignore -q {} \; -printf ' %P\n'
259
- )
260
- }
261
-
262
- function lintYAMLFile {
263
- local filePath=" $1 "
264
-
265
- log " Lint YAML file $filePath "
266
-
267
- docker run --rm --name idoitdocker-yamllint \
268
- -v " $PWD " :/data cytopia/yamllint:latest \
269
- " $filePath " || \
270
- abort " No good"
271
- }
272
-
273
- function lintDockerfiles {
274
- while read -r filePath; do
275
- lintDockerfile " $filePath "
276
- done < <(
277
- find " $( git rev-parse --show-toplevel) " \
278
- -type f -name " Dockerfile" -not \
279
- -exec git check-ignore -q {} \; -printf ' %P\n'
280
- )
281
- }
282
-
283
- function lintDockerfile {
284
- local dockerfile=" $1 "
285
-
286
- log " Lint $dockerfile "
287
-
288
- docker run --rm -i -v " $PWD :/opt/hadolint/" hadolint/hadolint:latest \
289
- hadolint --config /opt/hadolint/.hadolint.yaml - < \
290
- " $dockerfile " || \
291
- abort " No good"
292
- }
293
-
294
- function lintShellScripts {
295
- while read -r filePath; do
296
- lintShellScript " $filePath "
297
- done < <(
298
- git ls-files | grep -e ' .sh$'
299
- )
300
- }
301
-
302
- function lintShellScript {
303
- local filePath=" $1 "
304
-
305
- log " Lint shell script $filePath "
306
-
307
- docker run \
308
- -v " $( pwd) :/scripts" \
309
- koalaman/shellcheck:latest \
310
- " /scripts/$filePath " || \
311
- abort " No good"
312
- }
313
-
314
- function testExecutableBits {
315
- while read -r filePath; do
316
- testExecutableBit " $filePath "
317
- done < <(
318
- git ls-files | grep -e ' .sh$'
319
- )
320
- }
321
-
322
- function testExecutableBit {
323
- local filePath=" $1 "
324
-
325
- log " Check executable bit on shell script $filePath "
326
-
327
- test -x " $filePath " || \
328
- abort " Script is not executable"
329
- }
330
-
331
190
function fix {
332
191
fixFilePermissions
333
192
}
@@ -467,7 +326,7 @@ function cleanUp {
467
326
}
468
327
469
328
function printUsage {
470
- log " build|clean|fix|help|login|logout|print|pull|push|scan|test "
329
+ log " build|clean|fix|help|login|logout|print|pull|push|scan"
471
330
}
472
331
473
332
function setUp {
0 commit comments