Skip to content

Docker Test

Docker Test #228

Workflow file for this run

name: Docker Test
on:
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch
workflow_dispatch:
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull_request
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- main
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
push:
branches:
- main
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
# pull_request:
# See: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
- cron: "30 8 * * *" # run at 8:30 AM UTC
jobs:
bats:
name: Bats Testing
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Run bats
run: docker run -v "$PWD/docker/:/var/www" bats/bats:latest /var/www/tests/bats
hadolint:
name: hadolint
runs-on: ubuntu-24.04
permissions:
contents: read
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Pixelfed
uses: hadolint/[email protected]
with:
dockerfile: docker/Dockerfile
config: docker/.hadolint.yaml
failure-threshold: error
pixelfed:
name: pixelfed
runs-on: ubuntu-24.04
strategy:
fail-fast: false
# See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
matrix:
php_version:
- 8.3
- 8.4
pixelfed_branch:
- staging
- dev
debian_release:
- bookworm
php_base:
- apache
- fpm
target_runtime:
- apache
- nginx
# See: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#excluding-matrix-configurations
# See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixexclude
exclude:
# targeting [apache] runtime with [fpm] base type doesn't make sense
- target_runtime: apache
php_base: fpm
# targeting [nginx] runtime with [apache] base type doesn't make sense
- target_runtime: nginx
php_base: apache
# See: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-and-the-default-behavior
concurrency:
group: pixelfed-${{ github.ref }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.target_runtime }}-${{ matrix.pixelfed_branch }}
cancel-in-progress: true
permissions:
contents: read
packages: write
steps:
# checout this repo
- name: Checkout Code
uses: actions/checkout@v4
# checkout pixelfed source code into src/
- name: Checkout pixelfed/pixelfed
uses: actions/checkout@v4
with:
repository: "pixelfed/pixelfed"
ref: "${{ matrix.pixelfed_branch }}"
path: "src/"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
id: buildx
# See: https://github.com/docker/login-action?tab=readme-ov-file#github-container-registry
- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
uses: docker/metadata-action@v5
id: meta
with:
images: |
name=ghcr.io/${{ github.repository }},enable=true
flavor: |
suffix=-${{ matrix.pixelfed_branch }}-${{ matrix.target_runtime }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
tags: |
# schedule
type=schedule,pattern=nightly
type=schedule,pattern=nightly-{{ date 'YYYY-MM-DD' tz='UTC' }}
# default behavior
type=ref,event=branch,prefix=branch/
type=ref,event=pr,prefix=pr/
- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: docker/Dockerfile
target: ${{ matrix.target_runtime }}-runtime
platforms: linux/amd64,linux/arm64
builder: ${{ steps.buildx.outputs.name }}
tags: ${{ steps.meta.outputs.tags }}
annotations: ${{ steps.meta.outputs.annotations }}
push: true
provenance: false # https://github.com/docker/build-push-action/issues/894#issuecomment-1785937908
build-args: |
PHP_VERSION=${{ matrix.php_version }}
PHP_BASE_TYPE=${{ matrix.php_base }}
PHP_DEBIAN_RELEASE=${{ matrix.debian_release }}
cache-from: |
type=gha,scope=pixelfed/branch/main/${{ matrix.target_runtime }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
type=gha,scope=pixelfed/branch/${{ github.ref_name }}/${{ matrix.target_runtime }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
cache-to: |
type=gha,mode=max,ignore-error=true,scope=pixelfed/branch/${{ github.ref_name }}/${{ matrix.target_runtime }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
- name: Setup
run: docker/tests/setup.sh
env:
CI: true
DOCKER_APP_PHP_VERSION: "${{ matrix.php_version }}"
DOCKER_APP_TAG: "${{ steps.meta.outputs.version }}"
# goss validate the image
#
# See: https://github.com/goss-org/goss
- uses: e1himself/goss-installation-action@v1
with:
version: "v0.4.9"
- name: Execute Goss tests
working-directory: docker/
run: tests/goss.sh
env:
TAGS: "${{ steps.meta.outputs.tags }}"
DOCKER_APP_PHP_VERSION: ${{ matrix.php_version }}
PHP_BASE_TYPE: ${{ matrix.php_base }}
- name: "Setup NodeJS"
uses: actions/setup-node@v4
with:
cache: "npm"
cache-dependency-path: "docker/package-lock.json"
- name: Run E2E tests
run: docker/tests/e2e.sh
env:
CI: true
DOCKER_APP_TAG: "${{ steps.meta.outputs.version }}"
- if: always()
name: Show docker compose config
run: docker compose config
- if: always()
name: Show docker compose logs (web)
run: docker compose logs web
- if: always()
name: Show docker compose logs (worker)
run: docker compose logs worker
- if: always()
name: Show docker compose logs (cron)
run: docker compose logs cron
- if: always()
name: Show docker compose logs (proxy)
run: docker compose logs proxy proxy-acme
- if: always()
name: Show docker compose logs (db)
run: docker compose logs db
- if: always()
name: Show docker compose logs (redis)
run: docker compose logs redis
- if: always()
name: Show docker compose logs (combined)
run: docker compose logs
- if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report-${{ matrix.pixelfed_branch }}-${{ matrix.target_runtime }}-${{ matrix.php_base }}-${{ matrix.php_version }}-${{ matrix.debian_release }}
path: test-results/
retention-days: 30