Skip to content

[CI] Rework tests php job, fix minimum-stability, add Symfony versions #2734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 2.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 78 additions & 54 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ on:
- 'src/**/*.md'
- 'ux.symfony.com/**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
coding-style-js:
name: JavaScript Coding Style
Expand Down Expand Up @@ -50,75 +54,95 @@ jobs:
echo "The Git workspace is clean. No changes detected."
fi
tests-php-components:
runs-on: ubuntu-latest
outputs:
components: ${{ steps.components.outputs.components }}
steps:
- uses: actions/checkout@v4

- id: components
run: |
components=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | jq -R -s -c 'split("\n")[:-1] | map(. | sub("^src/";"")) | sort')
echo "$components"
echo "components=$components" >> $GITHUB_OUTPUT
tests-php:
runs-on: ubuntu-latest
needs: tests-php-components
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.3', '8.4']
minimum-stability: ['stable', 'dev']
include:
- php-version: '8.1'
dependency-version: 'lowest'
- php-version: '8.3'
dependency-version: 'highest'
- php-version: '8.4'
dependency-version: 'highest'
component: ${{ fromJson(needs.tests-php-components.outputs.components )}}
exclude:
- php-version: '8.1'
minimum-stability: 'dev'
- php-version: '8.3'
minimum-stability: 'dev'
- component: Swup # has no tests
- component: Turbo # has its own workflow (test-turbo.yml)
- component: Typed # has no tests

config:
# Minimum supported PHP versions, LTS Symfony versions, with highest deps
- PHP_VERSION: '8.1'
SYMFONY_VERSION: '6.4.*'

# Minimum supported PHP versions, with highest and lowest deps
- PHP_VERSION: '8.1'
- PHP_VERSION: '8.1'
COMPOSER_FLAGS: --prefer-lowest
- PHP_VERSION: '8.2'
- PHP_VERSION: '8.3'
- PHP_VERSION: '8.4'

# Multiple PHP versions, major Symfony development versions
- PHP_VERSION: '8.1'
SYMFONY_VERSION: '6.*'
MINIMUM_STABILITY: dev

- PHP_VERSION: '8.2'
SYMFONY_VERSION: '7.*'
MINIMUM_STABILITY: dev

- PHP_VERSION: '8.3'
SYMFONY_VERSION: '7.*'
MINIMUM_STABILITY: dev

- PHP_VERSION: '8.4'
SYMFONY_VERSION: '7.*'
MINIMUM_STABILITY: dev

env:
SYMFONY_REQUIRE: ${{ matrix.config.SYMFONY_VERSION }}
steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
- name: Configure environment
run: |
echo COLUMNS=120 >> $GITHUB_ENV
echo COMPOSER_MIN_STAB='composer config minimum-stability ${{ matrix.config.MINIMUM_STABILITY || 'stable' }} --ansi' >> $GITHUB_ENV
echo COMPOSER_UP='composer update ${{ matrix.config.COMPOSER_FLAGS || '' }} --no-progress --no-interaction --ansi' >> $GITHUB_ENV
echo PHPUNIT='vendor/bin/simple-phpunit' >> $GITHUB_ENV
# Swup and Typed have no tests, Turbo has its own workflow file
PACKAGES=$(find src/ -mindepth 2 -type f -name composer.json -not -path "*/vendor/*" -printf '%h\n' | sed 's/^src\///' | grep -Ev "Swup|Turbo|Typed" | sort | tr '\n' ' ')
echo "Packages: $PACKAGES"
echo "PACKAGES=$PACKAGES" >> $GITHUB_ENV
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: flex

- name: Install root packages
uses: ramsey/composer-install@v3
with:
working-directory: ${{ github.workspace }}
dependency-versions: ${{ matrix.dependency-version }}
- name: Install root dependencies
run: composer install

- name: Build root packages
run: php .github/build-packages.php
working-directory: ${{ github.workspace }}

- name: Configure ${{ matrix.minimum-stability }} stability
if: ${{ matrix.minimum-stability }}
run: composer config minimum-stability ${{ matrix.minimum-stability }}
working-directory: "src/${{ matrix.component }}"

- name: Install ${{ matrix.component }} packages
uses: ramsey/composer-install@v3
with:
working-directory: "src/${{ matrix.component }}"
dependency-versions: ${{ matrix.dependency-version }}

- name: ${{ matrix.component }} Tests
working-directory: "src/${{ matrix.component }}"
run: vendor/bin/simple-phpunit
- name: Run packages tests
run: |
_run_task() {
local ok=0
local title="$1"
local start=$(date -u +%s)
OUTPUT=$(bash -xc "$2" 2>&1) || ok=$?
local end=$(date -u +%s)
if [[ $ok -ne 0 ]]; then
printf "\n%-70s%10s\n" $title $(($end-$start))s
echo "$OUTPUT"
echo "Job exited with: $ok"
echo -e "\n::error::KO $title\\n"
else
printf "::group::%-68s%10s\n" $title $(($end-$start))s
echo "$OUTPUT"
echo -e "\n\\e[32mOK\\e[0m $title\\n\\n::endgroup::"
fi
exit $ok
}
export -f _run_task
echo "$PACKAGES" | xargs -n1 | parallel -j +3 "_run_task {} '(cd src/{} && $COMPOSER_MIN_STAB && $COMPOSER_UP && $PHPUNIT)'"
tests-js:
runs-on: ubuntu-latest
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
"dev"
],
"require-dev": {
"symfony/filesystem": "^5.2|^6.0|^7.0",
"symfony/finder": "^5.4|^6.0|^7.0",
"php": ">=8.1",
"symfony/filesystem": "^7.0",
"symfony/finder": "^7.0",
"php-cs-fixer/shim": "^3.62"
}
}
Loading