dishplanner/.forgejo/workflows/ci.yml

101 lines
3.2 KiB
YAML
Raw Normal View History

2026-08-17 13:30:49 +02:00
name: CI
on:
push:
branches: ['release/*']
pull_request:
branches: [main, 'release/*']
jobs:
ci-image:
runs-on: docker
container:
image: catthehacker/ubuntu:act-latest
outputs:
tag: ${{ steps.meta.outputs.tag }}
steps:
- uses: https://data.forgejo.org/actions/checkout@v4
- name: Set up Docker Buildx
uses: https://data.forgejo.org/docker/setup-buildx-action@v3
- name: Login to Forgejo Registry
uses: https://data.forgejo.org/docker/login-action@v3
with:
registry: forge.lvl0.xyz
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Compute image tag from lockfile
id: meta
run: |
HASH="$(sha256sum composer.lock | cut -c1-12)"
echo "tag=php8.3-${HASH}" >> "$GITHUB_OUTPUT"
- name: Check whether image already exists
id: exists
run: |
set -euo pipefail
TOKEN="$(curl -sf "https://forge.lvl0.xyz/v2/token?service=container_registry&scope=repository:lvl0/dishplanner-ci:pull" | grep -o '"token":"[^"]*"' | head -n1 | cut -d'"' -f4)"
if [ -z "$TOKEN" ]; then
echo "Registry token fetch failed; cannot check for an existing image." >&2
exit 1
fi
CODE="$(curl -s -o /dev/null -w '%{http_code}' \
-H "Authorization: Bearer $TOKEN" \
-H 'Accept: application/vnd.oci.image.index.v1+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.docker.distribution.manifest.v2+json' \
"https://forge.lvl0.xyz/v2/lvl0/dishplanner-ci/manifests/${{ steps.meta.outputs.tag }}")"
if [ "$CODE" = "200" ]; then
echo "found=true" >> "$GITHUB_OUTPUT"
else
echo "found=false" >> "$GITHUB_OUTPUT"
fi
- name: Build and push CI image
if: steps.exists.outputs.found == 'false'
uses: https://data.forgejo.org/docker/build-push-action@v5
with:
context: .
file: docker/build/Dockerfile.ci
push: true
tags: forge.lvl0.xyz/lvl0/dishplanner-ci:${{ steps.meta.outputs.tag }}
cache-from: type=registry,ref=forge.lvl0.xyz/lvl0/dishplanner-ci:buildcache
cache-to: type=registry,ref=forge.lvl0.xyz/lvl0/dishplanner-ci:buildcache,mode=max
2026-08-17 13:30:49 +02:00
ci:
needs: ci-image
2026-08-17 13:30:49 +02:00
runs-on: docker
container:
image: forge.lvl0.xyz/lvl0/dishplanner-ci:${{ needs.ci-image.outputs.tag }}
2026-08-17 13:30:49 +02:00
steps:
- uses: https://data.forgejo.org/actions/checkout@v4
- name: Prepare environment
run: cp .env.testing .env
- name: Restore dependencies
run: |
cp -a /opt/deps/vendor ./vendor
composer install --no-interaction --no-progress
2026-08-17 13:30:49 +02:00
- name: Lint
run: vendor/bin/pint --test
- name: Static analysis
run: vendor/bin/phpstan analyse --memory-limit=1G
- name: Tests
run: vendor/bin/pest
- name: Install frontend dependencies
run: npm ci
- name: Install Playwright browser
run: npx playwright install --with-deps chromium
- name: Build frontend assets
run: npm run build
- name: Browser tests
run: vendor/bin/pest tests/Browser