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..ae107b7 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +VERSION ?= 8.4 +IMAGE ?= utopia-base-test:$(VERSION) +ENV_FILE := versions/$(VERSION).env + +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 + +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: + @for v in $(VERSIONS); do $(MAKE) build VERSION=$$v || exit $$?; done + +clean: + @for v in $(VERSIONS); do docker rmi utopia-base-test:$$v 2>/dev/null || true; done 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`.