Skip to content

Commit 03386ba

Browse files
authored
lint: add actionlint (#751)
This PR adds `actionlint`[0], a linter for GitHub Workflow files. It also checks inlined bash scripts with `shellcheck`. I've disabled a couple of noisy `shellcheck` rules (`SC2046`, `SC2086`), which in most cases produce benign warnings. The action itself copied from `neondatabase/neon` [3]. Run it locally (you should have both `actionlint`, and `shellcheck` installed): ```bash SHELLCHECK_OPTS=--exclude=SC2046,SC2086 actionlint ``` - [0] https://github.com/rhysd/actionlint - [1] https://www.shellcheck.net/ - [3] neondatabase/neon#5265
1 parent 393c373 commit 03386ba

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

.github/actionlint.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
self-hosted-runner:
2+
labels:
3+
- gen3
4+
- large
5+
- small

.github/workflows/lint.yml

+21-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches:
66
- main
77

8+
defaults:
9+
run:
10+
shell: bash -euo pipefail {0}
11+
812
jobs:
913
golangci:
1014
name: golangci-lint
@@ -40,7 +44,7 @@ jobs:
4044
go mod tidy
4145
- name: check diff
4246
run: |
43-
if ! (test -z "$(git ls-files --exclude-standard --others .)$(git diff .)"); then
47+
if ! test -z "$(git ls-files --exclude-standard --others .)$(git diff .)"; then
4448
git ls-files --exclude-standard --others .
4549
git diff .
4650
echo "ERROR: 'go mod tidy' modified the source tree."
@@ -61,7 +65,7 @@ jobs:
6165
make manifests
6266
- name: check diff
6367
run: |
64-
if ! (test -z "$(git ls-files --exclude-standard --others .)$(git diff .)"); then
68+
if ! test -z "$(git ls-files --exclude-standard --others .)$(git diff .)"; then
6569
git ls-files --exclude-standard --others .
6670
git diff .
6771
echo "ERROR: 'make manifests' modified the source tree."
@@ -79,7 +83,7 @@ jobs:
7983
make generate
8084
- name: check diff
8185
run: |
82-
if ! (test -z "$(git ls-files --exclude-standard --others .)$(git diff .)"); then
86+
if ! test -z "$(git ls-files --exclude-standard --others .)$(git diff .)"; then
8387
git ls-files --exclude-standard --others .
8488
git diff .
8589
echo "ERROR: 'make generate' modified the source tree."
@@ -96,3 +100,17 @@ jobs:
96100
with:
97101
check_hidden: true
98102
skip: go.sum,*.patch # '*.patch' references cluster-autoscaler/ca.patch, but somehow skipping directly doesn't work...
103+
104+
actionlint:
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v4
108+
- uses: reviewdog/action-actionlint@54e8faeff91fe07595b1ad3cfdc6aee0157bf51b # v1.40.0
109+
env:
110+
# SC2046 - Quote this to prevent word splitting. - https://www.shellcheck.net/wiki/SC2046
111+
# SC2086 - Double quote to prevent globbing and word splitting. - https://www.shellcheck.net/wiki/SC2086
112+
SHELLCHECK_OPTS: --exclude=SC2046,SC2086
113+
with:
114+
fail_on_error: true
115+
filter_mode: nofilter
116+
level: error

.github/workflows/release.yaml

+9-7
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ jobs:
3333
- name: get version and git info
3434
id: get_vcs_info
3535
run: |
36-
echo "version=${{ github.ref_name }}" >> $GITHUB_OUTPUT
37-
echo -n "git_info=" >> $GITHUB_OUTPUT
38-
# note: --tags enables matching on lightweight (i.e. not annotated) tags, which normally
39-
# wouldn't be necessary, except that actions/checkout@v3 does weird things to setup the
40-
# repository that means that we actually end up checked out with *just* a lightweight tag
41-
# to the tagged commit.
42-
git describe --tags --long --dirty >> $GITHUB_OUTPUT
36+
{
37+
echo "version=${{ github.ref_name }}"
38+
echo -n "git_info="
39+
# note: --tags enables matching on lightweight (i.e. not annotated) tags, which normally
40+
# wouldn't be necessary, except that actions/checkout@v3 does weird things to setup the
41+
# repository that means that we actually end up checked out with *just* a lightweight tag
42+
# to the tagged commit.
43+
git describe --tags --long --dirty
44+
} >> $GITHUB_OUTPUT
4345
- name: get CA base git tag
4446
id: get_ca_tag
4547
run: |

.github/workflows/vm-kernel.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
elif [ -z "${CACHED_IMAGE}" ]; then
106106
# there's no image to retag
107107
RETAG_NEEDED=false
108-
elif [ -n "${FORCED_TAG}"]; then
108+
elif [ -n "${FORCED_TAG}" ]; then
109109
# we're asked to return image for a specific tag, so no need to retag
110110
RETAG_NEEDED=false
111111
elif [ "${FORCE_REBUILD}" == "true" ]; then

0 commit comments

Comments
 (0)