Files
kured/Makefile
T
Jean-Philippe Evrard e531f64b85 feat(release): let GoReleaser manage artifacts
GoReleaser now builds the multi-arch images,
publishes SBOM/provenance metadata, signs image digests, and attaches
the generated combined Kubernetes manifest to tagged GitHub releases.

This is to have goReleaser as a single point of work for release
automation. With this, so tags and main commits follow one consistent
image pipeline.

We keep the CI and developer image builds intentionally local.
PR, periodic, main, and tag scan jobs build only `kured:dev` and scan that
local image with Trivy, which avoids pushing disposable images and keeps
the tested image identical to the one used by kind-based e2e tests.

Simplify the Makefile around the remaining artifact boundaries: `build` for a
local GoReleaser binary build, `dev-image` for local Docker/e2e/scan use, and
`release` for the GoReleaser publish path. Remove the old manual manifest
target because the release manifest is now generated during the tagged release
flow.

To avoid a mess with all the configuration files, I move everything into
a `.config` folder, for the tools supporting it.

This also meant updating golangci-lint to a valid v2 config, and simplify
the Dockerfile to the layout expected by GoReleaser `dockers_v2`
using `TARGETPLATFORM`.

Handle Prometheus client initialization errors explicitly so the stricter
errcheck configuration keeps the existing fail-closed reboot-blocking behavior,
to fix the golangci-lint issue that appeared.

Signed-off-by: Jean-Philippe Evrard <open-source@a.spamming.party>
2026-06-09 09:19:04 +02:00

67 lines
2.8 KiB
Makefile

.DEFAULT: all
.PHONY: all clean install-tools build dev-image release dev-manifest e2e-test minikube-publish test lint lint-docs
DH_ORG ?= kubereboot
IMAGE_NAME ?= $(DH_ORG)/kured
VERSION ?= $(shell git rev-parse --short HEAD)
GORELEASER_CONFIG ?= .config/goreleaser.yaml
GOLANGCI_CONFIG ?= .config/golangci.yaml
LOCAL_PLATFORM ?= linux/amd64
SUDO=$(shell docker info >/dev/null 2>&1 || echo "sudo -E")
DEV_IMAGE := kured:dev
all: build
install-tools:
command -v mise 2>&1 || { echo "please install mise to continue" >&2; exit 127; }
mise install
clean:
rm -rf ./dist ./.tmp/goreleaser
build:
IMAGE_NAME="$(IMAGE_NAME)" goreleaser build --clean --single-target --snapshot -f $(GORELEASER_CONFIG)
release:
IMAGE_NAME="$(IMAGE_NAME)" goreleaser release --clean -f $(GORELEASER_CONFIG)
dev-image:
mkdir -p dist/docker/$(LOCAL_PLATFORM)
CGO_ENABLED=0 go build -trimpath -ldflags "-s -w -X main.version=$(VERSION)" -o dist/docker/$(LOCAL_PLATFORM)/kured ./cmd/kured
cp Dockerfile dist/docker/Dockerfile
$(SUDO) docker buildx build --load --platform $(LOCAL_PLATFORM) -t $(DEV_IMAGE) dist/docker
dev-manifest:
# basic e2e scenario
sed -e "s#image: ghcr.io/.*kured.*#image: kured:dev#g" -e 's/#\(.*\)--period=1h/\1--period=20s/g' kured-ds.yaml > tests/kind/testfiles/kured-ds.yaml
# signal e2e scenario
sed -e "s#image: ghcr.io/.*kured.*#image: kured:dev#g" -e 's/#\(.*\)--period=1h/\1--period=20s/g' kured-ds-signal.yaml > tests/kind/testfiles/kured-ds-signal.yaml
# concurrency e2e command scenario
sed -e "s#image: ghcr.io/.*kured.*#image: kured:dev#g" -e 's/#\(.*\)--period=1h/\1--period=20s/g' -e 's/#\(.*\)--concurrency=1/\1--concurrency=2/g' kured-ds.yaml > tests/kind/testfiles/kured-ds-concurrent-command.yaml
# concurrency e2e signal scenario
sed -e "s#image: ghcr.io/.*kured.*#image: kured:dev#g" -e 's/#\(.*\)--period=1h/\1--period=20s/g' -e 's/#\(.*\)--concurrency=1/\1--concurrency=2/g' kured-ds-signal.yaml > tests/kind/testfiles/kured-ds-concurrent-signal.yaml
# pod blocker e2e signal scenario
sed -e "s#image: ghcr.io/.*kured.*#image: kured:dev#g" -e 's/#\(.*\)--period=1h/\1--period=20s/g' -e 's/#\(.*\)--blocking-pod-selector=name=temperamental/\1--blocking-pod-selector=app=blocker/g' kured-ds-signal.yaml > tests/kind/testfiles/kured-ds-podblocker.yaml
e2e-test: dev-manifest dev-image
echo "Running ALL go tests"
go test -count=1 -v --parallel 4 ./... $(ARGS)
minikube-publish: dev-image
$(SUDO) docker save $(DEV_IMAGE) | (eval $$(minikube docker-env) && docker load)
test: lint
@echo "Running short go tests"
go test -test.short -json ./... > test.json
lint:
@echo "Running shellcheck"
find . -name '*.sh' | xargs -n1 shellcheck
@echo "Running golangci-lint..."
golangci-lint run --config $(GOLANGCI_CONFIG) ./...
lint-docs:
@echo "Running lychee"
mise x lychee@latest -- lychee --verbose --no-progress '*.md' '*.yaml' '*/*/*.go' --exclude-link-local