From 1d20c1222b24216c63bd71eee2d36f5ac4f09729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Bar=C4=87?= Date: Wed, 16 Sep 2020 14:57:41 +0200 Subject: [PATCH] ci: update --- .gitlab-ci.yml | 15 ++++++++++----- test.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100755 test.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b71865..7170408 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,13 @@ -services: - - docker:dind +image: debian:stable-slim -shellcheck: - image: docker:latest +stages: + - test + +before_script: + - apt-get update + - apt-get install -y bash shellcheck + +test: stage: test script: - - docker run --rm -v "$(pwd):/mnt" koalaman/shellcheck:stable src/* + - bash test.sh diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..2e33377 --- /dev/null +++ b/test.sh @@ -0,0 +1,31 @@ +#!/bin/sh + + +exit_result=0 +files="$(grep -R --exclude-dir='.git' '^#!/.*sh$' 2>/dev/null | cut -d ':' -f 1)" + + +for file in ${files} +do + echo "File ${file}... checking" + if shellcheck "${file}" + then + echo " file is correct" + else + echo " there were errors found in the file" + exit_result=1 + fi + echo "Done: ${file}" + echo +done + +if [ ${exit_result} = 0 ] +then + echo "No errors reported" + echo "Exiting successfully" + exit ${exit_result} +else + echo "Some errors reported" + echo "Exiting without success" + exit ${exit_result} +fi