Skip to content

Commit 5b674e5

Browse files
committed
ci: add local script to run super-linter
Signed-off-by: Shingo OKAWA <[email protected]>
1 parent 1a2d580 commit 5b674e5

File tree

4 files changed

+52
-22
lines changed

4 files changed

+52
-22
lines changed

.github/actions/spelling/allow.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ genproto
211211
georoute
212212
gettask
213213
gettickets
214+
gitleaks
214215
gitvote
215216
gle
216217
googleai

.github/super-linter.env

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
SHELLCHECK_OPTS=-e SC1091 -e SC2086
2+
VALIDATE_ALL_CODEBASE=false
3+
FILTER_REGEX_EXCLUDE=^(\\.github/|\\.vscode/).*|CODE_OF_CONDUCT.md|CHANGELOG.md|GOVERNANCE.md|MAINTAINERS.md
4+
VALIDATE_BASH=true
5+
VALIDATE_BASH_EXEC=true
6+
VALIDATE_CSS=true
7+
VALIDATE_EDITORCONFIG=true
8+
VALIDATE_GIT_MERGE_CONFLICT_MARKERS=true
9+
VALIDATE_GITHUB_ACTIONS=true
10+
VALIDATE_GITLEAKS=true
11+
VALIDATE_JSCPD=true
12+
VALIDATE_JSON=true
13+
VALIDATE_MARKDOWN=true
14+
VALIDATE_PROTOBUF=true
15+
VALIDATE_PYTHON_RUFF=true
16+
VALIDATE_SHELL_SHFMT=true
17+
VALIDATE_TOML=true
18+
VALIDATE_TYPESCRIPT_ES=true
19+
VALIDATE_YAML=true
20+
TYPESCRIPT_ES_CONFIG_FILE=.eslintrc.js
21+
MARKDOWN_CONFIG_FILE=.markdownlint.json
22+
PROTOBUF_CONFIG_FILE=.protolint.yaml

.github/workflows/linter.yaml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,11 @@ jobs:
1919
with:
2020
fetch-depth: 0
2121

22+
- name: Load Super Linter Environment Variables into GITHUB_ENV
23+
run: |
24+
grep -v '^\\(#.*\\|\\s\\?\\)$' .github/super-linter.env >> "${GITHUB_ENV}"
25+
2226
- name: GitHub Super Linter
2327
uses: super-linter/super-linter/slim@v8
2428
env:
2529
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26-
SHELLCHECK_OPTS: -e SC1091 -e 2086
27-
VALIDATE_ALL_CODEBASE: false
28-
FILTER_REGEX_EXCLUDE: "^(\\.github/|\\.vscode/).*|CODE_OF_CONDUCT.md|CHANGELOG.md|GOVERNANCE.md|MAINTAINERS.md"
29-
VALIDATE_BASH: true
30-
VALIDATE_BASH_EXEC: true
31-
VALIDATE_CSS: true
32-
VALIDATE_EDITORCONFIG: true
33-
VALIDATE_GIT_MERGE_CONFLICT_MARKERS: true
34-
VALIDATE_GITHUB_ACTIONS: true
35-
VALIDATE_GITLEAKS: true
36-
VALIDATE_JSCPD: true
37-
VALIDATE_JSON: true
38-
VALIDATE_MARKDOWN: true
39-
VALIDATE_PROTOBUF: true
40-
VALIDATE_PYTHON_RUFF: true
41-
VALIDATE_SHELL_SHFMT: true
42-
VALIDATE_TOML: true
43-
VALIDATE_TYPESCRIPT_ES: true
44-
VALIDATE_YAML: true
45-
TYPESCRIPT_ES_CONFIG_FILE: ".eslintrc.js"
46-
MARKDOWN_CONFIG_FILE: ".markdownlint.json"
47-
PROTOBUF_CONFIG_FILE: ".protolint.yaml"

scripts/lint.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Exit on error (-e), undefined variable usage (-u), or failed pipe command (-o pipefail).
4+
set -euo pipefail
5+
6+
# Determine the repository root directory based on the script's location.
7+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
8+
REPO_ROOT=$(cd -- "${SCRIPT_DIR}/.." &>/dev/null && pwd)
9+
# Absolute path to the Super Linter configuration file.
10+
SUPER_LINTER_ENV="${REPO_ROOT}/.github/super-linter.env"
11+
# Detect the default branch from the remote repository.
12+
DEFAULT_BRANCH=$(git remote show origin | grep 'HEAD branch' | cut -d' ' -f5)
13+
14+
# Run Super Linter locally using Docker.
15+
# This mirrors the configuration used in GitHub Actions to provide consistent linting behavior.
16+
docker run \
17+
--rm -t \
18+
--platform linux/x86_64 \
19+
-v "${REPO_ROOT}":/tmp/lint \
20+
-e SHELL=/bin/bash \
21+
-e DEFAULT_BRANCH="${DEFAULT_BRANCH}" \
22+
-e RUN_LOCAL=true \
23+
-e LOG_LEVEL=INFO \
24+
--env-file "${SUPER_LINTER_ENV}" \
25+
ghcr.io/super-linter/super-linter:slim-v8

0 commit comments

Comments
 (0)