diff --git a/.github/actions/setup-php-composer/action.yml b/.github/actions/setup-php-composer/action.yml new file mode 100644 index 0000000..39cf403 --- /dev/null +++ b/.github/actions/setup-php-composer/action.yml @@ -0,0 +1,53 @@ +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' + 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' + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ inputs.php-version }} + coverage: ${{ inputs.coverage }} + extensions: ${{ inputs.extensions }} + + - 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-${{ inputs.stability }}- + + - 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 6771a8a..642816d 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -26,21 +26,18 @@ jobs: - name: Checkout code 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 33657b1..0038fba 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -18,26 +18,8 @@ jobs: - name: Checkout code 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@v5 - 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@v5 @@ -56,26 +38,36 @@ jobs: - name: Checkout code 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: Get Composer Cache Directory - id: composer-cache - run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + - name: Check type coverage + run: vendor/bin/pest --type-coverage --min=100 - - name: Cache Composer dependencies + format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Setup PHP and Composer + uses: ./.github/actions/setup-php-composer + + - 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