Skip to content

Commit

Permalink
[FEATURE] Compute matrix values
Browse files Browse the repository at this point in the history
  • Loading branch information
IchHabRecht committed Aug 3, 2024
1 parent 461191f commit be39baf
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 13 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/compute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ✏️ matrix

on: [ push, pull_request, workflow_call ]

env:
OS: '[ "ubuntu-latest" ]'
COVERAGE: '[ "~9.0.0", "~9.1.0", "~9.2.0", "~10.0.0", "~10.1.0" ]'
PHP: '[ "8.0", "8.1", "8.2", "8.3" ]'
EXCLUDE: '[ { "coverage": "~10.0.0", "php": "8.0" }, { "coverage": "~10.1.0", "php": "8.0" } ]'

jobs:
compute:
name: Compute outputs

runs-on: ubuntu-latest

outputs:
os: ${{ env.OS }}
php: ${{ env.PHP }}
coverage: ${{ env.COVERAGE }}
exclude: ${{ env.EXCLUDE }}

steps:
- name: Pseudo step
if: false
run: echo
44 changes: 31 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ name: 🏃 tests
on: [ push, pull_request, workflow_call ]

jobs:
test:
name: 'COVERAGE: ${{ matrix.coverage }} - PHP: ${{ matrix.php }}'
compute:
uses: ./.github/workflows/compute.yml

build:
name: 'Build COVERAGE: ${{ matrix.coverage }} - PHP: ${{ matrix.php }}'

needs: [ compute ]

strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest' ]
coverage: [ '~9.0.0', '~9.1.0', '~9.2.0', '~10.0.0', '~10.1.0' ]
php: [ '8.0', '8.1', '8.2', '8.3' ]
exclude:
- coverage: '~10.0.0'
php: '8.0'
- coverage: '~10.1.0'
php: '8.0'
os: ${{ fromJson(needs.compute.outputs.os) }}
coverage: ${{ fromJson(needs.compute.outputs.coverage) }}
php: ${{ fromJson(needs.compute.outputs.php) }}
exclude: ${{ fromJson(needs.compute.outputs.exclude) }}

runs-on: ${{ matrix.os }}

Expand All @@ -28,14 +29,20 @@ jobs:
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Store PHP code coverage version
id: version-cache
env:
COVERAGE: ${{ matrix.coverage }}
run: echo "version=${COVERAGE | tr -d -c 0-9}" >> $GITHUB_OUTPUT

- uses: actions/cache/restore@v4
id: restore-composer-cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ matrix.coverage }}-${{ matrix.php }}
key: ${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}
restore-keys: |
${{ runner.os }}-composer-${{ matrix.coverage }}-
${{ runner.os }}-composer-
${{ runner.os }}-${{ matrix.php }}-
${{ runner.os }}-
- name: Set up PHP Version ${{ matrix.php }}
uses: shivammathur/setup-php@v2
Expand Down Expand Up @@ -64,3 +71,14 @@ jobs:

- name: Lint PHP
run: php .Build/bin/parallel-lint --exclude .Build .

- name: Run PHPUnit
if: ${{ success() || failure() }}
run: .Build/bin/phpunit --log-junit .Log/log/junit_${{ steps.version-cache.outputs.version }}.xml --coverage-php .Log/coverage/coverage_${{ steps.version-cache.outputs.version }}.cov --coverage-filter src/ tests/

- name: Archive PHPUnit logs
uses: actions/upload-artifact@v4
with:
name: phpunit-logs-${{ runner.os }}-${{ matrix.php }}-${{ matrix.coverage }}
path: .Log/*
retention-days: 1

0 comments on commit be39baf

Please sign in to comment.