From 7e3268a9c87486ac916fd0ba464f77bb5cdec675 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Sat, 4 Sep 2021 18:13:31 -0700 Subject: [PATCH] ci: add staticcheck to linting See #6 --- .gitlab-ci.yml | 6 ++++-- .gitlab-ci/check_gofmt.sh | 11 ----------- .gitlab-ci/check_linting.sh | 13 +++++++++++++ 3 files changed, 17 insertions(+), 13 deletions(-) delete mode 100755 .gitlab-ci/check_gofmt.sh create mode 100755 .gitlab-ci/check_linting.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8ca1216..c42b69a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,9 +27,11 @@ gofmt linting: allow_failure: true <<: *only-default before_script: - - apk -q add go + # specific mirror used because staticcheck hasn't made it to the other mirrors yet... + - apk -q update --repository http://dl-4.alpinelinux.org/alpine/edge/testing + - apk -q add --repository http://dl-4.alpinelinux.org/alpine/edge/testing go staticcheck script: - - .gitlab-ci/check_gofmt.sh + - .gitlab-ci/check_linting.sh build: stage: build diff --git a/.gitlab-ci/check_gofmt.sh b/.gitlab-ci/check_gofmt.sh deleted file mode 100755 index dd24d7d..0000000 --- a/.gitlab-ci/check_gofmt.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -files="$(gofmt -l .)" - -[ -z "$files" ] && exit 0 - -# run gofmt to print out the diff of what needs to be changed - -gofmt -d -e . - -exit 1 diff --git a/.gitlab-ci/check_linting.sh b/.gitlab-ci/check_linting.sh new file mode 100755 index 0000000..311d52b --- /dev/null +++ b/.gitlab-ci/check_linting.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +echo "### Running gofmt..." +files="$(gofmt -l .)" + +if [ ! -z "$files" ]; then + # run gofmt to print out the diff of what needs to be changed + gofmt -d -e . + exit 1 +fi + +echo "### Running staticcheck..." +staticcheck ./...