From 53ce28113f1cabd46c8b6f143bdc8175d4c61d8b Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 14 May 2026 23:05:38 +0100 Subject: [PATCH 1/2] Add Makefile to drive templated builds, replace CI bash loop The bash arg-extraction loop in ci.yml and the README was hard to read and not reusable locally. A Makefile replaces it with one-line commands: make build VERSION=8.4 make test VERSION=8.4 make all CI now invokes `make build` directly. README documents the same commands. Co-Authored-By: Claude Opus 4.7 --- .github/workflows/ci.yml | 11 +---------- Makefile | 22 ++++++++++++++++++++++ README.md | 14 ++++---------- 3 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6d8f367..2173c10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,16 +43,7 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Build image - run: | - set -a - . ./versions/${{ matrix.php-versions }}.env - set +a - args=() - while IFS='=' read -r k _; do - [[ -z "$k" || "$k" =~ ^# ]] && continue - args+=(--build-arg "$k") - done < versions/${{ matrix.php-versions }}.env - docker image build "${args[@]}" --tag utopia-base-test . + run: make build VERSION=${{ matrix.php-versions }} IMAGE=utopia-base-test - name: Save image run: docker image save utopia-base-test -o image.tar diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..86c1b50 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +VERSION ?= 8.4 +IMAGE ?= utopia-base-test +ENV_FILE := versions/$(VERSION).env + +BUILD_ARGS := $(shell awk -F= '!/^\#/ && NF { printf "--build-arg %s ", $$1 }' $(ENV_FILE)) + +.PHONY: build test all clean + +build: + set -a && . ./$(ENV_FILE) && set +a && \ + docker build $(BUILD_ARGS) --tag $(IMAGE) . + +test: build + container-structure-test test --image $(IMAGE) --config tests.yaml + +all: + $(MAKE) build VERSION=8.3 + $(MAKE) build VERSION=8.4 + $(MAKE) build VERSION=8.5 + +clean: + docker rmi $(IMAGE) 2>/dev/null || true diff --git a/README.md b/README.md index 4371198..102c5d3 100644 --- a/README.md +++ b/README.md @@ -34,18 +34,12 @@ All publishing workflows share a `build-` concurrency group so a release qu ## Local development -A single `Dockerfile` is templated by the per-version configs in `versions/.env`: +A single `Dockerfile` is templated by the per-version configs in `versions/.env`. Use the `Makefile`: ```sh -set -a && . versions/8.4.env && set +a -args=() -while IFS='=' read -r k _; do - [[ -z "$k" || "$k" =~ ^# ]] && continue - args+=(--build-arg "$k") -done < versions/8.4.env - -docker build "${args[@]}" -t utopia-base-test . -container-structure-test test --image utopia-base-test --config tests.yaml +make build VERSION=8.4 # build a single version +make test VERSION=8.4 # build + run structure tests +make all # build all supported versions ``` To bump an extension version, edit the relevant `versions/.env`. To add a new PHP version, drop in a new `versions/.env` and add the version to the matrix in `.github/workflows/ci.yml` and `publish.yml`. From 0a2c301a8f4c3d59fdfdb3467bf098c363a2d043 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Thu, 14 May 2026 23:25:23 +0100 Subject: [PATCH 2/2] Address PR feedback: derive versions list from filesystem, version-scoped tags - VERSIONS now expands from versions/*.env via wildcard, so adding a new PHP version no longer requires updating the Makefile alongside ci.yml matrix. - Default IMAGE is now utopia-base-test:$(VERSION) so 'make all' produces three distinct tags instead of overwriting :latest each iteration. - 'make clean' iterates VERSIONS for the same reason. Co-Authored-By: Claude Opus 4.7 --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 86c1b50..ae107b7 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,10 @@ VERSION ?= 8.4 -IMAGE ?= utopia-base-test +IMAGE ?= utopia-base-test:$(VERSION) ENV_FILE := versions/$(VERSION).env -BUILD_ARGS := $(shell awk -F= '!/^\#/ && NF { printf "--build-arg %s ", $$1 }' $(ENV_FILE)) +VERSIONS := $(patsubst versions/%.env,%,$(wildcard versions/*.env)) + +BUILD_ARGS = $(shell awk -F= '!/^\#/ && NF { printf "--build-arg %s ", $$1 }' $(ENV_FILE)) .PHONY: build test all clean @@ -14,9 +16,7 @@ test: build container-structure-test test --image $(IMAGE) --config tests.yaml all: - $(MAKE) build VERSION=8.3 - $(MAKE) build VERSION=8.4 - $(MAKE) build VERSION=8.5 + @for v in $(VERSIONS); do $(MAKE) build VERSION=$$v || exit $$?; done clean: - docker rmi $(IMAGE) 2>/dev/null || true + @for v in $(VERSIONS); do docker rmi utopia-base-test:$$v 2>/dev/null || true; done