Files
FOSSBilling/.github/workflows/php-build-test.yml
T
Adam Daley 1d58543600 Extract live tests into reusable Docker Compose workflow (#3565)
* Extract live tests into reusable workflow

* Use Docker Compose for live tests

* Normalize CI job names
2026-05-16 15:46:33 +01:00

82 lines
2.6 KiB
YAML

name: PHP Build and Test
on:
workflow_call:
inputs:
write-cache:
required: true
type: boolean
jobs:
php-build-test:
name: 'PHP Build and Test (${{ matrix.php }})'
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
php: ['8.3', '8.4', '8.5']
fail-fast: true
steps:
- name: 'Checkout Repository'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
persist-credentials: false
- name: 'Lowercase github.repository'
run: |
echo "IMAGE_NAME=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
- name: 'Login to GitHub Container Registry'
if: inputs.write-cache
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: 'Set up Docker Buildx'
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
- name: 'Build Docker Test Image'
if: ${{ !inputs.write-cache }}
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
build-args: |
PHP_VERSION=${{ matrix.php }}
INSTALL_TRANSLATIONS=false
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-ci-${{ matrix.php }}
context: .
load: true
tags: |
fossbilling:test-${{ matrix.php }}
target: test
- name: 'Build Docker Test Image'
if: inputs.write-cache
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
with:
build-args: |
PHP_VERSION=${{ matrix.php }}
INSTALL_TRANSLATIONS=false
cache-from: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-ci-${{ matrix.php }}
cache-to: type=registry,ref=ghcr.io/${{ env.IMAGE_NAME }}:cache-ci-${{ matrix.php }},mode=max
context: .
load: true
tags: |
fossbilling:test-${{ matrix.php }}
target: test
- name: 'PHPStan'
run: |
docker run --rm \
--env APP_ENV=test \
fossbilling:test-${{ matrix.php }} \
./src/vendor/bin/phpstan analyse --configuration phpstan.neon --memory-limit=512M
- name: 'PHPUnit'
run: |
docker run --rm \
--env APP_ENV=test \
fossbilling:test-${{ matrix.php }} \
./src/vendor/bin/phpunit --configuration phpunit.xml.dist