From 7ff605e0267aabe9d416180664fa055f34e5e411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=C3=ADn=20Ma=C5=A1ek?= Date: Mon, 1 Apr 2024 18:01:40 +1300 Subject: [PATCH 1/5] Wip --- .github/workflows/phpstan.yml | 26 ------------ .github/workflows/run-tests.yml | 50 ++++++++++++---------- .github/workflows/update-changelog.yml | 28 ------------ CHANGELOG.md | 59 -------------------------- composer.json | 21 +++------ phpstan-baseline.neon | 0 phpstan.neon.dist | 13 ------ phpunit.xml.dist | 33 +++----------- 8 files changed, 37 insertions(+), 193 deletions(-) delete mode 100644 .github/workflows/phpstan.yml delete mode 100644 .github/workflows/update-changelog.yml delete mode 100644 CHANGELOG.md delete mode 100644 phpstan-baseline.neon delete mode 100644 phpstan.neon.dist diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index 9d41c0c..0000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: PHPStan - -on: - push: - paths: - - '**.php' - - 'phpstan.neon.dist' - -jobs: - phpstan: - name: phpstan - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - coverage: none - - - name: Install composer dependencies - uses: ramsey/composer-install@v2 - - - name: Run PHPStan - run: ./vendor/bin/phpstan --error-format=github diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b96d396..619cc46 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,36 +1,37 @@ name: run-tests -on: - push: - branches: [main] - pull_request: - branches: [main] +on: [push, pull_request] jobs: - test-laravel-9: + test: runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: - os: [ubuntu-latest] - php: [8.1, 8.2] - laravel: ['9.*'] - phpunit: ['9.5.8'] - testbench: ['7.22.0'] - collision: ['6.4'] - stability: [prefer-lowest,prefer-stable] + os: [ ubuntu-latest ] + php: [ 8.3, 8.2, 8.1 ] + laravel: [ 11.*, 10.* ] + stability: [ prefer-lowest, prefer-stable ] + include: + - laravel: 11.* + testbench: 9.* + - laravel: 10.* + testbench: 8.* + exclude: + - laravel: 11.* + php: 8.1 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick coverage: none - name: Setup problem matchers @@ -40,24 +41,25 @@ jobs: - name: Install dependencies run: | - composer require "nunomaduro/collision:~${{ matrix.collision }}" "orchestra/testbench:~${{ matrix.testbench }}" "phpunit/phpunit:~${{ matrix.phpunit }}" --dev --no-interaction --no-update - composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests run: vendor/bin/phpunit --no-coverage - test-laravel-10: + + + test-laravel-9: runs-on: ${{ matrix.os }} strategy: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.1,8.2] - laravel: ['10.*'] - phpunit: ['10.0'] - testbench: ['8.0'] - collision: ['7.0.2'] + php: [8.1, 8.2] + laravel: ['9.*'] + phpunit: ['9.5.8'] + testbench: ['7.22.0'] + collision: ['6.4'] stability: [prefer-lowest,prefer-stable] name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} @@ -77,10 +79,12 @@ jobs: run: | echo "::add-matcher::${{ runner.tool_cache }}/php.json" echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + - name: Install dependencies run: | composer require "nunomaduro/collision:~${{ matrix.collision }}" "orchestra/testbench:~${{ matrix.testbench }}" "phpunit/phpunit:~${{ matrix.phpunit }}" --dev --no-interaction --no-update composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update composer update --${{ matrix.stability }} --prefer-dist --no-interaction + - name: Execute tests run: vendor/bin/phpunit --no-coverage diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml deleted file mode 100644 index b20f3b6..0000000 --- a/.github/workflows/update-changelog.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: "Update Changelog" - -on: - release: - types: [released] - -jobs: - update: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - ref: main - - - name: Update Changelog - uses: stefanzweifel/changelog-updater-action@v1 - with: - latest-version: ${{ github.event.release.name }} - release-notes: ${{ github.event.release.body }} - - - name: Commit updated CHANGELOG - uses: stefanzweifel/git-auto-commit-action@v4 - with: - branch: main - commit_message: Update CHANGELOG - file_pattern: CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 30768b3..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,59 +0,0 @@ -# Changelog - -All notable changes to `laravel-model-hashids` will be documented in this file. - -## 0.6.0 - 2023-11-25 - -### Breaking change - -The `updating` eloquent model event won't be fired when setting the `hash_id`. If you want to change this, you need to set `save_quietly` to false inside the config file. - -## 0.5.0 - 2023-02-16 - -### What's Changed - -- Laravel 10 Support by @sweptsquash in https://github.com/antoninmasek/laravel-model-hashids/pull/4 - -### New Contributors - -- @sweptsquash made their first contribution in https://github.com/antoninmasek/laravel-model-hashids/pull/4 - -**Full Changelog**: https://github.com/antoninmasek/laravel-model-hashids/compare/0.4.0...0.5.0 - -## 0.4.0 - 2022-07-27 - -### What's Changed - -- Possibility to regenerate hash id by @antoninmasek in https://github.com/antoninmasek/laravel-model-hashids/pull/3 - -**Full Changelog**: https://github.com/antoninmasek/laravel-model-hashids/compare/0.3.1...0.4.0 - -## 0.3.1 - 2022-07-23 - -- Rename service provider - -**Full Changelog**: https://github.com/antoninmasek/laravel-model-hashids/compare/0.3.0...0.3.1 - -## 0.3.0 - 2022-07-23 - -### What's Changed - -- Refactoring by @antoninmasek in https://github.com/antoninmasek/laravel-model-hashids/pull/2 - -**Full Changelog**: https://github.com/antoninmasek/laravel-model-hashids/compare/0.2.0...0.3.0 - -## 0.2.0 - 2022-07-20 - -### What's Changed - -- Work with just one column by @antoninmasek in https://github.com/antoninmasek/laravel-model-hashids/pull/1 - -### New Contributors - -- @antoninmasek made their first contribution in https://github.com/antoninmasek/laravel-model-hashids/pull/1 - -**Full Changelog**: https://github.com/antoninmasek/laravel-model-hashids/compare/0.1.0...0.2.0 - -## 0.1.0 - 2022-06-12 - -**Full Changelog**: https://github.com/antoninmasek/laravel-model-hashids/commits/0.1.0 diff --git a/composer.json b/composer.json index a21dbd4..8bcc91f 100644 --- a/composer.json +++ b/composer.json @@ -16,21 +16,15 @@ ], "homepage": "https://github.com/antoninmasek/laravel-model-hashids", "require": { - "php": "^8.1 || ^8.2", - "antoninmasek/laravel-hashids": "^0.2.0", - "illuminate/contracts": "^9.0 || ^10.0", + "php": "^8.1", + "antoninmasek/laravel-hashids": "^1.0.0", + "illuminate/contracts": "^10.0 || ^11.0", "spatie/laravel-package-tools": "^1.14.1" }, "require-dev": { - "ergebnis/composer-normalize": "^2.29", "laravel/pint": "^1.5", - "nunomaduro/collision": "^6.0 || ^7.0.2", - "nunomaduro/larastan": "^2.4.0", - "orchestra/testbench": "^7.0 || ^8.0", - "phpstan/extension-installer": "^1.2", - "phpstan/phpstan-deprecation-rules": "^1.1.1", - "phpstan/phpstan-phpunit": "^1.3.4", - "phpunit/phpunit": "^9.5 || ^10.0", + "orchestra/testbench": "^8.0 || ^9.0", + "phpunit/phpunit": "^10.0", "spatie/laravel-ray": "^1.32.2" }, "minimum-stability": "stable", @@ -46,10 +40,6 @@ } }, "config": { - "allow-plugins": { - "phpstan/extension-installer": true, - "ergebnis/composer-normalize": true - }, "sort-packages": true }, "extra": { @@ -63,7 +53,6 @@ } }, "scripts": { - "analyse": "vendor/bin/phpstan analyse", "test": "vendor/bin/phpunit --no-coverage", "test-coverage": "vendor/bin/phpunit --coverage" } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon deleted file mode 100644 index e69de29..0000000 diff --git a/phpstan.neon.dist b/phpstan.neon.dist deleted file mode 100644 index e005ac7..0000000 --- a/phpstan.neon.dist +++ /dev/null @@ -1,13 +0,0 @@ -includes: - - phpstan-baseline.neon - -parameters: - level: 4 - paths: - - src - - config - tmpDir: build/phpstan - checkOctaneCompatibility: true - checkModelProperties: true - checkMissingIterableValueType: false - diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 510f265..d2189c5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,40 +1,17 @@ - + - - ./tests + + tests/ - + ./src - - - - - - - - - + From 30ca391753c11354c20d7109a06636fceb07a64a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=C3=ADn=20Ma=C5=A1ek?= Date: Mon, 1 Apr 2024 18:02:50 +1300 Subject: [PATCH 2/5] Remove: Old workflow job --- .github/workflows/run-tests.yml | 42 --------------------------------- 1 file changed, 42 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 619cc46..c2ffa09 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -46,45 +46,3 @@ jobs: - name: Execute tests run: vendor/bin/phpunit --no-coverage - - - - test-laravel-9: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: true - matrix: - os: [ubuntu-latest] - php: [8.1, 8.2] - laravel: ['9.*'] - phpunit: ['9.5.8'] - testbench: ['7.22.0'] - collision: ['6.4'] - stability: [prefer-lowest,prefer-stable] - - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - 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: none - - - 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 require "nunomaduro/collision:~${{ matrix.collision }}" "orchestra/testbench:~${{ matrix.testbench }}" "phpunit/phpunit:~${{ matrix.phpunit }}" --dev --no-interaction --no-update - composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update - composer update --${{ matrix.stability }} --prefer-dist --no-interaction - - - name: Execute tests - run: vendor/bin/phpunit --no-coverage From 9f9718f0c52d45e2becd54100fad61b9275a0ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=C3=ADn=20Ma=C5=A1ek?= Date: Mon, 1 Apr 2024 18:04:02 +1300 Subject: [PATCH 3/5] Bump minimal PHPUnit version to 10.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8bcc91f..382d5b9 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "require-dev": { "laravel/pint": "^1.5", "orchestra/testbench": "^8.0 || ^9.0", - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^10.1", "spatie/laravel-ray": "^1.32.2" }, "minimum-stability": "stable", From 516a69df670c3b37b8650910c909bb80a75b0d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=C3=ADn=20Ma=C5=A1ek?= Date: Mon, 1 Apr 2024 18:06:11 +1300 Subject: [PATCH 4/5] Wip --- tests/GeneratesHashIdTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/GeneratesHashIdTest.php b/tests/GeneratesHashIdTest.php index ba46ca2..bb66684 100644 --- a/tests/GeneratesHashIdTest.php +++ b/tests/GeneratesHashIdTest.php @@ -2,7 +2,6 @@ namespace AntoninMasek\Hashids\Tests; -use _PHPStan_9a6ded56a\Nette\Neon\Exception; use AntoninMasek\Hashids\Facades\Hashids; use AntoninMasek\Hashids\ModelHashids; use AntoninMasek\Hashids\Tests\Fixtures\BindingTestModel; @@ -12,6 +11,7 @@ use AntoninMasek\Hashids\Tests\Fixtures\TestModelWithDifferentKeyForGenerationGenerator; use AntoninMasek\Hashids\Tests\Fixtures\TestModelWithMinLengthGenerator; use AntoninMasek\Hashids\Tests\Fixtures\TestModelWithSaltGenerator; +use Exception; use Illuminate\Database\Eloquent\Model; use Illuminate\Routing\Middleware\SubstituteBindings; use Illuminate\Support\Facades\Event; From 7f4fc0452bd6e55b12abe3b4e685680db0872e1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=C3=ADn=20Ma=C5=A1ek?= Date: Mon, 1 Apr 2024 18:14:32 +1300 Subject: [PATCH 5/5] Update Readme --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 73e04b3..2f6c08f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ # Easily use Hashids with Laravel models. -[![Latest Version on Packagist](https://img.shields.io/packagist/v/antoninmasek/laravel-model-hashids.svg?style=flat-square)](https://packagist.org/packages/antoninmasek/laravel-model-hashids) -[![GitHub Tests Action Status](https://img.shields.io/github/workflow/status/antoninmasek/laravel-model-hashids/run-tests?label=tests)](https://github.com/antoninmasek/laravel-model-hashids/actions?query=workflow%3Arun-tests+branch%3Amain) -[![GitHub Code Style Action Status](https://img.shields.io/github/workflow/status/antoninmasek/laravel-model-hashids/Check%20&%20fix%20styling?label=code%20style)](https://github.com/antoninmasek/laravel-model-hashids/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amain) -[![Total Downloads](https://img.shields.io/packagist/dt/antoninmasek/laravel-model-hashids.svg?style=flat-square)](https://packagist.org/packages/antoninmasek/laravel-model-hashids) +![Packagist Version](https://img.shields.io/packagist/v/antoninmasek/laravel-model-hashids?style=flat-square&link=https%3A%2F%2Fpackagist.org%2Fpackages%2Fantoninmasek%2Flaravel-model-hashids) +![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/antoninmasek/laravel-model-hashids/run-tests.yml?branch=main&style=flat-square&label=tests) +![Packagist Downloads](https://img.shields.io/packagist/dt/antoninmasek/laravel-model-hashids?style=flat-square&link=https%3A%2F%2Fpackagist.org%2Fpackages%2Fantoninmasek%2Flaravel-model-hashids) In some cases I really like to use [Hashids](https://hashids.org/php/) instead of uuids as my model keys. For me Hashids are less awkward to read and the resulting URL looks @@ -175,7 +174,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re ## Credits -- [Antonín Mašek](https://github.com/antoninmasek) +[Antonín Mašek](https://github.com/antoninmasek) ## License