Skip to content

Commit

Permalink
ci: add testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed Apr 3, 2024
1 parent dbe6106 commit 54d145f
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,89 @@ env:
name: 🚀 Build docker images with latest tag

jobs:
test:
strategy:
fail-fast: false
matrix:
os_name: ["alpine"]
php_version: ["8.1", "8.2"]
php_type: ["fpm", "cli", "supervisord"]
builder: [{arch: "amd64", os: "ubuntu-latest"}]
runs-on: ${{ matrix.builder.os }}
steps:

- name: 🌎 Set environment variables
run: |
php_version="${{ matrix.php_version }}"
tag="${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-${{ matrix.builder.arch }}"
php_version_slug="${php_version//./}"
target="php-${php_version_slug}-${{ matrix.php_type }}-${{ matrix.os_name }}"
echo "TARGET=${target}" >> $GITHUB_ENV
echo "PLATFORM_CACHE_TAG=${tag}" >> $GITHUB_ENV
- name: 📦 Check out the codebase
uses: actions/checkout@v4

- name: 🤖 Generate dist files
run: ansible-playbook src/playbook.yml -l ${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}

- name: 🛠️ Setup docker QEMU
uses: docker/setup-qemu-action@v3

- name: 🛠️ Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: "--debug"

- name: 🔑 Login to docker-hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: 🔑 Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: 🐳 Extract docker meta data
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DOCKER_NAMESPACE }}
${{ env.GHCR_NAMESPACE }}
tags: |
type=raw,event=branch,value=latest
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
flavor: |
latest=false
prefix=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}-
- name: 🧪 Bake image for testing
uses: docker/build-push-action@v5
with:
context: ./dist/base/${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }
platforms: linux/${{ matrix.builder.arch }}
push: false
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
cache-to: type=gha,scope=build-${{ env.PLATFORM_CACHE_TAG }}
labels: ${{ steps.meta.outputs.labels }}

- name: 🧪 Test Docker image
if: ${{ inputs.image-platform == 'linux/amd64' }}
run: |
export IMAGE_TEMPLATE=${{ matrix.php_version }}-${{ matrix.php_type }}-${{ matrix.os_name }}
export IMAGE_TAG=${{ env.PLATFORM_CACHE_TAG }}
make test
build:
needs: test
strategy:
fail-fast: false
matrix:
Expand Down

0 comments on commit 54d145f

Please sign in to comment.