File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Maintained in https://github.com/coreos/repo-templates
2+ # Do not edit downstream.
3+
4+ name : Go
5+ on :
6+ push :
7+ branches : [main]
8+ pull_request :
9+ branches : [main]
10+ permissions :
11+ contents : read
12+
13+ # don't waste job slots on superseded code
14+ concurrency :
15+ group : ${{ github.workflow }}-${{ github.ref }}
16+ cancel-in-progress : true
17+
18+ jobs :
19+ test :
20+ name : Test
21+ strategy :
22+ matrix :
23+ go-version : [1.25.x, 1.26.x]
24+ runs-on : ubuntu-latest
25+ steps :
26+ - name : Set up Go 1.x
27+ uses : actions/setup-go@v5
28+ with :
29+ go-version : ${{ matrix.go-version }}
30+ - name : Check out repository
31+ uses : actions/checkout@v6
32+ - name : Check Go formatting (gofmt)
33+ shell : bash
34+ run : |
35+ GO_FILES=$(find . -name '*.go' -not -path "./vendor/*")
36+ UNFORMATTED_FILES=$(gofmt -l $GO_FILES)
37+ if [ -n "$UNFORMATTED_FILES" ]; then
38+ echo "Go files are not formatted. Please run 'gofmt -w .' on your code."
39+ gofmt -d $UNFORMATTED_FILES
40+ exit 1
41+ fi
42+ echo "All Go files are correctly formatted."
43+ - name : Run linter
44+ uses : golangci/golangci-lint-action@v8
45+ with :
46+ version : v2.11.3
Original file line number Diff line number Diff line change 1+ # Template generated by https://github.com/coreos/repo-templates; do not edit downstream
2+
3+ name : ShellCheck
4+
5+ on :
6+ pull_request :
7+ branches : [main, rhel-*, rhcos-*]
8+
9+ permissions :
10+ contents : read
11+
12+ jobs :
13+ shellcheck :
14+ name : Shellcheck
15+ runs-on : ubuntu-latest
16+ container : quay.io/coreos-assembler/fcos-buildroot:testing-devel
17+ steps :
18+ - name : Check out repository
19+ uses : actions/checkout@v6
20+ # https://github.com/actions/checkout/issues/760
21+ - name : Mark git checkout as safe
22+ run : git config --global --add safe.directory "$GITHUB_WORKSPACE"
23+ - name : Run ShellCheck
24+ run : ci/shellcheck
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # Template generated by https://github.com/coreos/repo-templates; do not edit downstream
3+
4+ set -euo pipefail
5+
6+ main () {
7+ local found_errors=" false"
8+ # Let's start with error, then we can do warning, info, style
9+ local -r severity=" error"
10+
11+ while IFS= read -r -d ' ' f; do
12+ # Skip non-text files that are very unlikely to be shell scripts
13+ if [[ " $( file -b --mime-type " ${f} " | sed ' s|/.*||' ) " != " text" ]]; then
14+ continue
15+ fi
16+ shebang=" $( head -1 " ${f} " ) "
17+ if [[ " ${f} " == * .sh ]] || \
18+ [[ ${shebang} =~ ^#! /.*/bash.* ]] || \
19+ [[ ${shebang} =~ ^#! /.*/env\ bash ]]; then
20+ echo " [+] Checking ${f} "
21+ shellcheck --external-sources --shell bash --severity= " ${severity} " " ${f} " || found_errors= " true"
22+ bash -n " ${f} " || found_errors= " true"
23+ fi
24+ done< < (find . -path " ./.git" -prune -o -path " ./vendor" -prune -o -type f -print0)
25+
26+ if [[ " ${found_errors} " != " false" ]]; then
27+ echo " [+] Found errors with ShellCheck"
28+ exit 1
29+ fi
30+
31+ echo " [+] No error found with ShellCheck"
32+ exit 0
33+ }
34+
35+ main " ${@ } "
You can’t perform that action at this time.
0 commit comments