Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Jan 26, 2024
1 parent a4ba5a2 commit 96eb8df
Showing 1 changed file with 28 additions and 16 deletions.
44 changes: 28 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,44 @@ jobs:
coverage: xdebug

steps:
- uses: actions/checkout@v4
- run: echo "IMAGE=${{ env.REGISTRY }}/${{ github.repository }}/php${{ matrix.php }}" >> $GITHUB_ENV
- run: echo "TAG=${{ hashFiles(format('.docker/php{0}.Dockerfile', matrix.php)) }}" >> $GITHUB_ENV
- uses: docker/login-action@v3
- 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 }}
- run: |
docker pull ${{ env.IMAGE }}:${{ env.TAG }}
- name: Pull image
run: docker pull ${{ env.IMAGE }}:${{ env.TAG }}
continue-on-error: true
id: pull
- run: |
docker compose build php${{ matrix.php }}
docker tag ${{ github.event.repository.name }}-php${{ matrix.php }} ${{ env.IMAGE }}:${{ env.TAG }}
- 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'
- uses: actions/cache@v4
with:
path: ~/.cache/composer/files
key: php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
- run: docker compose -f docker-compose.ci.yml run --rm php${{ matrix.php }} composer update --no-interaction --no-progress --prefer-dist --prefer-${{ matrix.release }}
- run: docker compose -f docker-compose.ci.yml run --rm php${{ matrix.php }} vendor/bin/phpunit ${{ env.COVERAGE }}
- 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' || '' }}
- uses: codecov/codecov-action@v3
- name: Upload code coverage
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: matrix.coverage == 'xdebug' && env.CODECOV_TOKEN

0 comments on commit 96eb8df

Please sign in to comment.