Skip to content

Merge pull request #139 from GW2Treasures/ci/update-github-workflow-a… #50

Merge pull request #139 from GW2Treasures/ci/update-github-workflow-a…

Merge pull request #139 from GW2Treasures/ci/update-github-workflow-a… #50

Workflow file for this run

name: CI
on:
push:
branches: [ "master" ]
pull_request:
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions:
contents: read
pull-requests: write
jobs:
build:
name: Build / PHP ${{ matrix.php }}${{ matrix.phar && ' (phar)' || '' }}
runs-on: ubuntu-latest
continue-on-error: ${{ startsWith(matrix.php, '8.') }}
strategy:
fail-fast: false
matrix:
php:
- '7.2' # version used by legacy.gw2treasures.com
- '7.4' # latest 7.x
- '8.2' # stable 8
- '8.3' # stable 8
phar:
- false
include:
- php: '7.2'
phar: true
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: |
phar.readonly=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Build phar
if: matrix.phar
run: php build/build.php
- name: Run Tests
if: matrix.phar == false
run: vendor/bin/phpunit --configuration phpunit.xml --coverage-clover clover.xml
- name: Run Tests (phar)
if: matrix.phar
run: vendor/bin/phpunit --configuration phpunit.xml --bootstrap build/autoload.php
- name: Download base coverage
uses: dawidd6/action-download-artifact@v3
if: github.event_name == 'pull_request' && matrix.phar == false
continue-on-error: true
with:
branch: master
name: coverage-${{ matrix.php }}
path: ./coverage-base/
search_artifacts: true
workflow: .github/workflows/ci.yml
- name: Report coverage
if: github.event_name == 'pull_request' && matrix.phar == false
uses: lucassabreu/[email protected]
with:
base-file: ./coverage-base/clover.xml
file: ./clover.xml
with-chart: false
signature: PHP ${{ matrix.php }}
- name: Upload coverage
uses: actions/upload-artifact@v4
if: matrix.phar == false
with:
name: coverage-${{ matrix.php }}
path: ./clover.xml
- name: Upload phar
uses: actions/upload-artifact@v4
if: matrix.phar
with:
name: phar
path: |
./build/artifacts/gw2api.phar
./build/artifacts/gw2api.zip
success:
name: Success
needs: [build]
runs-on: ubuntu-latest
steps:
- run: echo "Success"