Files
FOSSBilling/.github/workflows/php-build-test.yml
T
Adam Daley f43e07cb64 Add CI job summaries and GHCR package cleanup workflow (#3567)
* Add GHCR package cleanup workflow

* Add job summaries to CI workflows

* Add create-release workflow; update release-docker

* Improve auto-cs-fix workflow: caching and summary

* Use GHCR build-cache image and mirror manifests

* Remove prepare-application-assets action

* Standardize workflow step names and cache image
2026-05-16 17:57:49 +01:00

102 lines
3.4 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: 'Set Registry Cache Image'
run: echo "CACHE_IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}-build-cache" >> "${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'
id: build_read_cache
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=${{ env.CACHE_IMAGE }}:cache-ci-${{ matrix.php }}
context: .
load: true
tags: |
fossbilling:test-${{ matrix.php }}
target: test
- name: 'Build Docker Test Image'
id: build_write_cache
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=${{ env.CACHE_IMAGE }}:cache-ci-${{ matrix.php }}
cache-to: type=registry,ref=${{ env.CACHE_IMAGE }}:cache-ci-${{ matrix.php }},mode=max
context: .
load: true
tags: |
fossbilling:test-${{ matrix.php }}
target: test
- name: 'PHPStan'
id: 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'
id: phpunit
run: |
docker run --rm \
--env APP_ENV=test \
fossbilling:test-${{ matrix.php }} \
./src/vendor/bin/phpunit --configuration phpunit.xml.dist
- name: 'Write Job Summary'
if: always()
run: |
cat >> "${GITHUB_STEP_SUMMARY}" <<'EOF'
## PHP Build and Test
| Item | Value |
| --- | --- |
| PHP version | `${{ matrix.php }}` |
| Test image | `fossbilling:test-${{ matrix.php }}` |
| Registry cache | `${{ env.CACHE_IMAGE }}:cache-ci-${{ matrix.php }}` |
| Cache mode | `${{ inputs.write-cache && 'read/write' || 'read-only' }}` |
| Docker build | `${{ inputs.write-cache && steps.build_write_cache.outcome || steps.build_read_cache.outcome }}` |
| PHPStan | `${{ steps.phpstan.outcome }}` |
| PHPUnit | `${{ steps.phpunit.outcome }}` |
EOF