From a91b4277b9f4d4540d6aee420f944424fcf433c7 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sun, 15 May 2022 12:24:23 +0700 Subject: [PATCH 1/8] generate json report --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8998eeb..098450c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -43,9 +43,9 @@ else fi if [ "${HAS_CONFIG}" = true ] && [ "${INPUT_USE_LOCAL_CONFIG}" = "true" ] ; then - ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle + ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --report-json=./phpcs.json else - ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} + ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --report-json=./phpcs.json --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} fi status=$? From 02070e0a0c0894796e5395ba41432416f5d7fa15 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sun, 15 May 2022 12:32:09 +0700 Subject: [PATCH 2/8] try generate md and add it to gh action summary --- entrypoint.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 098450c..5dab4a5 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -48,6 +48,9 @@ else ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --report-json=./phpcs.json --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} fi +npx github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md +cat phpcs.md >> $GITHUB_STEP_SUMMARY + status=$? echo "::remove-matcher owner=phpcs::" From b6323b0fdfd7aaefbb68da82790f47a934df2120 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sun, 15 May 2022 12:47:56 +0700 Subject: [PATCH 3/8] add node --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 1fa60a3..bcb4f13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ RUN chmod +x /action/entrypoint.sh RUN apk update && \ apk upgrade && \ + apk add node && \ apk add git ENTRYPOINT ["/action/entrypoint.sh"] From 8eaa9c8102a73ed48085d4bddcf990e625e32c24 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sun, 15 May 2022 12:50:13 +0700 Subject: [PATCH 4/8] don't update summary inside actions --- Dockerfile | 1 - entrypoint.sh | 3 --- 2 files changed, 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index bcb4f13..1fa60a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,6 @@ RUN chmod +x /action/entrypoint.sh RUN apk update && \ apk upgrade && \ - apk add node && \ apk add git ENTRYPOINT ["/action/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 5dab4a5..098450c 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -48,9 +48,6 @@ else ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --report-json=./phpcs.json --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} fi -npx github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md -cat phpcs.md >> $GITHUB_STEP_SUMMARY - status=$? echo "::remove-matcher owner=phpcs::" From d7cb288397cc9b2a8eee5f959f09ac271b4048be Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sun, 15 May 2022 13:40:05 +0700 Subject: [PATCH 5/8] create extra_args flag to passing custom arguments --- action.yml | 4 ++++ entrypoint.sh | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 281eed9..a0a306e 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,10 @@ inputs: description: 'Use local config if available' required: false default: 'false' + extra_args: + description: 'Passing extra arguments to the phpcs command' + required: false + default: '' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 098450c..a85d837 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -43,9 +43,9 @@ else fi if [ "${HAS_CONFIG}" = true ] && [ "${INPUT_USE_LOCAL_CONFIG}" = "true" ] ; then - ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --report-json=./phpcs.json + ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle ${EXTRA_ARGS} else - ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --report-json=./phpcs.json --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} + ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} ${EXTRA_ARGS} fi status=$? From a11d824f23339925acbe8bc86a0ec31990ed0d35 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sun, 15 May 2022 13:43:34 +0700 Subject: [PATCH 6/8] update readme --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index ecbfdbd..f1153d2 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Available options (with default value): repo_branch: 'master' # Branch of Standard repository phpcs_bin_path: 'phpcs' # Custom PHPCS bin path use_local_config: 'false' # Use local config if available + extra_args: '' # Extra arguments passing to the command ``` ## Examples @@ -77,6 +78,30 @@ jobs: with: standard: 'WordPress-VIP-Go' ``` +### Display the linting result in the GitHub Actions summary + +```yaml +name: WPCS check + +on: pull_request + +jobs: + phpcs: + name: VIPCS + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: VIPCS check + uses: 10up/wpcs-action@stable + with: + standard: 'WordPress-VIP-Go' + extra_args: '--report-json=./phpcs.json' + - name: Update summary + run: | + npx github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md + cat phpcs.md >> $GITHUB_STEP_SUMMARY + if: always() +``` ## Support Level From ebf8ffddf4bb895db97c1b444faacb7edaf84bf2 Mon Sep 17 00:00:00 2001 From: Tung Du Date: Sun, 15 May 2022 14:32:52 +0700 Subject: [PATCH 7/8] fix flag variable name --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index a85d837..71e1d88 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -43,9 +43,9 @@ else fi if [ "${HAS_CONFIG}" = true ] && [ "${INPUT_USE_LOCAL_CONFIG}" = "true" ] ; then - ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle ${EXTRA_ARGS} + ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle ${INPUT_EXTRA_ARGS} else - ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} ${EXTRA_ARGS} + ${INPUT_PHPCS_BIN_PATH} ${WARNING_FLAG} --report=checkstyle --standard=${INPUT_STANDARD} --ignore=${EXCLUDES} --extensions=php ${INPUT_PATHS} ${INPUT_EXTRA_ARGS} fi status=$? From 9ca2affe6be39bee189a157dfc361a22cc8db69f Mon Sep 17 00:00:00 2001 From: Tung Du Date: Mon, 16 May 2022 15:35:07 +0700 Subject: [PATCH 8/8] force downloading the package --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f1153d2..ab0fb41 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ jobs: extra_args: '--report-json=./phpcs.json' - name: Update summary run: | - npx github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md + npx --yes github:10up/phpcs-json-to-md --path ./phpcs.json --output ./phpcs.md cat phpcs.md >> $GITHUB_STEP_SUMMARY if: always() ```