From 1515a0aaf771ac89df1ad61a7e5bd099a0f83a67 Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Sat, 14 Nov 2020 14:26:29 +0100 Subject: [PATCH 1/4] Add support for quiet level --- action.yml | 4 ++++ entrypoint.sh | 5 +++++ test/test.bats | 1 + 3 files changed, 10 insertions(+) diff --git a/action.yml b/action.yml index e900b00..2cd9379 100644 --- a/action.yml +++ b/action.yml @@ -10,6 +10,10 @@ inputs: description: 'If set, check hidden files (those starting with ".") as well' required: false default: '' + quiet_level: + description: 'Bitmask that allows suppressing messages' + required: false + default: '' exclude_file: description: 'File with lines that should not be checked for spelling mistakes' required: false diff --git a/entrypoint.sh b/entrypoint.sh index 1afc65c..8216f48 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -20,6 +20,11 @@ if [ -n "${INPUT_CHECK_HIDDEN}" ]; then echo "Checking hidden" command_args="${command_args} --check-hidden" fi +echo "Check quiet level? '${INPUT_QUIET_LEVEL}'" +if [ -n "${INPUT_QUIET_LEVEL}" ]; then + echo "Checking quiet level" + command_args="${command_args} --quiet-level ${INPUT_QUIET_LEVEL}" +fi echo "Exclude file '${INPUT_EXCLUDE_FILE}'" if [ "x${INPUT_EXCLUDE_FILE}" != "x" ]; then command_args="${command_args} --exclude-file ${INPUT_EXCLUDE_FILE}" diff --git a/test/test.bats b/test/test.bats index 51d0a69..4f4d7b3 100644 --- a/test/test.bats +++ b/test/test.bats @@ -20,6 +20,7 @@ function setup() { # Set default input values export INPUT_CHECK_FILENAMES="" export INPUT_CHECK_HIDDEN="" + export INPUT_QUIET_LEVEL="" export INPUT_EXCLUDE_FILE="" export INPUT_SKIP="" export INPUT_BUILTIN="" From 8687724368eecbf16335a57f9f501c0da0134be1 Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Mon, 1 Feb 2021 15:41:11 +0100 Subject: [PATCH 2/4] First try at testing --- test/test.bats | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test.bats b/test/test.bats index 898b53b..7f48b29 100644 --- a/test/test.bats +++ b/test/test.bats @@ -10,6 +10,7 @@ ROOT_MISSPELLING_COUNT=5 FILENAME_MISSPELLING_COUNT=1 HIDDEN_MISSPELLING_COUNT=1 +QUIET_LEVEL_MISSPELLING_COUNT=1 EXCLUDED_MISSPELLING_COUNT=1 BUILTIN_NAMES_MISSPELLING_COUNT=1 IGNORE_WORDS_MISSPELLING_COUNT=5 @@ -83,6 +84,17 @@ function setup() { [ "${lines[-4 - $errorCount]}" == "$errorCount" ] } +@test "Check quiet level" { + errorCount=$QUIET_LEVEL_MISSPELLING_COUNT + # codespell's exit status is 0, or 65 if there are errors found + if [ $errorCount -eq 0 ]; then expectedExitStatus=0; else expectedExitStatus=65; fi + INPUT_QUIET_LEVEL="0" + INPUT_PATH="./test/testdata/example.bin" + run "./entrypoint.sh" + [ $status -eq $expectedExitStatus ] + [ "${lines[-4 - $errorCount]}" == "$errorCount" ] +} + @test "Check a hidden file without INPUT_CHECK_HIDDEN set" { errorCount=0 # codespell's exit status is 0, or 65 if there are errors found From 19753a4e5c387275536d46992364415b171a213a Mon Sep 17 00:00:00 2001 From: Guillaume Favelier Date: Fri, 12 Feb 2021 16:55:05 +0100 Subject: [PATCH 3/4] Skip the bats diagnostics --- .github/workflows/testing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 34c4219..248bf3d 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -79,6 +79,8 @@ jobs: uses: actions/setup-python@v2 - run: pip3 --quiet --quiet install ${{ matrix.codespell_pip_version }} - run: | + # Skip the bats diagnostics + exit 0 # Simulate the Dockerfile COPY command [ -d "${RUNNER_TEMP}/code/" ] || sudo mkdir -p ${RUNNER_TEMP}/code/ [ -f "${RUNNER_TEMP}/code/codespell-matcher.json" ] || sudo cp codespell-problem-matcher/codespell-matcher.json ${RUNNER_TEMP}/code/ From d9c25251913f7a946e91ea85457a37b746c9a7d7 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Fri, 12 Feb 2021 17:23:41 +0000 Subject: [PATCH 4/4] Update the bats debugging for quiet mode testing --- .github/workflows/testing.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 248bf3d..57ecd38 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -79,8 +79,6 @@ jobs: uses: actions/setup-python@v2 - run: pip3 --quiet --quiet install ${{ matrix.codespell_pip_version }} - run: | - # Skip the bats diagnostics - exit 0 # Simulate the Dockerfile COPY command [ -d "${RUNNER_TEMP}/code/" ] || sudo mkdir -p ${RUNNER_TEMP}/code/ [ -f "${RUNNER_TEMP}/code/codespell-matcher.json" ] || sudo cp codespell-problem-matcher/codespell-matcher.json ${RUNNER_TEMP}/code/ @@ -93,10 +91,11 @@ jobs: #ls -alR /github/workflow/ export INPUT_CHECK_FILENAMES="" export INPUT_CHECK_HIDDEN="" + export INPUT_QUIET_LEVEL="0" export INPUT_EXCLUDE_FILE="" export INPUT_SKIP="" export INPUT_IGNORE_WORDS_FILE="./test/ignore-words-file.txt" export INPUT_IGNORE_WORDS_LIST="" - export INPUT_PATH="./test/testdata" + export INPUT_PATH="./test/testdata/example.bin" export INPUT_ONLY_WARN="" ./entrypoint.sh || echo $?