Skip to content

Commit 9df685f

Browse files
committed
Separate build and test stages (with bake)
1 parent 0e39d90 commit 9df685f

File tree

10 files changed

+1261
-120
lines changed

10 files changed

+1261
-120
lines changed

.github/workflows/workflow.yml

Lines changed: 17 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,23 @@ jobs:
1414
build_test_maybe_release:
1515
strategy:
1616
matrix:
17-
include:
18-
- variant: 'cli'
19-
php_version: '8.1'
20-
- variant: 'apache'
21-
php_version: '8.1'
22-
- variant: 'fpm'
23-
php_version: '8.1'
24-
- variant: 'cli'
25-
php_version: '8.0'
26-
- variant: 'apache'
27-
php_version: '8.0'
28-
- variant: 'fpm'
29-
php_version: '8.0'
30-
- variant: 'cli'
31-
php_version: '7.4'
32-
- variant: 'apache'
33-
php_version: '7.4'
34-
- variant: 'fpm'
35-
php_version: '7.4'
36-
- variant: 'cli'
37-
php_version: '7.3'
38-
- variant: 'apache'
39-
php_version: '7.3'
40-
- variant: 'fpm'
41-
php_version: '7.3'
42-
- variant: 'cli'
43-
php_version: '7.2'
44-
- variant: 'apache'
45-
php_version: '7.2'
46-
- variant: 'fpm'
47-
php_version: '7.2'
17+
variant: ['cli','apache','fpm']
18+
php_version: ['8.1','8.0','7.4', '7.3','7.2']
4819
runs-on: ubuntu-latest
4920
steps:
5021
- name: Set up QEMU
5122
uses: docker/setup-qemu-action@v1
5223
- name: Set up Docker Buildx
5324
uses: docker/setup-buildx-action@v1
54-
- uses: actions/checkout@v1
55-
- name: Build and test
25+
- name: Checkout
26+
uses: actions/checkout@v1
27+
- name: Build
5628
run: |
57-
PLATFORM="linux/amd64" PHP_VERSION="${{ matrix.php_version }}" BRANCH="v4" VARIANT="${{ matrix.variant }}" ./build-and-test.sh
58-
PUSH=0 PLATFORM="linux/arm64" PHP_VERSION="${{ matrix.php_version }}" BRANCH="v4" VARIANT="${{ matrix.variant }}" ./build-load-or-push.sh
59-
docker images | grep thecodingmachine/php
29+
PHP_VERSION="${{ matrix.php_version }}"
30+
docker buildx bake --load \
31+
--platform=${PLATFORM:$(uname -p)}} \
32+
php${PHP_VERSION//.}-${{ matrix.variant }}
33+
docker images --filter=reference=thecodingmachine/php
6034
- name: Login to DockerHub
6135
# Merge ~ push.
6236
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
@@ -68,20 +42,10 @@ jobs:
6842
# Merge ~ push.
6943
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }}
7044
run: |
71-
BRANCH_VARIANT=`echo "${{ matrix.variant }}" | sed 's/\./-/g'`
72-
PUSH=1 PLATFORM="linux/amd64,linux/arm64" PHP_VERSION="${{ matrix.php_version }}" BRANCH="v4" VARIANT="${{ matrix.variant }}" ./build-load-or-push.sh
73-
# Let's also tag PHP patch releases
74-
PHP_PATCH_VERSION=`docker run --rm thecodingmachine/php:${{ matrix.php_version }}-v4-slim-${BRANCH_VARIANT} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
75-
echo "Tagging patch release $PHP_PATCH_VERSION"
76-
docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-slim-${BRANCH_VARIANT} thecodingmachine/php:${PHP_PATCH_VERSION}-v4-slim-${BRANCH_VARIANT}
77-
docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT} thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}
78-
docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node10 thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node10
79-
docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node12 thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node12
80-
docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node14 thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node14
81-
docker tag thecodingmachine/php:${{ matrix.php_version }}-v4-${BRANCH_VARIANT}-node16 thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node16
82-
docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-slim-${BRANCH_VARIANT}
83-
docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}
84-
docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node10
85-
docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node12
86-
docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node14
87-
docker push thecodingmachine/php:${PHP_PATCH_VERSION}-v4-${BRANCH_VARIANT}-node16
45+
PHP_VERSION="${{ matrix.php_version }}"
46+
PHP_PATCH_VERSION=`docker run --rm thecodingmachine/php:${PHP_VERSION}-v4-slim-${BRANCH_VARIANT} php -v | head -n1 | grep -P '\d+\.\d+\.\d+' -o | head -n1`
47+
TAG=${PHP_PATCH_VERSION} docker buildx bake --push \
48+
--cache-from=type=local,src=/tmp/buildx-cache \
49+
--cache-to=type=local,dest=/tmp/buildx-cache \
50+
--platform=${PLATFORM:$(uname -p)}} \
51+
php${PHP_VERSION//.}-${{ matrix.variant }}

Makefile

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@ blueprint: ## Generate all blueprints file
22
@if ! type orbit >/dev/null 2>&1; then echo "Missing orbit dependency, please install from https://github.com/gulien/orbit/"; exit 1; fi
33
orbit run generate
44

5-
test-latest: test-8.0 ## Test the latest build only
5+
test-latest: test-8.1 ## Test the latest build only
66

77
_test-prerequisites: blueprint
88
docker pull ubuntu:20.04
99

10-
test-quick: _test-prerequisites ## Test 8.0 and 8.1 quickly
11-
PLATFORM=$$(uname -p) PHP_VERSION=8.0 BRANCH=v4 VARIANT=cli ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1)
12-
PLATFORM=$$(uname -p) PHP_VERSION=8.1 BRANCH=v4 VARIANT=cli ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1)
13-
notify-send -u critical "Tests passed with success"
10+
test-quick: ## Test 8.0 and 8.1 quickly
11+
PHP_VERSION=8.0 VARIANT=cli $(MAKE) _test-version
12+
PHP_VERSION=8.1 VARIANT=cli $(MAKE) _test-version
1413

15-
test-8.1: _test-prerequisites ## Test php8.1 build only
16-
docker pull ubuntu:20.04
17-
PLATFORM=$$(uname -p) PHP_VERSION=8.1 BRANCH=v4 VARIANT=cli ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1)
18-
PLATFORM=$$(uname -p) PHP_VERSION=8.1 BRANCH=v4 VARIANT=apache ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1)
19-
notify-send -u critical "Tests passed with success"
14+
test-8.1: ## Test php8.1 build only
15+
PHP_VERSION=8.1 VARIANT=cli $(MAKE) _test-version
16+
PHP_VERSION=8.1 VARIANT=apache $(MAKE) _test-version
2017

21-
test-8.0: _test-prerequisites ## Test php8.0 build only
22-
docker pull ubuntu:20.04
23-
PLATFORM=$$(uname -p) PHP_VERSION=8.0 BRANCH=v4 VARIANT=cli ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1)
24-
PLATFORM=$$(uname -p) PHP_VERSION=8.0 BRANCH=v4 VARIANT=apache ./build-and-test.sh || (notify-send -u critical "Tests failed" && exit 1)
25-
notify-send -u critical "Tests passed with success"
18+
test-8.0: ## Test php8.0 build only
19+
PHP_VERSION=8.0 VARIANT=cli $(MAKE) _test-version
20+
PHP_VERSION=8.0 VARIANT=apache $(MAKE) _test-version
21+
22+
_test-version: _test-prerequisites ## Test php build for VERSION="" and VARIANT=""
23+
docker buildx bake --load \
24+
--platform=${PLATFORM:$(uname -p)}} \
25+
php${VERSION//.}-cli
26+
PHP_VERSION="$(VERSION)" BRANCH=v4 VARIANT=cli ./test-image.sh || (notify-send -u critical "Tests failed ($(VERSION)-$(VARIANT))" && exit 1)
27+
notify-send -u critical "Tests passed with success ($(VERSION)-$(VARIANT))"
2628

2729
clean: ## Clean dangles image after build
30+
rm -rf /tmp/buildx-cache

build-load-or-push.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)