Files
claudeandClaude Opus 5.5 1dab77645e G2: reusable lint workflows for Ansible roles, Helm charts and Dockerfiles
Three workflow_call workflows that run in the shared CI tools image (G1):
- reusable-ansible-role-lint: ansible-lint (which includes yamllint's
  rules) on a copy of the role named as the playbooks use it, with the
  repo name also resolvable for galaxy's skeleton tests/test.yml.
  role-name is a warning; .ansible-lint-ignore baselines are honoured.
- reusable-helm-lint: helm lint, then helm template | kubeconform for
  Kubernetes 1.31.2, with optional extra values files.
- reusable-dockerfile-lint: hadolint on every Dockerfile, threshold
  warning by default.

docs/ci-cd/adding-ci.md has caller templates, inputs, the baseline
command, and what was and wasn't tested.

Tested locally by running each workflow's steps verbatim in a local build
of the tools image: ansible-role-gitea fails as-is (48 findings), passes
with a baseline and fails on a new bad task; helm-jamulus passes, a
missing-value template and an invalid Service fail; the tools Dockerfile
passes and an unpinned one fails. Not yet run on the runner, and
cross-repo uses: is untested. No callers added, so no runs start.

Refs DevOps/software-infrastructure#50

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 18:49:25 -05:00

53 lines
1.7 KiB
YAML

# Reusable Dockerfile lint (hadolint). DevOps/software-infrastructure#50 (G2).
# Usage: docs/ci-cd/adding-ci.md. A repo's .hadolint.yaml is honoured.
name: reusable-dockerfile-lint
on:
workflow_call:
inputs:
tools-image:
description: CI tools image, pinned by version.
type: string
default: gitea.eom.dev/devops/ci-tools:1.0.0
dockerfiles:
description: "Space-separated Dockerfile paths. Default: every Dockerfile* and *.Dockerfile in the repo."
type: string
default: ""
failure-threshold:
description: Lowest hadolint severity that fails the job (error, warning, info, style).
type: string
default: warning
permissions:
contents: read
jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
container:
image: ${{ inputs.tools-image }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- name: hadolint
env:
DOCKERFILES: ${{ inputs.dockerfiles }}
THRESHOLD: ${{ inputs.failure-threshold }}
run: |
set -euo pipefail
files=()
if [ -n "$DOCKERFILES" ]; then
for f in $DOCKERFILES; do files+=("$f"); done
else
while IFS= read -r f; do files+=("$f"); done < <(
find . -path ./.git -prune -o -type f \( -name 'Dockerfile*' -o -name '*.Dockerfile' \) -print | sort)
fi
if [ "${#files[@]}" -eq 0 ]; then
echo "::error::No Dockerfiles found. Set the dockerfiles input."
exit 1
fi
printf 'Linting %s\n' "${files[@]}"
hadolint --no-color --failure-threshold "$THRESHOLD" "${files[@]}"