Skip to content

Commit a91dda8

Browse files
committed
ci: run shellcheck and hadolint via lint script
1 parent b9652ae commit a91dda8

4 files changed

Lines changed: 68 additions & 3 deletions

File tree

.github/workflows/pr.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,21 @@ on:
44
pull_request:
55

66
jobs:
7+
lint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
12+
- uses: jdx/mise-action@v2
13+
with:
14+
cache: true
15+
16+
- name: Lint
17+
run: ./scripts/lint.sh
18+
719
matrix:
820
runs-on: ubuntu-latest
21+
needs: [lint]
922
outputs:
1023
matrix: ${{ steps.gen.outputs.matrix }}
1124
count: ${{ steps.gen.outputs.count }}
@@ -63,4 +76,3 @@ jobs:
6376
tags: local/${{ matrix.image_name }}:pr-${{ github.sha }}
6477
cache-from: type=gha
6578
cache-to: type=gha,mode=max
66-

.github/workflows/publish.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,21 @@ permissions:
1010
packages: write
1111

1212
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- uses: jdx/mise-action@v2
19+
with:
20+
cache: true
21+
22+
- name: Lint
23+
run: ./scripts/lint.sh
24+
1325
matrix:
1426
runs-on: ubuntu-latest
27+
needs: [lint]
1528
outputs:
1629
matrix: ${{ steps.gen.outputs.matrix }}
1730
count: ${{ steps.gen.outputs.count }}
@@ -93,4 +106,3 @@ jobs:
93106
org.opencontainers.image.revision=${{ github.sha }}
94107
cache-from: type=gha
95108
cache-to: type=gha,mode=max
96-

AGENTS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ Notes:
5151
- Use `mise` to install tool dependencies in CI (via `jdx/mise-action`).
5252
- Builds must be multi-arch with Buildx (at least `linux/amd64` and `linux/arm64`).
5353
- PRs should validate Dockerfiles (lint + build) but must not push to GHCR.
54+
- CI must run repo linting via `./scripts/lint.sh` (ShellCheck for `scripts/*.sh`, Hadolint for `images/*/Dockerfile`).
55+
56+
## Linting
57+
58+
- Run locally: `./scripts/lint.sh`
59+
- CI must run this script on PRs and on `main` publishes so linting stays consistent across sessions.
5460

5561
## Adding A New Image
5662

5763
1. Create `images/<image>/Dockerfile` and `.dockerignore`.
5864
2. Add `images/<image>/image.toml` (set `version` if you want a stable tag).
5965
3. Add a short `images/<image>/README.md`.
60-

scripts/lint.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
cd "$repo_root"
6+
7+
echo "[lint] shellcheck"
8+
if command -v shellcheck >/dev/null 2>&1; then
9+
shellcheck scripts/*.sh
10+
elif command -v mise >/dev/null 2>&1; then
11+
mise exec -- shellcheck scripts/*.sh
12+
else
13+
echo "[lint] shellcheck (missing; install via mise)" >&2
14+
exit 127
15+
fi
16+
17+
dockerfiles=()
18+
while IFS= read -r -d '' f; do
19+
dockerfiles+=("$f")
20+
done < <(find images -mindepth 2 -maxdepth 2 -type f -name Dockerfile -print0 2>/dev/null || true)
21+
22+
if [[ ${#dockerfiles[@]} -gt 0 ]]; then
23+
echo "[lint] hadolint"
24+
for f in "${dockerfiles[@]}"; do
25+
if command -v hadolint >/dev/null 2>&1; then
26+
hadolint "$f"
27+
elif command -v mise >/dev/null 2>&1; then
28+
mise exec -- hadolint "$f"
29+
else
30+
echo "[lint] hadolint (missing; install via mise)" >&2
31+
exit 127
32+
fi
33+
done
34+
else
35+
echo "[lint] hadolint (skipped; no Dockerfiles found)"
36+
fi

0 commit comments

Comments
 (0)