88 lines
2.3 KiB
YAML
88 lines
2.3 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
env:
|
|
REGISTRY: git.arthurerlich.de
|
|
|
|
jobs:
|
|
build-dev:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# type=gha depends on act_runner's internal cache proxy, which is unreachable
|
|
# from job containers on this runner (dial tcp ... i/o timeout). Use the
|
|
# registry cache backend instead, same as docker-publish.yml.
|
|
- name: Log in to Gitea registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ gitea.actor }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
- name: Build dev image (PHP 8.4 + composer deps)
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: Dockerfile.dev
|
|
target: dev
|
|
outputs: type=docker,dest=/tmp/graph-dev.tar
|
|
tags: graph-dev:ci
|
|
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev
|
|
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ gitea.repository }}:buildcache-dev,mode=max
|
|
|
|
- name: Upload dev image
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: graph-dev-image
|
|
path: /tmp/graph-dev.tar
|
|
retention-days: 1
|
|
build-prod:
|
|
needs: build-dev
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build prod image (final target)
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
file: Dockerfile
|
|
target: final
|
|
push: false
|
|
|
|
test:
|
|
needs: build-dev
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download dev image
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: graph-dev-image
|
|
path: /tmp
|
|
|
|
- name: Load dev image
|
|
run: docker load --input /tmp/graph-dev.tar
|
|
|
|
- name: Run PHPUnit
|
|
run: docker run --rm graph-dev:ci vendor/bin/phpunit --testdox
|
|
|
|
- name: Run PHPStan
|
|
run: docker run --rm graph-dev:ci composer phpstan
|