Thank you for your interest in contributing to docker-lint!
- Go 1.22.x or later (matches the
go 1.22.0directive ingo.mod) - Git
-
Fork and clone the repository:
git clone https://github.com/[username]/docker-lint.git cd docker-lint -
Install dependencies:
go mod download
-
Build the project:
go build -o docker-lint ./cmd/docker-lint
-
Run tests:
go test ./...
docker-lint/
├── cmd/docker-lint/ # CLI entry point
├── internal/
│ ├── ast/ # AST data structures
│ ├── parser/ # BuildKit parse result -> AST conversion
│ ├── rules/ # Lint rule implementations
│ ├── analyzer/ # Rule orchestration
│ └── formatter/ # Output formatters
└── testdata/ # Test fixtures
- Write unit tests for new functionality
- Write property-based tests for universal properties
- Use table-driven tests where appropriate
- Include test fixtures in
testdata/ - After changing a rule or the parser, regenerate the real-world corpus snapshots
with
go test ./internal/analyzer -run TestCorpus -update-corpusand review the diff: every changed line is a finding that appeared, disappeared or moved on a real Dockerfile (seetestdata/corpus/SOURCES.md)
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run specific package tests
go test ./internal/parser/- Follow standard Go conventions
- Run
go fmtbefore committing - Run
go vetto catch common issues - Keep functions small and focused
- Create a feature branch from
main - Make your changes with clear commit messages
- Ensure all tests pass
- Update documentation if needed
- Submit a pull request with a clear description
- Create or update a file in
internal/rules/ - Implement the
Ruleinterface - Register the rule in
registry.go - Add unit tests for the rule
- Update README.md with rule documentation
Releases are built by GoReleaser from a pushed tag and land as a draft GitHub release, so nothing is public until a maintainer publishes it.
-
Make sure
mainis green andgoreleaser release --snapshot --cleanbuilds locally (CI also runs it on every pull request). -
In
CHANGELOG.md, rename## [Unreleased]to## [X.Y.Z] - YYYY-MM-DD, add a new empty## [Unreleased]above it, update the comparison links at the bottom, point thedocker-lint-dockerhook in.pre-commit-hooks.yamland the version examples inREADME.mdat the new version, and merge that change tomain. The Release workflow fails if the hook names another version's image. -
Tag the merge commit and push the tag:
git tag -a vX.Y.Z -m "docker-lint vX.Y.Z" git push origin vX.Y.Z -
The Release workflow runs the tests, takes the release notes from the version's
CHANGELOG.mdsection (it fails if there is none) and uploads the binaries andchecksums.txtto a draft release. -
Review the draft on the Releases page: check its notes, download an archive and verify it against
checksums.txt, then publish it. Avoidgo install ...@vX.Y.Zbefore publishing: the Go module proxy caches a tag's contents permanently, so the tag can no longer be moved if the release needs fixing. -
Publishing the release runs the Image workflow, which pushes
ghcr.io/devblac/docker-lintfor linux/amd64 and linux/arm64. The first time, make the package public in its settings on GitHub; packages start out private. It also runs the Version tags workflow, which moves the major and minor tags (v0,v0.1) to the release when it is the newest in their line. Never push those tags by hand.
Open an issue for questions or discussions.