From c84ca0609c3a20f172dd0b926c2f539ee3c68e61 Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Mon, 18 Nov 2024 15:06:11 +0100 Subject: [PATCH 1/4] (chore): workflows form boilerplate --- .github/workflows/composer-lock-diff.yml | 30 +--------- ...l-request.yml => dependabot-automerge.yml} | 2 +- .github/workflows/format-php.yml | 31 +---------- .github/workflows/labeler.yml | 20 ------- .github/workflows/markdown-linting.yml | 15 +---- .github/workflows/npm-lock-diff.yml | 15 +---- .github/workflows/phpstan.yml | 26 +-------- .github/workflows/run-tests.yml | 55 ++++++++++++++++--- 8 files changed, 60 insertions(+), 134 deletions(-) rename .github/workflows/{pull-request.yml => dependabot-automerge.yml} (85%) delete mode 100644 .github/workflows/labeler.yml diff --git a/.github/workflows/composer-lock-diff.yml b/.github/workflows/composer-lock-diff.yml index b893386..da726e3 100644 --- a/.github/workflows/composer-lock-diff.yml +++ b/.github/workflows/composer-lock-diff.yml @@ -3,32 +3,8 @@ on: pull_request: paths: - 'composer.lock' + jobs: composer-diff: - name: Composer Diff - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Required to make it possible to compare with PR base branch - - - name: Generate composer diff - id: composer_diff # To reference the output in comment - uses: IonBazan/composer-diff-action@v1 - - - uses: marocchino/sticky-pull-request-comment@v2 - # An empty diff result will break this action. - if: ${{ steps.composer_diff.outputs.composer_diff_exit_code != 0 }} - with: - header: composer-diff # Creates a collapsed comment with the report - message: | -
- Composer package changes - - ${{ steps.composer_diff.outputs.composer_diff }} - -
+ uses: yardinternet/workflows/.github/workflows/composer-lock-diff.yml@main + secrets: inherit diff --git a/.github/workflows/pull-request.yml b/.github/workflows/dependabot-automerge.yml similarity index 85% rename from .github/workflows/pull-request.yml rename to .github/workflows/dependabot-automerge.yml index 7ee7d39..fc1ef7d 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -1,4 +1,4 @@ -name: Pull Request Workflow +name: Dependabot automerge on: pull_request jobs: diff --git a/.github/workflows/format-php.yml b/.github/workflows/format-php.yml index 16b1a38..e536275 100644 --- a/.github/workflows/format-php.yml +++ b/.github/workflows/format-php.yml @@ -7,32 +7,5 @@ on: jobs: php-cs-fixer: - name: php-cs-fixer - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer:v2 - coverage: none - env: - COMPOSER_TOKEN: ${{ secrets.YARD_BOT_PAT }} - - - name: Install composer dependencies - run: composer install --prefer-dist --no-interaction - - - name: Run PHPStan - run: ./vendor/bin/php-cs-fixer fix - - - uses: stefanzweifel/git-auto-commit-action@v5 - with: - commit_message: '(auto): apply php-cs-fixer changes' - push_options: '--force' - env: - GITHUB_TOKEN: ${{ secrets.YARD_BOT_PAT }} + uses: yardinternet/workflows/.github/workflows/format-php.yml@main + secrets: inherit diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml deleted file mode 100644 index f8ca0ba..0000000 --- a/.github/workflows/labeler.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: 'Labeler' - -on: - pull_request: - types: [opened, synchronize, reopened] - -jobs: - label: - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - - steps: - - uses: actions/checkout@v4 - - - name: Labeler - uses: actions/labeler@v5.0.0 - with: - repo-token: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/markdown-linting.yml b/.github/workflows/markdown-linting.yml index 742824d..684207c 100644 --- a/.github/workflows/markdown-linting.yml +++ b/.github/workflows/markdown-linting.yml @@ -5,15 +5,6 @@ on: - '**.md' jobs: - lint: - name: Markdown Linting - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: DavidAnson/markdownlint-cli2-action@v18 - with: - globs: | - *.md - config: .markdownlint.yml + linting: + uses: yardinternet/workflows/.github/workflows/markdown-linting.yml@main + secrets: inherit diff --git a/.github/workflows/npm-lock-diff.yml b/.github/workflows/npm-lock-diff.yml index 80c82f4..e115ebf 100644 --- a/.github/workflows/npm-lock-diff.yml +++ b/.github/workflows/npm-lock-diff.yml @@ -6,16 +6,5 @@ on: jobs: lockfile_changes: - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Required to make it possible to compare with PR base branch - - name: NPM Lockfile Changes - uses: rvanvelzen/npm-lockfile-changes@main - with: - token: ${{ secrets.GITHUB_TOKEN }} + uses: yardinternet/workflows/.github/workflows/npm-lock-diff.yml@main + secrets: inherit diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index b8cdd46..76fe387 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -8,26 +8,6 @@ on: - '.github/workflows/phpstan.yml' jobs: - phpstan: - name: phpstan - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: composer:v2 - coverage: none - env: - COMPOSER_TOKEN: ${{ secrets.YARD_BOT_PAT }} - - - name: Install composer dependencies - run: composer install --prefer-dist --no-interaction - - - name: Run PHPStan - run: ./vendor/bin/phpstan --error-format=github + phpstan: + uses: yardinternet/workflows/.github/workflows/phpstan.yml@main + secrets: inherit diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index db8bde1..64246aa 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -11,22 +11,59 @@ on: workflow_dispatch: jobs: - ci: - runs-on: ubuntu-latest + test: + runs-on: ${{ matrix.os }} + timeout-minutes: 5 + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [8.1] + laravel: [10.*] + include: + - laravel: 10.* + testbench: 8.* + + name: PHP${{ matrix.php }} - Laravel${{ matrix.laravel }} + + permissions: + contents: read + pull-requests: write steps: - - name: Checkout + - name: Checkout code uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: 8.1 - tools: composer:v2 + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo, xdebug coverage: xdebug + tools: composer:v2 + env: + COMPOSER_TOKEN: ${{ secrets.YARD_BOT_PAT }} - - name: Install Dependencies - run: composer install --no-interaction --prefer-dist --optimize-autoloader + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" - - name: Tests - run: ./vendor/bin/pest --ci + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --prefer-dist --no-interaction + + - name: List Installed Dependencies + run: composer show -D + + - name: Execute tests + run: vendor/bin/pest --coverage-clover=coverage.xml + + - name: Coverage Report as Comment (Clover) + if: github.event_name == 'pull_request' + uses: lucassabreu/comment-coverage-clover@main + with: + file: coverage.xml From 6a2c17ecfa667eb7981beed5fb0f6a305ac477b2 Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Mon, 18 Nov 2024 15:29:39 +0100 Subject: [PATCH 2/4] (chore): remove labeler.yml --- .github/labeler.yml | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 .github/labeler.yml diff --git a/.github/labeler.yml b/.github/labeler.yml deleted file mode 100644 index 6fce6bc..0000000 --- a/.github/labeler.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Add 'root' label to any root file changes -# Quotation marks are required for the leading asterisk -root: - - changed-files: - - any-glob-to-any-file: '*' - -# Add 'documentation' label to any change to .md files within the entire repository -documentation: - - changed-files: - - any-glob-to-any-file: '**/*.md' - -# Add 'enhancement' label to any PR where the head branch name starts with `feature` or has a `feature` section in the name -enhancement: - - head-branch: ['^feature', 'feature', '^feat'] - -# Add 'fix' label to any PR where the head branch name starts with `fix` or has a `fix` section in the name -bug: - - head-branch: ['fix', '^fix'] - -# Add 'release' label to any PR that is opened against the `main` branch -release: - - base-branch: 'main' - -# Add 'dependencies' label to any composer.lock or package-lock.json changes -dependencies: - - changed-files: - - any-glob-to-any-file: ['composer.lock', 'package-lock.json'] - -# Add 'tests' label to any changes to the tests directory -tests: - - changed-files: - - any-glob-to-any-file: 'tests/**/*' From ed83f08cafa306b5a2a8bb1703ccad925e31f7d7 Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Tue, 19 Nov 2024 15:32:36 +0100 Subject: [PATCH 3/4] (chore): php config version, cleanup test workflow --- .github/workflows/run-tests.yml | 12 ++++-------- composer.json | 5 ++++- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 64246aa..2367135 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -17,14 +17,10 @@ jobs: strategy: fail-fast: true matrix: - os: [ubuntu-latest] - php: [8.1] - laravel: [10.*] - include: - - laravel: 10.* - testbench: 8.* + os: [ ubuntu-latest ] + php: [ 8.1,8.2 ] - name: PHP${{ matrix.php }} - Laravel${{ matrix.laravel }} + name: PHP${{ matrix.php }} permissions: contents: read @@ -53,7 +49,7 @@ jobs: - name: Install dependencies run: | - composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer require --no-interaction --no-update composer update --prefer-dist --no-interaction - name: List Installed Dependencies diff --git a/composer.json b/composer.json index 24dbea9..6b7a501 100644 --- a/composer.json +++ b/composer.json @@ -8,10 +8,13 @@ "sort-packages": true, "allow-plugins": { "pestphp/pest-plugin": true + }, + "platform": { + "php": "8.1" } }, "require": { - "php": "8.1.*", + "php": ">=8.1", "ckr/arraymerger": "^3.0", "webmozart/assert": "^1.11" }, From 2192c3260fcd1a78f3a7fe8a893c99dbc1d3a18d Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Tue, 19 Nov 2024 16:05:44 +0100 Subject: [PATCH 4/4] (chore): same as in boilerplate --- .editorconfig | 3 --- 1 file changed, 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index 6254313..e3ac933 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,6 +14,3 @@ indent_size = 2 [*.md] trim_trailing_whitespace = false indent_style = space - -[{*.txt,wp-config-sample.php}] -end_of_line = crlf