Skip to content

Commit

Permalink
ci: conditional php version per branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Jan 17, 2025
1 parent 6381de4 commit fe4a7e3
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/matrix_includes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[
{
"runs_on": "ubuntu-latest",
"runOn":"master",
"php_version":"8.2",
"php_unit_version": "phpunit:11.*"
},
{
"runs_on": "ubuntu-latest",
"runOn":"master",
"php_version":"8.3",
"php_unit_version": "phpunit:11.*"
},
{
"runs_on": "ubuntu-latest",
"runOn":"13.x",
"php_version":"8.2",
"php_unit_version": "phpunit:11.*"
},
{
"runs_on": "ubuntu-latest",
"runOn":"13.x",
"php_version":"8.3",
"php_unit_version": "phpunit:11.*"
},
{
"runs_on": "ubuntu-latest",
"runOn":"8.x",
"php_version":"8.1",
"php_unit_version": "phpunit:10.*"
},
{
"runs_on": "ubuntu-latest",
"runOn":"8.x",
"php_version":"8.2",
"php_unit_version": "phpunit:10.*"
}
]
26 changes: 20 additions & 6 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,27 @@ permissions:
contents: read

jobs:
tests:
matrix_prep:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- id: set-matrix
run: |
branchName=$(echo '${{ github.ref }}' | sed 's,refs/heads/,,g')
matrix=$(jq --arg branchName "$branchName" 'map(
. | select((.runOn==$branchName) or (.runOn=="always"))
)' matrix_includes.json)
echo "matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT
tests:
needs: matrix_prep
runs-on: ${{ matrix.runs_on }}
strategy:
fail-fast: true
matrix:
php: [ 8.1, 8.2 ]
name: PHP ${{ matrix.php }}
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
name: PHP ${{ matrix.php_version }}
timeout-minutes: 10
steps:
- name: Checkout code
Expand All @@ -26,10 +40,10 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
php-version: ${{ matrix.php_version }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
coverage: xdebug
tools: phpunit:10.*
tools: ${{ matrix.php_unit_version }}

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress
Expand Down

0 comments on commit fe4a7e3

Please sign in to comment.