Skip to content

ci

ci #101

Workflow file for this run

name: CI
on: [ push, pull_request ]
env:
REGISTRY: ghcr.io
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: [ 8.3, 8.2, 8.1 ]
release: [ stable, lowest ]
include:
- php: 8.3
release: stable
coverage: xdebug
steps:
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ~/.cache/composer/files
key: php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- name: Check out code
uses: actions/checkout@v4
- name: Set environment variables
run: |
echo "CONTAINER=php${{ matrix.php }}" >> $GITHUB_ENV
echo "IMAGE=${{ env.REGISTRY }}/${{ github.repository }}/php${{ matrix.php }}" >> $GITHUB_ENV
echo "TAG=${{ hashFiles(format('.docker/php{0}.Dockerfile', matrix.php)) }}" >> $GITHUB_ENV
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull image
run: docker pull ${{ env.IMAGE }}:${{ env.TAG }}
continue-on-error: true
id: pull
- name: Build and push image if not pulled
run: |
docker compose build ${{ env.CONTAINER }}
docker tag ${{ github.event.repository.name }}-${{ env.CONTAINER }} ${{ env.IMAGE }}:${{ env.TAG }}
docker push ${{ env.IMAGE }}:${{ env.TAG }}
if: steps.pull.outcome != 'success'
- name: Install dependencies
run: |
docker compose -f docker-compose.ci.yml run --rm ${{ env.CONTAINER }} composer update --no-interaction \
--no-progress --prefer-dist --prefer-${{ matrix.release }}
- name: Run tests
run: docker compose -f docker-compose.ci.yml run --rm ${{ env.CONTAINER }} vendor/bin/phpunit ${{ env.COVERAGE }}
env:
COVERAGE: ${{ matrix.coverage == 'xdebug' && '--coverage-clover=coverage.xml' || '' }}
- name: Upload code coverage
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: matrix.coverage == 'xdebug' && env.CODECOV_TOKEN