Skip to content

Commit 5149e06

Browse files
authored
ci: add pre-commit hooks and fix shellcheck findings (#295)
* Add pre-commit hooks actionlint, zizmor-pre-commit, gitleaks and pre-commit-hooks * Add/fix trailing new line * ci: fix shellcheck findings in workflow files Quote variable expansions to satisfy SC2086 and use ./*.glob pattern to satisfy SC2035 in actionlint checks.
1 parent c287bdc commit 5149e06

6 files changed

Lines changed: 43 additions & 19 deletions

File tree

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ end_of_line = lf
66
indent_size = 2
77
indent_style = space
88
insert_final_newline = true
9-
trim_trailing_whitespace = true
9+
trim_trailing_whitespace = true

.github/dependabot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@ updates:
2828
include: "scope"
2929
cooldown:
3030
default-days: 7
31-

.github/workflows/dockerimage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
ccache -p
5555
5656
- name: Get latest node version
57-
run: echo "LATEST_VERSION=$(curl -fsSLo- --compressed https://nodejs.org/dist/index.json | jq '.[].version' | tr -d '"' | tr -d 'v' | head -1)" >> $GITHUB_ENV
57+
run: echo "LATEST_VERSION=$(curl -fsSLo- --compressed https://nodejs.org/dist/index.json | jq '.[].version' | tr -d '"' | tr -d 'v' | head -1)" >> "$GITHUB_ENV"
5858

5959
- name: Display Node Version
6060
run: |
@@ -64,9 +64,9 @@ jobs:
6464
run: |
6565
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
6666
which gcc
67-
./build.sh -n $LATEST_VERSION
67+
./build.sh -n "$LATEST_VERSION"
6868
ccache -s
69-
cp node-v$LATEST_VERSION/out/Release/node node
69+
cp "node-v${LATEST_VERSION}/out/Release/node" node
7070
7171
- name: Set up Docker Buildx
7272
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242

4343
- name: Shellcheck
4444
run: |
45-
shellcheck *.sh
45+
shellcheck ./*.sh
4646
shellcheck test/*.bats
4747
4848
markdownlint:

.github/workflows/update-current-image.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
else
4848
NODE_VERSION=$(./check-missing-versions.sh | tail -1)
4949
fi
50-
echo "NODE_VERSION=$NODE_VERSION" >> $GITHUB_OUTPUT
50+
echo "NODE_VERSION=$NODE_VERSION" >> "$GITHUB_OUTPUT"
5151
if [[ -n "$NODE_VERSION" ]]; then
5252
echo "Building Node.js version: $NODE_VERSION"
5353
else
@@ -99,17 +99,17 @@ jobs:
9999
100100
- name: Set and Display Versions
101101
run: |
102-
MAJOR_VERSION=$(echo $NODE_VERSION | cut -d'.' -f 1)
103-
echo "MAJOR_VERSION=$MAJOR_VERSION" >> $GITHUB_ENV
102+
MAJOR_VERSION=$(echo "$NODE_VERSION" | cut -d'.' -f 1)
103+
echo "MAJOR_VERSION=$MAJOR_VERSION" >> "$GITHUB_ENV"
104104
echo "Building Node.js version: $NODE_VERSION (major: $MAJOR_VERSION)"
105105
106106
- name: Build Node
107107
run: |
108108
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
109109
which gcc
110-
./build.sh -n $NODE_VERSION
110+
./build.sh -n "$NODE_VERSION"
111111
ccache -s
112-
cp node-v$NODE_VERSION/out/Release/node node
112+
cp "node-v${NODE_VERSION}/out/Release/node" node
113113
114114
- name: Set up Docker Buildx
115115
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
@@ -181,7 +181,7 @@ jobs:
181181
password: ${{ secrets.GITHUB_TOKEN }}
182182

183183
- name: Set major version
184-
run: echo "MAJOR_VERSION=$(echo "$NODE_VERSION" | cut -d'.' -f 1)" >> $GITHUB_ENV
184+
run: echo "MAJOR_VERSION=$(echo "$NODE_VERSION" | cut -d'.' -f 1)" >> "$GITHUB_ENV"
185185

186186
- name: Create DockerHub multi-arch manifests
187187
env:

.pre-commit-config.yaml

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
repos:
2-
- repo: https://github.com/koalaman/shellcheck-precommit
3-
rev: v0.11.0
2+
- repo: https://github.com/rhysd/actionlint
3+
rev: v1.7.9
44
hooks:
5-
- id: shellcheck
6-
files: \.(sh|bats)$
5+
- id: actionlint
6+
7+
- repo: https://github.com/gitleaks/gitleaks
8+
rev: v8.23.1
9+
hooks:
10+
- id: gitleaks
11+
12+
- repo: https://github.com/DavidAnson/markdownlint-cli2
13+
rev: v0.22.1
14+
hooks:
15+
- id: markdownlint-cli2-docker
16+
17+
- repo: https://github.com/pre-commit/pre-commit-hooks
18+
rev: v6.0.0
19+
hooks:
20+
- id: trailing-whitespace
21+
- id: end-of-file-fixer
22+
- id: check-yaml
23+
- id: check-merge-conflict
24+
- id: check-added-large-files
25+
- id: mixed-line-ending
726

827
- repo: https://github.com/scop/pre-commit-shfmt
928
rev: v3.13.1-1
@@ -12,7 +31,13 @@ repos:
1231
args: [-sr, -i, '2', -w, -ci]
1332
files: \.(sh|bats)$
1433

15-
- repo: https://github.com/DavidAnson/markdownlint-cli2
16-
rev: v0.22.1
34+
- repo: https://github.com/koalaman/shellcheck-precommit
35+
rev: v0.11.0
1736
hooks:
18-
- id: markdownlint-cli2-docker
37+
- id: shellcheck
38+
files: \.(sh|bats)$
39+
40+
- repo: https://github.com/woodruffw/zizmor-pre-commit
41+
rev: v1.9.0
42+
hooks:
43+
- id: zizmor

0 commit comments

Comments
 (0)