Lint by piping files to the linters instead of bind-mounting
`make lint` passed locally but failed in Gitea Actions with every Dockerfile
reported as missing:
hadolint: images/node-agent/Dockerfile: withBinaryFile: does not exist
The job itself runs in a container, and the checkout lives in a docker volume
rather than on the host filesystem. Starting hadolint as a sibling container
through the host's docker socket meant `-v "$(CURDIR)":/repo` was resolved
against the HOST, where /workspace/... does not exist — so Docker created an
empty directory and mounted that.
Stream each file in on stdin instead. No shared filesystem is involved, so the
same command works locally and in CI. The linters then only ever see "-" as the
filename, so hack/lint.sh prints the real path itself, and only on failure.
Reproduced the original error and verified the fix against a faithful local
simulation: the repo in a docker volume at a path absent from the host, with
the socket mounted, running the real runner image.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
@@ -14,10 +14,6 @@ TARGETS := $(if $(IMAGE),$(IMAGE),$(IMAGES))
|
||||
# CI overrides REF with the real published ref so the smoke test runs against it.
|
||||
REF ?=
|
||||
|
||||
HADOLINT ?= hadolint/hadolint:latest-alpine
|
||||
SHELLCHECK ?= koalaman/shellcheck:stable
|
||||
SCRIPTS := $(wildcard hack/*.sh images/*/test.sh template/test.sh)
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
.PHONY: help list check lint hadolint shellcheck build test all
|
||||
|
||||
@@ -40,13 +36,10 @@ check: ## Verify each image directory follows the expected layout
|
||||
exit $$rc
|
||||
|
||||
hadolint: ## Lint every Dockerfile
|
||||
@docker run --rm -v "$(CURDIR)":/repo:ro -w /repo $(HADOLINT) \
|
||||
hadolint $(addprefix images/,$(addsuffix /Dockerfile,$(IMAGES))) template/Dockerfile
|
||||
@echo "hadolint ok"
|
||||
@hack/lint.sh dockerfiles
|
||||
|
||||
shellcheck: ## Lint every shell script
|
||||
@docker run --rm -v "$(CURDIR)":/repo:ro -w /repo $(SHELLCHECK) $(SCRIPTS)
|
||||
@echo "shellcheck ok"
|
||||
@hack/lint.sh scripts
|
||||
|
||||
lint: hadolint shellcheck ## Run all linters
|
||||
|
||||
|
||||
Reference in New Issue
Block a user