-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathci.sh
More file actions
57 lines (50 loc) · 1.42 KB
/
ci.sh
File metadata and controls
57 lines (50 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
set -euo pipefail
# Only try to install if running in GHA
if [[ -n "${GITHUB_ACTION:-}" ]] ; then
sudo apt-get update && sudo apt-get install -y \
shellcheck
fi
###
printf '> Running shellcheck...\n'
find . \
-type f \
-name '*.sh' \
-not -path '*.terraform*' \
-print0 \
| xargs -0 -I{} shellcheck {}
###
printf '> Finding Go modules...\n'
find . -type f -name 'go.mod' > /tmp/go-modules
if [[ "$(</tmp/go-modules wc -l)" -gt 0 ]] ; then
printf '> Installing CI checks for Go...\n'
for pkg in \
honnef.co/go/tools/cmd/staticcheck@latest \
github.com/mgechev/revive@latest \
github.com/kisielk/errcheck@latest \
; do
go install "${pkg}"
done
fi
while read -r module ; do
# Don't check the intentionally-broken dummy-app-src directory
if [[ "${module}" =~ 'dummy-app-src' ]] ; then continue ; fi
printf '> Running CI checks for Go module defined at %s...\n' "${module}"
mod_dir="$(dirname "${module}")"
(
cd "${mod_dir}"
printf '>> Running go vet...\n'
go vet ./...
printf '>> Running staticcheck linter...\n'
staticcheck ./...
printf '>> Running revive linter...\n'
revive --set_exit_status ./...
printf '>> Running error-checker...\n'
errcheck ./...
)
done < /tmp/go-modules
# TODO: enable in a separate PR
# printf '> Running IaC linter...\n'
# go run github.com/terraform-linters/tflint@latest --chdir=./terraform
###
printf '> Success!\n'