-
-
Notifications
You must be signed in to change notification settings - Fork 92
62 lines (57 loc) · 2.23 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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