From c0c6e9545311b544afe3d5f7d91a865b4f42661a Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Thu, 18 Dec 2025 08:53:29 +0000 Subject: [PATCH 1/3] ci: Improve GH workflows --- .github/actions/setup-php-composer/action.yml | 48 +++++++++++++ .github/dependabot.yml | 2 +- .github/workflows/run-tests.yml | 11 ++- .github/workflows/static-analysis.yml | 72 +++++++++---------- README.md | 4 +- 5 files changed, 87 insertions(+), 50 deletions(-) create mode 100644 .github/actions/setup-php-composer/action.yml diff --git a/.github/actions/setup-php-composer/action.yml b/.github/actions/setup-php-composer/action.yml new file mode 100644 index 0000000..0bd7af9 --- /dev/null +++ b/.github/actions/setup-php-composer/action.yml @@ -0,0 +1,48 @@ +name: 'Setup PHP and Composer' +description: 'Setup PHP and install Composer dependencies with caching' + +inputs: + php-version: + description: 'PHP version to use' + required: false + default: '8.3' + coverage: + description: 'Coverage driver to use (none, xdebug, pcov)' + required: false + default: 'none' + stability: + description: 'Composer stability preference (prefer-stable, prefer-lowest)' + required: false + default: 'prefer-stable' + +runs: + using: 'composite' + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ inputs.php-version }} + coverage: ${{ inputs.coverage }} + + - name: Get Composer Cache Directory + id: composer-cache + shell: bash + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache Composer dependencies + uses: actions/cache@v5 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ inputs.stability }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + + - name: Install dependencies + shell: bash + run: | + if [ "${{ inputs.stability }}" = "prefer-lowest" ]; then + composer update --prefer-lowest --prefer-dist --no-interaction --no-progress + else + composer install --prefer-dist --no-interaction --no-progress + fi + diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 45efac9..852b924 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,7 +7,7 @@ updates: labels: - "dependencies" - "composer" - versioning-strategy: "widen" + versioning-strategy: "increase-if-necessary" open-pull-requests-limit: 5 - package-ecosystem: "github-actions" diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index e5d64d0..63d316d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -24,23 +24,20 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - name: Setup PHP - uses: shivammathur/setup-php@v2 + - name: Setup PHP and Composer + uses: ./.github/actions/setup-php-composer with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo coverage: pcov + stability: ${{ matrix.stability }} - name: Setup problem matchers run: | echo "::add-matcher::${{ runner.tool_cache }}/php.json" echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Install dependencies - run: composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - name: Execute tests with mutation if: ${{ matrix.os == 'ubuntu-latest' }} run: vendor/bin/pest --colors=always --mutate --parallel --min=80 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index c9fb08d..0038fba 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -16,31 +16,13 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.3 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo - - - name: Get Composer Cache Directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache Composer dependencies - uses: actions/cache@v4 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - name: Install dependencies - run: composer install --prefer-dist --no-interaction --no-progress + - name: Setup PHP and Composer + uses: ./.github/actions/setup-php-composer - name: Cache phpstan results - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: .phpstan-cache key: "result-cache-${{ github.run_id }}" # always write a new cache @@ -54,28 +36,38 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v5 + uses: actions/checkout@v6 - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.3 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + - name: Setup PHP and Composer + uses: ./.github/actions/setup-php-composer + + - name: Check type coverage + run: vendor/bin/pest --type-coverage --min=100 + + format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 - - name: Get Composer Cache Directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Setup PHP and Composer + uses: ./.github/actions/setup-php-composer - - name: Cache Composer dependencies - uses: actions/cache@v4 + - name: Cache rector results + uses: actions/cache@v5 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + path: /tmp/rector + key: "rector-cache-${{ github.run_id }}" # always write a new cache restore-keys: | - ${{ runner.os }}-composer- + rector-cache- - - name: Install dependencies - run: composer install --prefer-dist --no-interaction --no-progress + - name: Cache ecs results + uses: actions/cache@v5 + with: + path: /tmp/ecs + key: "ecs-cache-${{ github.run_id }}" # always write a new cache + restore-keys: | + ecs-cache- - - name: Check type coverage - run: vendor/bin/pest --type-coverage --min=100 + - name: Run format checks + run: composer format --no-progress-bar diff --git a/README.md b/README.md index be7685f..a4b7984 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ This package supports multiple JSON Schema specification versions with automatic ### Supported Versions -- **Draft-07** (2018) - Default version for maximum compatibility +- **Draft 2020-12** - (Default) Latest version with `prefixItems`, dynamic references, and format vocabularies - **Draft 2019-09** - Adds advanced features like `$defs`, `unevaluatedProperties`, `deprecated` -- **Draft 2020-12** - Latest version with `prefixItems`, dynamic references, and format vocabularies +- **Draft-07** (2018) - Legacy version for maximum compatibility ## Requirements From b4826186c0672516538ff9cd0ab331bb2e967682 Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Thu, 18 Dec 2025 09:00:40 +0000 Subject: [PATCH 2/3] add extensions --- .github/actions/setup-php-composer/action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/actions/setup-php-composer/action.yml b/.github/actions/setup-php-composer/action.yml index 0bd7af9..b1366da 100644 --- a/.github/actions/setup-php-composer/action.yml +++ b/.github/actions/setup-php-composer/action.yml @@ -14,6 +14,10 @@ inputs: description: 'Composer stability preference (prefer-stable, prefer-lowest)' required: false default: 'prefer-stable' + extensions: + description: 'PHP extensions to install' + required: false + default: 'dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo' runs: using: 'composite' @@ -23,6 +27,7 @@ runs: with: php-version: ${{ inputs.php-version }} coverage: ${{ inputs.coverage }} + extensions: ${{ inputs.extensions }} - name: Get Composer Cache Directory id: composer-cache From 20471f0cb4f37edc570b558bf9440ad236b22a6b Mon Sep 17 00:00:00 2001 From: Sean Tymon Date: Thu, 18 Dec 2025 09:22:19 +0000 Subject: [PATCH 3/3] improve cache --- .github/actions/setup-php-composer/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup-php-composer/action.yml b/.github/actions/setup-php-composer/action.yml index b1366da..39cf403 100644 --- a/.github/actions/setup-php-composer/action.yml +++ b/.github/actions/setup-php-composer/action.yml @@ -40,7 +40,7 @@ runs: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ inputs.stability }}-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-composer- + ${{ runner.os }}-composer-${{ inputs.stability }}- - name: Install dependencies shell: bash