From 5a82b05be5df1e2e868251da1d60d52676db8d53 Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Fri, 15 Nov 2024 16:01:36 +0100 Subject: [PATCH 1/6] (chore): added phpstan workflow, made file exist check, gitignore --- .github/workflows/dependabot-automerge.yml | 1 + .github/workflows/phpstan.yml | 36 ++++++++++++++++++++++ .gitignore | 1 + 3 files changed, 38 insertions(+) create mode 100644 .github/workflows/phpstan.yml create mode 100644 .gitignore diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml index 7841fde..78611a7 100644 --- a/.github/workflows/dependabot-automerge.yml +++ b/.github/workflows/dependabot-automerge.yml @@ -1,4 +1,5 @@ name: Dependabot automerge + on: - workflow_call diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..57852d9 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,36 @@ +name: PHPStan + +on: + workflow_call: + paths: + - '**.php' + - 'phpstan.neon.dist' + - '.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: Dirty fix for previously defined function + run: [ -f ./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php ] && sed -i -e 's#function __(#function ____(#' ./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php + + - name: Run PHPStan + run: ./vendor/bin/phpstan --error-format=github diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file From aa5656ab21f3f2652325675e21b749e811b8ee42 Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Fri, 15 Nov 2024 16:07:09 +0100 Subject: [PATCH 2/6] (chore): create readme --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6c8f6c6 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Workflows + +Github Actions used in projects of the WordPress team. + +- PHPStan +- Dependabot (auto-merge) +- From 35a23810775af860b91a38cfd969fe65d6c38852 Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Mon, 18 Nov 2024 09:36:59 +0100 Subject: [PATCH 3/6] (fix): path not allowed on workflow_call --- .github/workflows/composer-lock-diff.yml | 36 ++++++++++++++++++++++++ .github/workflows/format-php.yml | 36 ++++++++++++++++++++++++ .github/workflows/phpstan.yml | 6 +--- 3 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/composer-lock-diff.yml create mode 100644 .github/workflows/format-php.yml diff --git a/.github/workflows/composer-lock-diff.yml b/.github/workflows/composer-lock-diff.yml new file mode 100644 index 0000000..d2a6129 --- /dev/null +++ b/.github/workflows/composer-lock-diff.yml @@ -0,0 +1,36 @@ +name: Composer Diff + +on: + workflow_call: + 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 }} + +
diff --git a/.github/workflows/format-php.yml b/.github/workflows/format-php.yml new file mode 100644 index 0000000..9e38868 --- /dev/null +++ b/.github/workflows/format-php.yml @@ -0,0 +1,36 @@ +name: PHP CS Fixer + +on: + - workflow_call + +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 }} diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 57852d9..9fee3b9 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -1,11 +1,7 @@ name: PHPStan on: - workflow_call: - paths: - - '**.php' - - 'phpstan.neon.dist' - - '.github/workflows/phpstan.yml' + - workflow_call jobs: phpstan: From c1c6096222f5a5e3b013e89ab9a99f2015e9228c Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Mon, 18 Nov 2024 09:43:47 +0100 Subject: [PATCH 4/6] (chore): add markdown-linting and npm lock diff --- .github/workflows/markdown-linting.yml | 18 ++++++++++++++++++ .github/workflows/npm-lock-diff.yml | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 .github/workflows/markdown-linting.yml create mode 100644 .github/workflows/npm-lock-diff.yml diff --git a/.github/workflows/markdown-linting.yml b/.github/workflows/markdown-linting.yml new file mode 100644 index 0000000..1c901f2 --- /dev/null +++ b/.github/workflows/markdown-linting.yml @@ -0,0 +1,18 @@ +name: linting + +on: + - workflow_call + +jobs: + lint: + name: Markdown Linting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: DavidAnson/markdownlint-cli2-action@v17 + with: + globs: | + *.md + config: .markdownlint.yml diff --git a/.github/workflows/npm-lock-diff.yml b/.github/workflows/npm-lock-diff.yml new file mode 100644 index 0000000..d795ed0 --- /dev/null +++ b/.github/workflows/npm-lock-diff.yml @@ -0,0 +1,20 @@ +name: NPM Lockfile Changes + +on: + - workflow_call + +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 }} From 60f5d3d4580499c3149c23670fc12ff65e80d3b2 Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Mon, 18 Nov 2024 11:28:35 +0100 Subject: [PATCH 5/6] (chore): add context to name stubs fix. Add markdown lint file --- .github/workflows/phpstan.yml | 2 +- .markdownlint.yml | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .markdownlint.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 9fee3b9..28fa648 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -25,7 +25,7 @@ jobs: - name: Install composer dependencies run: composer install --prefer-dist --no-interaction - - name: Dirty fix for previously defined function + - name: Dirty fix for previously defined function (packages using php-stubs) run: [ -f ./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php ] && sed -i -e 's#function __(#function ____(#' ./vendor/php-stubs/wordpress-stubs/wordpress-stubs.php - name: Run PHPStan diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..ef8bb79 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,6 @@ +MD010: { "spaces_per_tab": 4 } +MD013: false +MD024: { "siblings_only": true } +MD025: false +MD033: false +MD036: false From 78bf6a0578abd077f7a9246899b4d0aea0ba6ba7 Mon Sep 17 00:00:00 2001 From: Freek de Kruijff Date: Mon, 18 Nov 2024 11:57:31 +0100 Subject: [PATCH 6/6] (chore): remove path --- .github/workflows/composer-lock-diff.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/composer-lock-diff.yml b/.github/workflows/composer-lock-diff.yml index d2a6129..cd5f3df 100644 --- a/.github/workflows/composer-lock-diff.yml +++ b/.github/workflows/composer-lock-diff.yml @@ -1,9 +1,7 @@ name: Composer Diff on: - workflow_call: - paths: - - 'composer.lock' + - workflow_call jobs: composer-diff: