From af568952bd8d2a04d22115d301a9ff8ab7f54e10 Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 18 Jan 2025 17:34:34 +0100 Subject: [PATCH 01/16] Added: The new boolean input `stop-on-manual-fix` will cause the workflow to stop (fail) if manual fixes are necessary. --- CHANGELOG.md | 2 ++ README.md | 8 ++++++-- action.yml | 13 +++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c50511a..dc906d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Added` for new features +- The new boolean input `stop-on-manual-fix` will cause the workflow to stop (fail) if manual fixes are necessary. + ### `Changed` for changes in existing functionality ### `Deprecated` for soon-to-be removed features diff --git a/README.md b/README.md index a4b4e04..524d987 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,12 @@ This action can either commit changes directly to the current branch or create a This action is designed to be used as a _reusable workflow_. You can call it from another workflow in your repository or simply add [the provided YAML configuration](.github/workflows/phpcs-phpcbf.yml) to your repository. -By default, if needed, a new branch with a name starting with `prettier/fix` will be created, making it easy to review and merge the fixes into your main branch. +By default, if necessary, a new branch with a name starting with `phpcbf/fix` will be created, making it easy to review and merge fixes into your main branch. -Note: This action is not blocking, so the status remains green even if changes are proposed in the form of a new branch. Then it’s up to you to either create a pull request to merge the changes or delete the branch. +Note 1: This action is non-blocking, so the status remains green even when changes are proposed via a new branch. +A notice message is displayed, and it is then up to you to either create a pull request to merge the changes or delete the branch. + +Note 2: However, you can mandate the action to stop if manual fixes are necessary by setting the input parameter `stop-on-manual-fix: true`. ### Permissions @@ -37,6 +40,7 @@ permissions: | `ignore` | Ignore files based on a comma-separated list of patterns matching files and/or directories. | String | `vendor/` | | `php-version` | The PHP version to use, e.g. `"8.2"`. | String | `"8.2"` | | `standard` | The name of, or the path to, the coding standard to use. Can be a comma-separated list specifying multiple standards. | String | The project's `.github/linters/phpcs.xml` (where Super-linter expects it) with fallback to copied to [.github/linters/super-linter-templates-phpcs.xml](.github/linters/super-linter-templates-phpcs.xml) will be used. | +| `stop-on-manual-fix` | If true, the execution will stop when manual fixes are necessary. | Boolean | `false` | ### Outputs diff --git a/action.yml b/action.yml index 3cc2134..f1e1628 100644 --- a/action.yml +++ b/action.yml @@ -45,6 +45,10 @@ inputs: required: false type: string default: "" # if left empty, .github/linters/phpcs.xml or https://github.com/super-linter/super-linter/blob/main/TEMPLATES/phpcs.xml will be used + stop-on-manual-fix: + description: "If true, the execution will stop when manual fixes are necessary." + type: boolean + default: false outputs: branch-name: @@ -112,8 +116,13 @@ runs: # Check for fixable changes if [ -z "$(git status --porcelain)" ]; then echo "::warning title=No fixable errors were found by phpcbf::Manual fix necessary. Compare to the PHP Code Sniffer section above." - # Exiting gracefully - exit 0 + if [ "${{ inputs.stop-on-manual-fix }}" = "true" ]; then + # Indicates an error + exit 1 + else + # Exiting gracefully + exit 0 + fi # The rest of the script must still be within the same step to really stop the execution fi From e940f4f8b5fed7ac98a6d9dcdd6469ad30cd3c15 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 18 Jan 2025 16:34:58 +0000 Subject: [PATCH 02/16] Prettier fixes applied automatically on 2025-01-18 16:34:58 UTC --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 524d987..fd93a27 100644 --- a/README.md +++ b/README.md @@ -32,15 +32,15 @@ permissions: ### Inputs (all optional) -| Input | Description | Type | Default | -| ---------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `commit-changes` | If set to `true`, the action will commit changes to the current branch; otherwise a new branch is created for manual review. | Boolean | `false` | -| `commit-message` | Commit message to use if the action commits changes. | String | `"PHP Code Beautifier fixes applied automatically"` | -| `extensions` | Comma-delimited list of file extensions to be sniffed. Note: an empty value will disable checking. | String | `"php"` (defaults to PHP only; other file types must be specified) | -| `ignore` | Ignore files based on a comma-separated list of patterns matching files and/or directories. | String | `vendor/` | -| `php-version` | The PHP version to use, e.g. `"8.2"`. | String | `"8.2"` | -| `standard` | The name of, or the path to, the coding standard to use. Can be a comma-separated list specifying multiple standards. | String | The project's `.github/linters/phpcs.xml` (where Super-linter expects it) with fallback to copied to [.github/linters/super-linter-templates-phpcs.xml](.github/linters/super-linter-templates-phpcs.xml) will be used. | -| `stop-on-manual-fix` | If true, the execution will stop when manual fixes are necessary. | Boolean | `false` | +| Input | Description | Type | Default | +| -------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `commit-changes` | If set to `true`, the action will commit changes to the current branch; otherwise a new branch is created for manual review. | Boolean | `false` | +| `commit-message` | Commit message to use if the action commits changes. | String | `"PHP Code Beautifier fixes applied automatically"` | +| `extensions` | Comma-delimited list of file extensions to be sniffed. Note: an empty value will disable checking. | String | `"php"` (defaults to PHP only; other file types must be specified) | +| `ignore` | Ignore files based on a comma-separated list of patterns matching files and/or directories. | String | `vendor/` | +| `php-version` | The PHP version to use, e.g. `"8.2"`. | String | `"8.2"` | +| `standard` | The name of, or the path to, the coding standard to use. Can be a comma-separated list specifying multiple standards. | String | The project's `.github/linters/phpcs.xml` (where Super-linter expects it) with fallback to copied to [.github/linters/super-linter-templates-phpcs.xml](.github/linters/super-linter-templates-phpcs.xml) will be used. | +| `stop-on-manual-fix` | If true, the execution will stop when manual fixes are necessary. | Boolean | `false` | ### Outputs From b180943e07e0420724ebb8974e22a36df1bcf26f Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 18 Jan 2025 20:56:41 +0100 Subject: [PATCH 03/16] Stop with an error if some manual fixes are required on top of automatic fixes --- .github/workflows/phpcs-phpcbf.yml | 1 + CHANGELOG.md | 1 + action.yml | 11 ++++++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/phpcs-phpcbf.yml b/.github/workflows/phpcs-phpcbf.yml index f1947a0..fad77df 100644 --- a/.github/workflows/phpcs-phpcbf.yml +++ b/.github/workflows/phpcs-phpcbf.yml @@ -16,3 +16,4 @@ jobs: uses: WorkOfStan/phpcs-fix@main with: commit-changes: true + stop-on-manual-fix: true diff --git a/CHANGELOG.md b/CHANGELOG.md index dc906d5..191a7e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Added` for new features - The new boolean input `stop-on-manual-fix` will cause the workflow to stop (fail) if manual fixes are necessary. +- Also stop with an error if some manual fixes are required on top of automatic fixes. ### `Changed` for changes in existing functionality diff --git a/action.yml b/action.yml index f1e1628..ea12ab5 100644 --- a/action.yml +++ b/action.yml @@ -108,7 +108,11 @@ runs: if: env.HAS_ISSUES == 'true' run: | echo "phpcbf standard=${{ env.USE_STANDARD }}" - vendor/bin/phpcbf --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || echo "::warning title=Some phpcs issues remained::Manual fix necessary. Compare to the PHP Code Sniffer section above." + vendor/bin/phpcbf --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || MORE_ISSUES=true + : "${MORE_ISSUES:=false}" + if [ "${MORE_ISSUES}" = "true" ]; then + echo "::warning title=Some phpcs issues remained::Manual fix necessary. Compare to the PHP Code Sniffer section above." + fi # restore composer.json before staging the changes git checkout composer.json @@ -151,4 +155,9 @@ runs: # Set branch name as output echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT + + # Stop with an error if some manual fixes are required on top of automatic fixes + if [ "${{ inputs.stop-on-manual-fix }}" = "true" ] && [ "${MORE_ISSUES}" = "true" ]; then + exit 1 + fi shell: bash From 3e298bb15b1f9d03076831ee3825c4a63f43c9fb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 18 Jan 2025 19:56:58 +0000 Subject: [PATCH 04/16] Prettier fixes applied automatically on 2025-01-18 19:56:58 UTC --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ea12ab5..685ba72 100644 --- a/action.yml +++ b/action.yml @@ -155,7 +155,7 @@ runs: # Set branch name as output echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT - + # Stop with an error if some manual fixes are required on top of automatic fixes if [ "${{ inputs.stop-on-manual-fix }}" = "true" ] && [ "${MORE_ISSUES}" = "true" ]; then exit 1 From dbda4c8bb6855284ed81cec176b58599dd76be9e Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 18 Jan 2025 21:39:22 +0100 Subject: [PATCH 05/16] Update action.yml phpcbf non-zero exit - warning to investigate --- action.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 685ba72..2f9e524 100644 --- a/action.yml +++ b/action.yml @@ -111,7 +111,9 @@ runs: vendor/bin/phpcbf --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || MORE_ISSUES=true : "${MORE_ISSUES:=false}" if [ "${MORE_ISSUES}" = "true" ]; then - echo "::warning title=Some phpcs issues remained::Manual fix necessary. Compare to the PHP Code Sniffer section above." + #echo "::warning title=Some phpcs issues remained::Manual fix necessary. Compare to the PHP Code Sniffer section above." + # todo investigate when this happens + echo "::warning title=Non-zero code exit of phpcbf::Manual fix necessary?" fi # restore composer.json before staging the changes @@ -156,8 +158,8 @@ runs: # Set branch name as output echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT - # Stop with an error if some manual fixes are required on top of automatic fixes - if [ "${{ inputs.stop-on-manual-fix }}" = "true" ] && [ "${MORE_ISSUES}" = "true" ]; then - exit 1 - fi + ## Stop with an error if some manual fixes are required on top of automatic fixes + #if [ "${{ inputs.stop-on-manual-fix }}" = "true" ] && [ "${MORE_ISSUES}" = "true" ]; then + # exit 1 + #fi shell: bash From 3d226eb1a2ea16447ba82de3d41a38141b970e78 Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 18 Jan 2025 21:57:18 +0100 Subject: [PATCH 06/16] Update action.yml PHPCBF_EXIT_CODE --- action.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 2f9e524..39f83ae 100644 --- a/action.yml +++ b/action.yml @@ -108,12 +108,14 @@ runs: if: env.HAS_ISSUES == 'true' run: | echo "phpcbf standard=${{ env.USE_STANDARD }}" - vendor/bin/phpcbf --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || MORE_ISSUES=true - : "${MORE_ISSUES:=false}" - if [ "${MORE_ISSUES}" = "true" ]; then + PHPCBF_EXIT_CODE=0 + vendor/bin/phpcbf --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || PHPCBF_EXIT_CODE=$? + ##: "${MORE_ISSUES:=false}" + if [ ${PHPCBF_EXIT_CODE} -ne 0 ]; then + ##if [ "${MORE_ISSUES}" = "true" ]; then #echo "::warning title=Some phpcs issues remained::Manual fix necessary. Compare to the PHP Code Sniffer section above." # todo investigate when this happens - echo "::warning title=Non-zero code exit of phpcbf::Manual fix necessary?" + echo "::warning title=Non-zero code exit of phpcbf ${PHPCBF_EXIT_CODE}::Manual fix necessary?" fi # restore composer.json before staging the changes From a81fbb0199f310cbc8507e86d914398de63605fa Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 25 Jan 2025 10:26:45 +0100 Subject: [PATCH 07/16] Update action.yml phpcs rerun if phpcbf exit non-zero --- action.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/action.yml b/action.yml index 39f83ae..937beb4 100644 --- a/action.yml +++ b/action.yml @@ -110,12 +110,15 @@ runs: echo "phpcbf standard=${{ env.USE_STANDARD }}" PHPCBF_EXIT_CODE=0 vendor/bin/phpcbf --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || PHPCBF_EXIT_CODE=$? - ##: "${MORE_ISSUES:=false}" + "${MORE_ISSUES:=false}" if [ ${PHPCBF_EXIT_CODE} -ne 0 ]; then - ##if [ "${MORE_ISSUES}" = "true" ]; then - #echo "::warning title=Some phpcs issues remained::Manual fix necessary. Compare to the PHP Code Sniffer section above." - # todo investigate when this happens - echo "::warning title=Non-zero code exit of phpcbf ${PHPCBF_EXIT_CODE}::Manual fix necessary?" + echo "::notice title=Non-zero code exit of phpcbf = ${PHPCBF_EXIT_CODE}::phpcbf wasn't idle" + + vendor/bin/phpcs --extensions="${{ inputs.extensions }}" . --standard="$use_standard" --ignore="${{ inputs.ignore }}" || MORE_ISSUES=true + # because of `||`, the previous command always exit 0 + if [ "${MORE_ISSUES}" = "true" ]; then + echo "::warning title=Some phpcs issues remained.::Manual fix necessary." + fi fi # restore composer.json before staging the changes @@ -161,7 +164,7 @@ runs: echo "branch-name=$BRANCH_NAME" >> $GITHUB_OUTPUT ## Stop with an error if some manual fixes are required on top of automatic fixes - #if [ "${{ inputs.stop-on-manual-fix }}" = "true" ] && [ "${MORE_ISSUES}" = "true" ]; then - # exit 1 - #fi + if [ "${{ inputs.stop-on-manual-fix }}" = "true" ] && [ "${MORE_ISSUES}" = "true" ]; then + exit 1 + fi shell: bash From 24e3f86d56f50a1ab6f511bb322e2647e6de3524 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 25 Jan 2025 09:26:59 +0000 Subject: [PATCH 08/16] Prettier fixes applied automatically on 2025-01-25 09:26:59 UTC --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 937beb4..1028ef0 100644 --- a/action.yml +++ b/action.yml @@ -113,7 +113,7 @@ runs: "${MORE_ISSUES:=false}" if [ ${PHPCBF_EXIT_CODE} -ne 0 ]; then echo "::notice title=Non-zero code exit of phpcbf = ${PHPCBF_EXIT_CODE}::phpcbf wasn't idle" - + vendor/bin/phpcs --extensions="${{ inputs.extensions }}" . --standard="$use_standard" --ignore="${{ inputs.ignore }}" || MORE_ISSUES=true # because of `||`, the previous command always exit 0 if [ "${MORE_ISSUES}" = "true" ]; then From 598cc1f365a82fdec9448f253eca693ff808a19c Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sun, 26 Jan 2025 00:43:27 +0100 Subject: [PATCH 09/16] Update action.yml cache added --- action.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 1028ef0..f8fc34c 100644 --- a/action.yml +++ b/action.yml @@ -74,8 +74,20 @@ runs: php-version: "${{ inputs.php-version }}" tools: composer:v2 - # todo consider using cache + # https://github.com/actions/cache + # A repository can have up to 10 GB of caches. Once the 10 GB limit is reached, older caches will be evicted based on when the cache was last accessed. + # Caches that are not accessed within the last week will also be evicted. + - name: Cache composer dependencies + uses: actions/cache@v4 + id: vendor-cache + with: + # path to Checkout working directory is /home/runner/work/repo-name/repo-name , so just add /vendor/ + path: ${{ github.workspace }}/vendor/ + # Use composer.json for key, if composer.lock is not committed. + key: ${{ runner.os }}-PHP${{ inputs.php-version }}-vendor-${{ hashFiles('**/composer.json') }} + - name: "Use the latest PHPCS version" + if: ${{ steps.vendor-cache.outputs.cache-hit != 'true' }} run: composer require --dev squizlabs/php_codesniffer --prefer-dist --no-progress shell: bash @@ -109,8 +121,8 @@ runs: run: | echo "phpcbf standard=${{ env.USE_STANDARD }}" PHPCBF_EXIT_CODE=0 + MORE_ISSUES=false vendor/bin/phpcbf --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || PHPCBF_EXIT_CODE=$? - "${MORE_ISSUES:=false}" if [ ${PHPCBF_EXIT_CODE} -ne 0 ]; then echo "::notice title=Non-zero code exit of phpcbf = ${PHPCBF_EXIT_CODE}::phpcbf wasn't idle" From 80d59f4cd6c7ddca3c576bf168fc5e69bd344575 Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sun, 26 Jan 2025 00:46:21 +0100 Subject: [PATCH 10/16] Update action.yml fix spaces --- action.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/action.yml b/action.yml index f8fc34c..4fc9a59 100644 --- a/action.yml +++ b/action.yml @@ -74,18 +74,18 @@ runs: php-version: "${{ inputs.php-version }}" tools: composer:v2 - # https://github.com/actions/cache - # A repository can have up to 10 GB of caches. Once the 10 GB limit is reached, older caches will be evicted based on when the cache was last accessed. - # Caches that are not accessed within the last week will also be evicted. - - name: Cache composer dependencies - uses: actions/cache@v4 - id: vendor-cache - with: - # path to Checkout working directory is /home/runner/work/repo-name/repo-name , so just add /vendor/ - path: ${{ github.workspace }}/vendor/ - # Use composer.json for key, if composer.lock is not committed. - key: ${{ runner.os }}-PHP${{ inputs.php-version }}-vendor-${{ hashFiles('**/composer.json') }} - + # https://github.com/actions/cache + # A repository can have up to 10 GB of caches. Once the 10 GB limit is reached, older caches will be evicted based on when the cache was last accessed. + # Caches that are not accessed within the last week will also be evicted. + - name: Cache composer dependencies + uses: actions/cache@v4 + id: vendor-cache + with: + # path to Checkout working directory is /home/runner/work/repo-name/repo-name , so just add /vendor/ + path: ${{ github.workspace }}/vendor/ + # Use composer.json for key, if composer.lock is not committed. + key: ${{ runner.os }}-PHP${{ inputs.php-version }}-vendor-${{ hashFiles('**/composer.json') }} + - name: "Use the latest PHPCS version" if: ${{ steps.vendor-cache.outputs.cache-hit != 'true' }} run: composer require --dev squizlabs/php_codesniffer --prefer-dist --no-progress From e974209c6184a624de9866ae0497ff6743d4f332 Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sun, 26 Jan 2025 01:14:51 +0100 Subject: [PATCH 11/16] Update action.yml own cache, better notices --- action.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 4fc9a59..a615360 100644 --- a/action.yml +++ b/action.yml @@ -84,7 +84,7 @@ runs: # path to Checkout working directory is /home/runner/work/repo-name/repo-name , so just add /vendor/ path: ${{ github.workspace }}/vendor/ # Use composer.json for key, if composer.lock is not committed. - key: ${{ runner.os }}-PHP${{ inputs.php-version }}-vendor-${{ hashFiles('**/composer.json') }} + key: phpcs-fix-${{ runner.os }}-PHP${{ inputs.php-version }}-vendor-${{ hashFiles('**/composer.json') }} - name: "Use the latest PHPCS version" if: ${{ steps.vendor-cache.outputs.cache-hit != 'true' }} @@ -124,12 +124,12 @@ runs: MORE_ISSUES=false vendor/bin/phpcbf --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || PHPCBF_EXIT_CODE=$? if [ ${PHPCBF_EXIT_CODE} -ne 0 ]; then - echo "::notice title=Non-zero code exit of phpcbf = ${PHPCBF_EXIT_CODE}::phpcbf wasn't idle" + echo "::notice title=phpcbf wasn't idle::Non-zero code exit of phpcbf = ${PHPCBF_EXIT_CODE} ... phpcbf wasn't idle" vendor/bin/phpcs --extensions="${{ inputs.extensions }}" . --standard="$use_standard" --ignore="${{ inputs.ignore }}" || MORE_ISSUES=true # because of `||`, the previous command always exit 0 if [ "${MORE_ISSUES}" = "true" ]; then - echo "::warning title=Some phpcs issues remained.::Manual fix necessary." + echo "::warning title=Some phpcs issues remained.::Some phpcs issues remained. Manual fix necessary." fi fi @@ -138,7 +138,7 @@ runs: # Check for fixable changes if [ -z "$(git status --porcelain)" ]; then - echo "::warning title=No fixable errors were found by phpcbf::Manual fix necessary. Compare to the PHP Code Sniffer section above." + echo "::warning title=No fixable errors were found by phpcbf::No fixable errors were found by phpcbf: Manual fix necessary. Compare to the PHP Code Sniffer section above." if [ "${{ inputs.stop-on-manual-fix }}" = "true" ]; then # Indicates an error exit 1 @@ -159,7 +159,7 @@ runs: # name includes timestamp and short_hash BRANCH_NAME="phpcbf/fix-$(date +'%y%m%d%H%M%S')-$(git rev-parse --short HEAD)" git checkout -b "$BRANCH_NAME" - echo "::warning title=New branch created::Consider pull request for a new branch: $BRANCH_NAME (or delete it)" + echo "::warning title=New branch created::New branch created: Consider pull request for a new branch: $BRANCH_NAME (or delete it)" NOTICE_MESSAGE="A PHPCBF commit was successfully added to the new branch: $BRANCH_NAME" fi From e4036be05cd5959994d51a22d99a988711c97e4b Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sun, 26 Jan 2025 01:19:13 +0100 Subject: [PATCH 12/16] Update action.yml use right standard --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index a615360..1a5175b 100644 --- a/action.yml +++ b/action.yml @@ -126,7 +126,7 @@ runs: if [ ${PHPCBF_EXIT_CODE} -ne 0 ]; then echo "::notice title=phpcbf wasn't idle::Non-zero code exit of phpcbf = ${PHPCBF_EXIT_CODE} ... phpcbf wasn't idle" - vendor/bin/phpcs --extensions="${{ inputs.extensions }}" . --standard="$use_standard" --ignore="${{ inputs.ignore }}" || MORE_ISSUES=true + vendor/bin/phpcs --extensions="${{ inputs.extensions }}" . --standard="${{ env.USE_STANDARD }}" --ignore="${{ inputs.ignore }}" || MORE_ISSUES=true # because of `||`, the previous command always exit 0 if [ "${MORE_ISSUES}" = "true" ]; then echo "::warning title=Some phpcs issues remained.::Some phpcs issues remained. Manual fix necessary." From 59911618d9b5bd25a1ed5ae44f0197466e074237 Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 1 Feb 2025 10:17:33 +0100 Subject: [PATCH 13/16] Update CHANGELOG.md --- CHANGELOG.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 191a7e6..66f2b88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Added` for new features -- The new boolean input `stop-on-manual-fix` will cause the workflow to stop (fail) if manual fixes are necessary. -- Also stop with an error if some manual fixes are required on top of automatic fixes. - ### `Changed` for changes in existing functionality ### `Deprecated` for soon-to-be removed features @@ -22,6 +19,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Security` in case of vulnerabilities +## [1.1.0] - 2025-02-01 + +### Added + +- The new boolean input `stop-on-manual-fix` will cause the workflow to stop (fail) if manual fixes are necessary. +- Also stop with an error if some manual fixes are required on top of automatic fixes. +- Cache `vendor/` (for a unique combination of php-version and composer.json) after a successful run in order to speed up further runs. + ## [1.0.0] - 2025-01-18 - This GitHub Action automates PHPCS formatting across your project, ensuring consistent code styling by creating a new branch for review when necessary. It simplifies integrating PHPCS/PHPCBF into your workflow. @@ -33,5 +38,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Notice about a successful commit. - **Checkout code**: Fetches the latest changes so that modifications from a previous job are included, enabling seamless job chaining. -[Unreleased]: https://github.com/WorkOfStan/phpcs-fix/compare/v1.0.0...HEAD?w=1 +[Unreleased]: https://github.com/WorkOfStan/phpcs-fix/compare/v1.1.0...HEAD?w=1 +[1.1.0]: https://github.com/WorkOfStan/phpcs-fix/compare/v1.0.0...v1.1.0?w=1 [1.0.0]: https://github.com/WorkOfStan/phpcs-fix/releases/tag/v1.0.0 From e999f09d454d9357b0f38c62ea13c900e058b293 Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 1 Feb 2025 10:21:37 +0100 Subject: [PATCH 14/16] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fd93a27..6211869 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ This action can either commit changes directly to the current branch or create a - **Automatic Fixes:** Check PHP files for coding standard violations and attempts to automatically fix them when possible. - **Flexible Committing:** Creates a new branch (prefixed with `phpcbf/fix`) if changes are required, making it easy to review and merge. Or you can set the input parameter `commit-changes: true` to commit to the current branch. (Recommendation: start with committing to another branch and review in order to avoid surprises. Then commit to the same branch for incremental changes.) - **Configurable:** Adjust extensions, ignore and standard parameters of phpcs. Adjust PHP version, or commit-message. +- **Caching:** Cache `vendor/` (for a unique combination of php-version and composer.json) after a successful run in order to speed up further runs. +- **Action chain:** Either leave this GitHub Action non-blocking or set `stop-on-manual-fix` according to your automation process needs. ## Usage From 96b3244ab44314a3a0f096cdda900ebd9215b4b7 Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 1 Feb 2025 10:25:56 +0100 Subject: [PATCH 15/16] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6211869..40988e5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This action can either commit changes directly to the current branch or create a - **Flexible Committing:** Creates a new branch (prefixed with `phpcbf/fix`) if changes are required, making it easy to review and merge. Or you can set the input parameter `commit-changes: true` to commit to the current branch. (Recommendation: start with committing to another branch and review in order to avoid surprises. Then commit to the same branch for incremental changes.) - **Configurable:** Adjust extensions, ignore and standard parameters of phpcs. Adjust PHP version, or commit-message. - **Caching:** Cache `vendor/` (for a unique combination of php-version and composer.json) after a successful run in order to speed up further runs. -- **Action chain:** Either leave this GitHub Action non-blocking or set `stop-on-manual-fix` according to your automation process needs. +- **GitHub Action Chain:** Either leave this GitHub Action non-blocking or set `stop-on-manual-fix` according to your automation process needs. ## Usage From 46fe38d1afdde43d0a059209a3dde7d2e7ecd5de Mon Sep 17 00:00:00 2001 From: WorkOfStan Date: Sat, 1 Feb 2025 17:13:30 +0100 Subject: [PATCH 16/16] 1.0.0 --- .github/workflows/polish-the-code.yml | 6 +++--- CHANGELOG.md | 15 ++++----------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/polish-the-code.yml b/.github/workflows/polish-the-code.yml index d259027..613e58f 100644 --- a/.github/workflows/polish-the-code.yml +++ b/.github/workflows/polish-the-code.yml @@ -19,14 +19,14 @@ permissions: jobs: prettier-fix: # Note: runs-on doesn't accept all expressions, so a string is used - runs-on: "ubuntu-24.04" + runs-on: "ubuntu-latest" permissions: contents: write # Limit the running time timeout-minutes: 10 steps: - name: Invoke the Prettier fix - uses: WorkOfStan/prettier-fix@v1.1.0 + uses: WorkOfStan/prettier-fix@v1.1.1 with: commit-changes: true @@ -34,4 +34,4 @@ jobs: needs: prettier-fix uses: WorkOfStan/seablast-actions/.github/workflows/linter.yml@v0.2.1 with: - runs-on: "ubuntu-24.04" + runs-on: "ubuntu-latest" diff --git a/CHANGELOG.md b/CHANGELOG.md index 66f2b88..cd0d802 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,15 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### `Security` in case of vulnerabilities -## [1.1.0] - 2025-02-01 - -### Added - -- The new boolean input `stop-on-manual-fix` will cause the workflow to stop (fail) if manual fixes are necessary. -- Also stop with an error if some manual fixes are required on top of automatic fixes. -- Cache `vendor/` (for a unique combination of php-version and composer.json) after a successful run in order to speed up further runs. - -## [1.0.0] - 2025-01-18 +## [1.0.0] - 2025-02-01 - This GitHub Action automates PHPCS formatting across your project, ensuring consistent code styling by creating a new branch for review when necessary. It simplifies integrating PHPCS/PHPCBF into your workflow. - A warning appears in the GitHub Actions Annotations section if changes occur and therefore a new branch is created. @@ -37,7 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **Branch Name Output**: The `branch-name` is provided as an output for downstream workflows. - Notice about a successful commit. - **Checkout code**: Fetches the latest changes so that modifications from a previous job are included, enabling seamless job chaining. +- The new boolean input `stop-on-manual-fix` will cause the workflow to stop (fail) if manual fixes are necessary. (Also stops with an error if some manual fixes are required on top of automatic fixes.) +- Cached `vendor/` (for a unique combination of php-version and composer.json) after a successful run in order to speed up further runs. -[Unreleased]: https://github.com/WorkOfStan/phpcs-fix/compare/v1.1.0...HEAD?w=1 -[1.1.0]: https://github.com/WorkOfStan/phpcs-fix/compare/v1.0.0...v1.1.0?w=1 +[Unreleased]: https://github.com/WorkOfStan/phpcs-fix/compare/v1.0.0...HEAD?w=1 [1.0.0]: https://github.com/WorkOfStan/phpcs-fix/releases/tag/v1.0.0