From 8884e74419388f97f2bc33f4aafd6c96d3842005 Mon Sep 17 00:00:00 2001 From: Mike Marschall Date: Thu, 18 Jun 2020 16:16:16 +0200 Subject: [PATCH 1/4] add environment variable to skip automatic linting of all PHP files --- README.md | 4 ++++ main.sh | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 099291c..6289574 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ jobs: env: GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} SKIP_FOLDERS: "tests,.github" + SKIP_LINT: "no" with: args: "WordPress,WordPress-Core,WordPress-Docs" ``` @@ -45,6 +46,8 @@ By default, pull request will be reviwed using WordPress coding and documentatio 4. In case you want to skip PHPCS scanning in any pull request, add `[do-not-scan]` in the PR description. You can add it anywhere in the description and it will skip the action run for that pull request. +5. In case you want to skip linting all files on every pull request, set `SKIP_LINT` to `1`, `yes` or `true`. + ## GitHub Token Creation You can create [GitHub Token from here](https://github.com/settings/tokens). @@ -64,6 +67,7 @@ Private | Complete `repo` and `write:discussion` permissions | [Screenshot Pr Variable | Default | Possible Values | Purpose ---------------|---------|-----------------------------|---------------------------------------------------- `SKIP_FOLDERS` | - | `tests`,`tests,.github` (Any other comma seprated top level directories in the repo) | If any specific folders should be ignored when scanning, then a comma seprated list of values should be added to this env variable. +`SKIP_LINT` | `no` | `1`, `yes`, `true` or any other value to indicate *false* | If the automatic linting of all PHP files should be deactivated, then this env variable should be set to a truthy value (see *Possible Values*). ## PHPCS Coding Standards diff --git a/main.sh b/main.sh index 3d1450a..49a59e2 100644 --- a/main.sh +++ b/main.sh @@ -69,7 +69,9 @@ fi /usr/games/cowsay "Running with the flag $phpcs_standard" +[[ ":1:yes:true:" = *:$SKIP_LINT:* ]] && lint_option='--lint=false' || lint_option='--lint=true' + echo "Running the following command" -echo "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$COMMIT_ID --token=\$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard $skip_folders_option --lint=true" +echo "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$COMMIT_ID --token=\$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard $skip_folders_option $lint_option" -gosu rtbot bash -c "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$COMMIT_ID --token=$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard $skip_folders_option --lint=true" +gosu rtbot bash -c "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$COMMIT_ID --token=$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard $skip_folders_option $lint_option" From dfe51c1da651774e983ea3af50bd5149ac3b8d62 Mon Sep 17 00:00:00 2001 From: Mike Marschall Date: Thu, 18 Jun 2020 16:16:33 +0200 Subject: [PATCH 2/4] bump version to v2.0.3 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 7cdc440..fa85d07 100644 --- a/action.yml +++ b/action.yml @@ -3,7 +3,7 @@ description: 'This will run phpcs on PRs' author: 'rtCamp' runs: using: 'docker' - image: 'docker://rtcamp/action-phpcs-code-review:v2.0.2' + image: 'docker://rtcamp/action-phpcs-code-review:v2.0.3' branding: icon: 'check-circle' color: 'green' From e6bc4d972c0b41f572ce563fca449941e4889e83 Mon Sep 17 00:00:00 2001 From: Mike Marschall Date: Thu, 25 Jun 2020 13:17:57 +0200 Subject: [PATCH 3/4] allow explicit passing of boolean flag for php linting (true by default), rename env variable accordingly --- README.md | 3 +-- main.sh | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6289574..2d3c7ef 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ jobs: env: GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} SKIP_FOLDERS: "tests,.github" - SKIP_LINT: "no" with: args: "WordPress,WordPress-Core,WordPress-Docs" ``` @@ -67,7 +66,7 @@ Private | Complete `repo` and `write:discussion` permissions | [Screenshot Pr Variable | Default | Possible Values | Purpose ---------------|---------|-----------------------------|---------------------------------------------------- `SKIP_FOLDERS` | - | `tests`,`tests,.github` (Any other comma seprated top level directories in the repo) | If any specific folders should be ignored when scanning, then a comma seprated list of values should be added to this env variable. -`SKIP_LINT` | `no` | `1`, `yes`, `true` or any other value to indicate *false* | If the automatic linting of all PHP files should be deactivated, then this env variable should be set to a truthy value (see *Possible Values*). +`PHP_LINT` | `true` | `true` or `false`, *case insensitive* (Any unknown value is the same as passing `true`) | If the default automatic linting of all PHP files should be deactivated, then this env variable should be set to `false`. ## PHPCS Coding Standards diff --git a/main.sh b/main.sh index 49a59e2..1d18f31 100644 --- a/main.sh +++ b/main.sh @@ -69,9 +69,12 @@ fi /usr/games/cowsay "Running with the flag $phpcs_standard" -[[ ":1:yes:true:" = *:$SKIP_LINT:* ]] && lint_option='--lint=false' || lint_option='--lint=true' +php_lint_option='--lint=true' +if [[ "$(echo "$PHP_LINT" | tr '[:upper:]' '[:lower:]')" = 'false' ]]; then + php_lint_option='--lint=false' +fi echo "Running the following command" -echo "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$COMMIT_ID --token=\$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard $skip_folders_option $lint_option" +echo "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$COMMIT_ID --token=\$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard $skip_folders_option $php_lint_option" -gosu rtbot bash -c "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$COMMIT_ID --token=$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard $skip_folders_option $lint_option" +gosu rtbot bash -c "/home/rtbot/vip-go-ci-tools/vip-go-ci/vip-go-ci.php --repo-owner=$GITHUB_REPO_OWNER --repo-name=$GITHUB_REPO_NAME --commit=$COMMIT_ID --token=$GH_BOT_TOKEN --phpcs-path=/home/rtbot/vip-go-ci-tools/phpcs/bin/phpcs --local-git-repo=/home/rtbot/github-workspace --phpcs=true $phpcs_standard $skip_folders_option $php_lint_option" From 21e70b2dddbacaa617762dc9142e908ed09a0e45 Mon Sep 17 00:00:00 2001 From: Mike Marschall <42121690+MikeMarschall@users.noreply.github.com> Date: Thu, 25 Jun 2020 13:34:37 +0200 Subject: [PATCH 4/4] Use correct env variable name in README.md Co-authored-by: Riddhesh Sanghvi --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2d3c7ef..2b2007b 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ By default, pull request will be reviwed using WordPress coding and documentatio 4. In case you want to skip PHPCS scanning in any pull request, add `[do-not-scan]` in the PR description. You can add it anywhere in the description and it will skip the action run for that pull request. -5. In case you want to skip linting all files on every pull request, set `SKIP_LINT` to `1`, `yes` or `true`. +5. In case you want to skip linting all files on every pull request, set `PHP_LINT` to `false`. ## GitHub Token Creation