Skip to content

Commit a2c1d1f

Browse files
committed
Add Docker-based development environment with official tool images
Features: - Makefile targets for running linting tools via official Docker images - mvdan/shfmt:v3 for shell script formatting - koalaman/shellcheck:stable for shell linting - node:lts-alpine with markdownlint-cli2 for markdown validation - No custom Dockerfile needed - uses well-maintained official images - Simplified pre-commit configuration with Docker-based hooks - Updated SETUP.md and AGENTS.md for simplified Docker workflow - Reverted CI workflow to GitHub Actions (checkshell.yml) - Native shfmt and shellcheck actions - DavidAnson/markdownlint-cli2-action for markdown linting - Jobs run in parallel without Docker overhead Benefits: - Developers only need Docker installed - Official tool images always available from maintainers - No build step required - images pulled on demand - Consistent tool versions across local dev and CI - Simpler to maintain - just update image tags - Faster CI with native GitHub Actions - Automatic updates by using stable/lts tags
1 parent 1640dfb commit a2c1d1f

5 files changed

Lines changed: 239 additions & 190 deletions

File tree

.github/workflows/checkshell.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,19 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v6
11-
- run: docker run --rm -v "$(pwd)":/sh -w /sh mvdan/shfmt:v3 -sr -i 2 -l -w -ci .
11+
- run: docker run --rm -v "$(pwd)":/work -w /work mvdan/shfmt:v3 -sr -i 2 -l -w -ci .
1212
- run: git diff --color --exit-code
1313

1414
shellcheck:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- uses: actions/checkout@v6
1818
- run: shellcheck *.sh
19+
20+
markdownlint:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v6
24+
- uses: DavidAnson/markdownlint-cli2-action@v18
25+
with:
26+
globs: '*.md'

.pre-commit-config.yaml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
repos:
2-
- repo: https://github.com/shellcheck-py/shellcheck-py
3-
rev: v0.10.0.1
2+
- repo: local
43
hooks:
5-
- id: shellcheck
4+
- id: shellcheck-docker
5+
name: shellcheck (Docker)
6+
entry: bash -c 'docker run --rm -v "$(pwd)":/mnt koalaman/shellcheck:stable "$@"' bash
7+
language: system
68
types: [shell]
79
files: \.(sh|bats)$
810

9-
- repo: https://github.com/scop/pre-commit-shfmt
10-
rev: v3.9.0-1
11-
hooks:
12-
- id: shfmt
13-
args: [-sr, -i, '2', -w, -ci]
11+
- id: shfmt-docker
12+
name: shfmt (Docker)
13+
entry: bash -c 'docker run --rm -v "$(pwd)":/work -w /work mvdan/shfmt:v3 -sr -i 2 -w -ci "$@"' bash
14+
language: system
1415
types: [shell]
1516
files: \.(sh|bats)$
1617

17-
- repo: https://github.com/DavidAnson/markdownlint-cli2
18-
rev: v0.15.0
19-
hooks:
20-
- id: markdownlint-cli2
18+
- id: markdownlint-docker
19+
name: markdownlint-cli2 (Docker)
20+
entry: bash -c 'docker run --rm -v "$(pwd)":/work -w /work node:lts-alpine npx markdownlint-cli2 "$@"' bash
21+
language: system
2122
types: [markdown]

AGENTS.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,63 @@ Checks for new Node.js versions to build:
9090
- Quick start: `pre-commit install` then hooks run automatically on commit
9191
- **Branch Protection:** main branch requires passing checks and code owner review
9292

93+
## Docker-Based Development
94+
95+
All development tools run in official Docker containers. This approach requires only Docker; no local installation of shellcheck, shfmt, or Node.js needed.
96+
97+
### Getting Started
98+
99+
```bash
100+
# Run all linters
101+
make lint
102+
103+
# Auto-fix formatting issues
104+
make format
105+
106+
# See all available commands
107+
make help
108+
```
109+
110+
### Makefile Targets
111+
112+
The `Makefile` provides convenient targets for code quality checks:
113+
114+
- `make lint` - Run all linters (shellcheck, shfmt, markdownlint)
115+
- `make format` - Auto-fix shell script formatting with shfmt
116+
- `make shellcheck` - Run shellcheck
117+
- `make shfmt` - Check shell script formatting
118+
- `make shfmt-fix` - Auto-fix shell formatting
119+
- `make markdown-lint` - Check markdown files
120+
- `make help` - Display all available targets
121+
122+
### Pre-commit Hooks with Docker
123+
124+
Pre-commit hooks are configured to run tools inside Docker containers for consistency:
125+
126+
```bash
127+
pre-commit install # Install hooks
128+
pre-commit run --all-files # Run manually
129+
```
130+
131+
Hooks automatically execute on commit using official Docker images. See [SETUP.md](./SETUP.md) for complete setup instructions.
132+
133+
### For AI Agents
134+
135+
To run development checks in an agent environment with only Docker available:
136+
137+
```bash
138+
# Run all linters via Makefile
139+
make lint
140+
make format
141+
142+
# Or run individual Docker commands
143+
docker run --rm -v "$(pwd)":/mnt koalaman/shellcheck:stable *.sh
144+
docker run --rm -v "$(pwd)":/work -w /work mvdan/shfmt:v3 -sr -i 2 -l -ci *.sh
145+
docker run --rm -v "$(pwd)":/work -w /work node:lts-alpine npx markdownlint-cli2 "*.md"
146+
```
147+
148+
This approach requires only Docker to be installed in the agent's environment.
149+
93150
## Testing
94151

95152
### Unit Tests

Makefile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.PHONY: help lint shellcheck shfmt shfmt-fix markdown-lint format
2+
3+
export DOCKER_CLI_HINTS=false
4+
5+
help:
6+
@echo "Available targets:"
7+
@echo " lint Run all linters (shellcheck, shfmt, markdownlint)"
8+
@echo " shellcheck Run shellcheck"
9+
@echo " shfmt Check shell script formatting"
10+
@echo " shfmt-fix Auto-fix shell script formatting"
11+
@echo " markdown-lint Check markdown files"
12+
@echo " format Auto-format shell scripts (alias for shfmt-fix)"
13+
14+
shellcheck:
15+
docker run --rm -v "$$(pwd)":/mnt koalaman/shellcheck:stable *.sh
16+
17+
shfmt:
18+
docker run --rm -v "$$(pwd)":/work -w /work mvdan/shfmt:v3 -sr -i 2 -l -ci *.sh
19+
20+
shfmt-fix:
21+
docker run --rm -v "$$(pwd)":/work -w /work mvdan/shfmt:v3 -sr -i 2 -w -ci *.sh
22+
23+
markdown-lint:
24+
docker run --rm -v "$$(pwd)":/work -w /work node:lts-alpine sh -c "npx markdownlint-cli2 '*.md'"
25+
26+
format: shfmt-fix
27+
28+
lint: shellcheck shfmt markdown-lint

0 commit comments

Comments
 (0)