From 301f4dbd191e5c5babe98d162b9e069d61506385 Mon Sep 17 00:00:00 2001 From: Zaher Ghaibeh <27624+zaherg@users.noreply.github.com> Date: Tue, 21 Jun 2022 18:32:32 +0300 Subject: [PATCH] Make terms configurable (#3) Co-authored-by: Brian Bugh <438465+bbugh@users.noreply.github.com> --- .github/workflows/test.yml | 2 ++ Dockerfile | 2 +- README.md | 19 ++++++++++++++++--- action.yml | 8 +++++++- lib/entrypoint.sh | 4 ++-- 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a6c6ff4..8ef489a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,5 +12,7 @@ jobs: steps: - uses: actions/checkout@v1 - uses: ./ + with: + terms: "wip|fix|fixme" env: ENVIRONMENT: test diff --git a/Dockerfile b/Dockerfile index 4fff6f4..76625cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM alpine/git:1.0.7 LABEL com.github.actions.name="FIXME check" -LABEL com.github.actions.description="Check your code for `FIXME` labels" +LABEL com.github.actions.description="Check code for specific terms (FIXME, WIP, etc.) and fail (with code annotations) if any are found." LABEL com.github.actions.icon="code" LABEL com.github.actions.color="yellow" diff --git a/README.md b/README.md index aa5abbc..4369625 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # action-fixme-check -Checks the code base for any `FIXME:` (with the colon) and fails the check if -any are found. Useful if you want to make sure that you don't miss any required -changes in the code base before merging a PR. +Checks the code base for any terms ending with a colon, and fail the check if +any are found. The default term is `FIXME:`. You can add or change the terms +using the `term` parameter, see [Installation](#Installation) below. +Useful if you want to make sure that you don't miss any required changes in the +code base before merging a PR. It runs very fast, taking only a few seconds to finish even on a very large codebase. All files in the repository will be read, including binary files (it @@ -30,12 +32,23 @@ jobs: steps: - uses: actions/checkout@v1 - uses: bbugh/action-fixme-check@master # or @ the latest release + with: + terms: 'WIP|FIXME' # optional, defaults to `FIXME` ``` ## Support - [Official workflow configuration docs](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions) +## Testing words + +(Used for testing this action on itself.) + +- I am using `WIP:` here. +- I am using `FIXME:` here. +- Nothing to see here. +- I am using `FIX:` here. + ## License The `action-fixme-check` library is available as open source under the terms of diff --git a/action.yml b/action.yml index ee52056..9288a71 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ name: 'FIXME alert' -description: 'Check code for `FIXME:` and fail (with annotations) if any are found.' +description: 'Check code for specific terms (FIXME, WIP, etc.) and fail (with code annotations) if any are found.' author: '@bbugh' branding: icon: 'list' @@ -7,3 +7,9 @@ branding: runs: using: 'docker' image: 'Dockerfile' +inputs: + terms: + description: 'The pipe-delimited searchable terms to pass as a regex group to `git grep`.' + required: false + default: "FIXME" + diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh index 2647bcc..75d15b4 100755 --- a/lib/entrypoint.sh +++ b/lib/entrypoint.sh @@ -8,8 +8,8 @@ cp /git-grep-problem-matcher.json "$matcher_path" echo "::add-matcher::git-grep-problem-matcher.json" -tag="FIXME" -result=$(git grep --no-color -n -e "${tag}:") +tag=${INPUT_TERMS:=FIXME} +result=$(git grep --no-color --line-number --extended-regexp -e "(${tag})+(:)" :^.github) echo "${result}"