validate authors target

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-12-21 01:44:40 +01:00
parent ede32747b5
commit bea6c0d242
No known key found for this signature in database
GPG Key ID: 3248E46B6BB8C7F7
5 changed files with 42 additions and 5 deletions

View File

@ -20,6 +20,7 @@ jobs:
- lint
- shellcheck
- validate-vendor
- update-authors # ensure authors update target runs fine
steps:
-
name: Checkout

View File

@ -114,6 +114,20 @@ target "mod-outdated" {
output = ["type=cacheonly"]
}
target "validate-authors" {
inherits = ["_common"]
dockerfile = "./dockerfiles/Dockerfile.authors"
target = "validate"
output = ["type=cacheonly"]
}
target "update-authors" {
inherits = ["_common"]
dockerfile = "./dockerfiles/Dockerfile.authors"
target = "update"
output = ["."]
}
target "test" {
target = "test"
output = ["type=cacheonly"]

View File

@ -97,7 +97,7 @@ mod-outdated: ## check outdated dependencies
.PHONY: authors
authors: ## generate AUTHORS file from git history
$(DOCKER_RUN) -it $(DEV_DOCKER_IMAGE_NAME) make authors
docker buildx bake update-authors
.PHONY: manpages
manpages: build_docker_image ## generate man pages from go source and markdown

View File

@ -0,0 +1,23 @@
# syntax=docker/dockerfile:1.3-labs
FROM alpine:3.14 AS gen
RUN apk add --no-cache bash git
WORKDIR /src
RUN --mount=type=bind,target=. \
mkdir /out && ./scripts/docs/generate-authors.sh /out
FROM scratch AS update
COPY --from=gen /out /
FROM gen AS validate
RUN --mount=type=bind,target=.,rw <<EOT
set -e
git add -A
cp -rf /out/* .
diff=$(git status --porcelain -- AUTHORS)
if [ -n "$diff" ]; then
echo >&2 'ERROR: Authors result differs. Please update with "make -f docker.Makefile authors"'
echo "$diff"
exit 1
fi
EOT

View File

@ -1,10 +1,8 @@
#!/usr/bin/env bash
set -e
cd "$(dirname "$(readlink -f "${BASH_SOURCE[*]}")")/../.."
# see also ".mailmap" for how email addresses and names are deduplicated
OUT="${1:-.}"
{
cat <<-'EOH'
# This file lists all individuals having contributed content to the repository.
@ -12,4 +10,5 @@ cd "$(dirname "$(readlink -f "${BASH_SOURCE[*]}")")/../.."
EOH
echo
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf
} > AUTHORS
} > "$OUT/AUTHORS"
cat "$OUT/AUTHORS"