diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 60c3dc9..27f8183 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -16,21 +16,43 @@ concurrency: cancel-in-progress: true jobs: + setup-phpunit-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.gen.outputs.matrix }} + steps: + - uses: actions/checkout@v6 + - id: gen + uses: galette/.github/actions/matrix-generator@main + with: + all-jobs: ${{ github.event_name != 'pull_request' && github.repository == 'galette-community/galette-oauth2' && (github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags')) }} + + setup-lint-matrix: + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.gen.outputs.matrix }} + steps: + - uses: actions/checkout@v6 + - id: gen + uses: galette/.github/actions/matrix-generator@main + with: + target: lint + all-jobs: ${{ github.event_name != 'pull_request' && github.repository == 'galette-community/galette-oauth2' && (github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags')) }} + lint: runs-on: ubuntu-latest - name: "Lint on PHP ${{ matrix.php-versions }}" + needs: setup-lint-matrix + name: "Lint on PHP ${{ matrix.php-version }}" strategy: - matrix: - php-versions: [ '8.2', '8.5' ] - coverage: [none] + matrix: ${{ fromJSON(needs.setup-lint-matrix.outputs.matrix) }} fail-fast: false steps: - name: PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php-version }} tools: composer coverage: ${{ matrix.coverage }} @@ -60,7 +82,7 @@ jobs: ../../vendor/bin/phpcs lib/ ./*.php - name: CS Fixer - if: matrix.php-versions == '8.2' + if: matrix.php-is-min run: | cd galette-core/galette/plugins/plugin-oauth2 ../../vendor/bin/php-cs-fixer check --show-progress=dots --verbose --diff @@ -82,30 +104,13 @@ jobs: unit-tests: runs-on: ubuntu-latest + needs: setup-phpunit-matrix strategy: - matrix: - include: - #always tests higher stable php version with lower db version - #enable coverage on higher stable php version with higher postrgesql version - #lower php version - - { php-version: "8.2", db-image: "mysql:5.7", coverage: none, always: false } - - { php-version: "8.2", db-image: "mysql:8.1", coverage: none, always: false } - - { php-version: "8.2", db-image: "mariadb:10.4", coverage: none, always: false } - - { php-version: "8.2", db-image: "mariadb:11", coverage: none, always: false } - - { php-version: "8.2", db-image: "postgres:11", coverage: none, always: false } - - { php-version: "8.2", db-image: "postgres:16", coverage: none, always: false } - #higher stable php version - - { php-version: "8.5", db-image: "mysql:5.7", coverage: none, always: true } - - { php-version: "8.5", db-image: "mysql:8.1", coverage: none, always: false } - - { php-version: "8.5", db-image: "mariadb:10.4", coverage: none, always: true } - - { php-version: "8.5", db-image: "mariadb:11", coverage: none, always: false } - - { php-version: "8.5", db-image: "postgres:11", coverage: none, always: true } - - { php-version: "8.5", db-image: "postgres:16", coverage: none, always: true } + matrix: ${{ fromJSON(needs.setup-phpunit-matrix.outputs.matrix) }} fail-fast: false env: - skip: ${{ matrix.always == false && (github.event_name == 'pull_request' || github.repository != 'galette/plugin-oauth2' || !(github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags'))) }} DB: ${{ matrix.db-image }} services: @@ -137,40 +142,34 @@ jobs: steps: - name: PHP - if: env.skip != 'true' uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-versions }} + php-version: ${{ matrix.php-version }} tools: composer, pecl coverage: ${{ matrix.coverage }} extensions: apcu ini-values: apc.enable_cli=1 - name: Show database version - if: env.skip != 'true' run: | docker exec ${{ job.services.db.id }} bash -c "if [[ -n \$(command -v psql) ]]; then psql --version; else if [[ -n \$(command -v mysql) ]]; then mysql --version; else mariadb --version; fi fi" - name: Build Galette - if: env.skip != 'true' uses: galette/.github/actions/build-galette@main with: php-version: ${{ matrix.php-version }} - name: Checkout plugin - if: env.skip != 'true' uses: actions/checkout@v6 with: path: galette-core/galette/plugins/plugin-oauth2 - name: Install plugin dependencies - if: env.skip != 'true' run: | cd galette-core/galette/plugins/plugin-oauth2 composer install --ignore-platform-reqs - name: Generate keys - if: env.skip != 'true' run: | cd galette-core/galette/plugins/plugin-oauth2/tests/config openssl genrsa -out private.key 2048 @@ -202,10 +201,9 @@ jobs: bin/console galette:install -v --dbtype=mysql --dbhost=127.0.0.1 --dbname=galette_tests --dbuser=galette_tests --dbpass=g@l3tte --admin=admin --password=admin --no-interaction -w bin/console galette:plugins:enable --all bin/console galette:plugins:list --enabled --complete - if: env.skip != 'true' && (startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb')) + if: startsWith(matrix.db-image, 'mysql') || startsWith(matrix.db-image, 'mariadb') - name: Unit tests - if: env.skip != 'true' run: | cd galette-core/galette/webroot DB=${{ env.DB }} php -S localhost:8888 ../plugins/plugin-oauth2/tests/router.php &