diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fd83b11 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +# See: https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#about-the-dependabotyml-file +version: 2 + +updates: + # Configure check for outdated GitHub Actions actions in workflows. + # See: https://docs.github.com/code-security/dependabot/working-with-dependabot/keeping-your-actions-up-to-date-with-dependabot + - package-ecosystem: github-actions + directory: / # Check the repository's workflows under /.github/workflows/ + schedule: + interval: daily diff --git a/.github/workflows/publish_master.yml b/.github/workflows/publish_master.yml index b3c89b7..f38f0de 100644 --- a/.github/workflows/publish_master.yml +++ b/.github/workflows/publish_master.yml @@ -13,7 +13,7 @@ jobs: name: Publish master image runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Build run: | GITHUB_REPOSITORY_LC=$(echo "${GITHUB_REPOSITORY}" | tr [A-Z] [a-z]) diff --git a/.github/workflows/publish_stable.yml b/.github/workflows/publish_stable.yml index d787bd9..4aabefa 100644 --- a/.github/workflows/publish_stable.yml +++ b/.github/workflows/publish_stable.yml @@ -10,7 +10,7 @@ jobs: name: Publish stable image runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Build run: | GITHUB_REPOSITORY_LC=$(echo "${GITHUB_REPOSITORY}" | tr [A-Z] [a-z]) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 697e178..62ca0bf 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -19,13 +19,18 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 + with: + python-version: '3.10' - name: Install codespell via pip using ${{ matrix.codespell_pip_version }} - run: pip3 --quiet --quiet install ${{ matrix.codespell_pip_version }} + run: pip install ${{ matrix.codespell_pip_version }} + + - name: Check codespell + run: codespell --version - name: Install Bats run: | @@ -43,7 +48,7 @@ jobs: name: Test run action runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ./ with: path: test/testdata @@ -53,26 +58,39 @@ jobs: name: Check for spelling errors runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ./ with: check_filenames: true check_hidden: true # When using this Action in other repos, the --skip option below can be removed - skip: ./.git,./codespell-problem-matcher/test,./test + skip: ./.git,./codespell-problem-matcher/test,./test,./README.md,./.github/workflows/testing.yml,./.pre-commit-config.yaml + # Check our README (and this workflow) ignoring the two intentional typos + - uses: ./ + with: + check_filenames: true + check_hidden: true + path: ./README.md,./.github/workflows/testing.yml + ignore_words_list: abandonned,ackward diagnose_bats: name: Diagnose bats + needs: test + if: always() && needs.test.result == 'failure' runs-on: ubuntu-latest continue-on-error: true + strategy: + fail-fast: false + matrix: + codespell_pip_version: ['codespell'] + include: + - codespell_pip_version: 'git+https://github.com/codespell-project/codespell.git' steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 - - run: pip3 --quiet --quiet install git+https://github.com/codespell-project/codespell.git + uses: actions/setup-python@v5 + - 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/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4c71139 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,8 @@ +repos: + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: [--ignore-words-list, "abandonned,ackward,bu"] + additional_dependencies: + - tomli diff --git a/README.md b/README.md index 8f683f2..f388c87 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ Any warnings or errors will be annotated in the Pull Request. ## Usage -``` -uses: codespell-project/actions-codespell@master +```yml +uses: codespell-project/actions-codespell@v2 ``` ### Parameter: check_filenames @@ -15,8 +15,8 @@ If set, check file names for speling mistakes as well. This parameter is optional; by default `codespell` will only check the file contents. -``` -uses: codespell-project/actions-codespell@master +```yml +uses: codespell-project/actions-codespell@v2 with: check_filenames: true ``` @@ -27,8 +27,8 @@ If set, check hidden files (those starting with ".") for spelling mistakes as we This parameter is optional; by default `codespell` will not check hidden files. -``` -uses: codespell-project/actions-codespell@master +```yml +uses: codespell-project/actions-codespell@v2 with: check_hidden: true ``` @@ -39,8 +39,8 @@ File with lines that should not be checked for spelling mistakes. This parameter is optional; by default `codespell` will check all lines. -``` -uses: codespell-project/actions-codespell@master +```yml +uses: codespell-project/actions-codespell@v2 with: exclude_file: src/foo ``` @@ -51,12 +51,64 @@ Comma-separated list of files to skip (it accepts globs as well). This parameter is optional; by default `codespell` won't skip any files. -``` -uses: codespell-project/actions-codespell@master +```yml +uses: codespell-project/actions-codespell@v2 with: skip: foo,bar ``` +### Parameter: builtin + +Comma-separated list of builtin dictionaries to use. + +This parameter is optional; by default `codespell` will use its default selection of built in dictionaries. + +```yml +uses: codespell-project/actions-codespell@v2 +with: + builtin: clear,rare +``` + +### Parameter: ignore_words_file + +File that contains words which will be ignored by `codespell`. File must contain one word per line. +Words are case sensitive based on how they are written in the dictionary file. + +This parameter is optional; by default `codespell` will check all words for typos. + +```yml +uses: codespell-project/actions-codespell@v2 +with: + ignore_words_file: .codespellignore +``` + +### Parameter: ignore_words_list + +Comma-separated list of words which will be ignored by `codespell`. +Words are case sensitive based on how they are written in the dictionary file. + +This parameter is optional; by default `codespell` will check all words for typos. + +```yml +uses: codespell-project/actions-codespell@v2 +with: + ignore_words_list: abandonned,ackward +``` + +### Parameter: uri_ignore_words_list + +Comma-separated list of words which will be ignored by `codespell` in URIs and emails only. +Words are case sensitive based on how they are written in the dictionary file. +If set to "*", all misspelling in URIs and emails will be ignored. + +This parameter is optional; by default `codespell` will check all URIs and emails for typos. + +```yml +uses: codespell-project/actions-codespell@v2 +with: + uri_ignore_words_list: abandonned +``` + ### Parameter: path Indicates the path to run `codespell` in. @@ -64,8 +116,8 @@ This can be useful if your project has code you don't want to spell check for so This parameter is optional; by default `codespell` will run on your whole repository. -``` -uses: codespell-project/actions-codespell@master +```yml +uses: codespell-project/actions-codespell@v2 with: path: src ``` @@ -78,8 +130,8 @@ All errors and warnings are annotated in Pull Requests, but it will act like eve This parameter is optional; setting this to any value will enable it. -``` -uses: codespell-project/actions-codespell@master +```yml +uses: codespell-project/actions-codespell@v2 with: only_warn: 1 ``` diff --git a/action.yml b/action.yml index e900b00..59e4372 100644 --- a/action.yml +++ b/action.yml @@ -23,11 +23,15 @@ inputs: required: false default: '' ignore_words_file: - description: 'File with a list of words to be ignored' + description: 'File with a list of words to be ignored. Words are case sensitive based on how they are written in the dictionary file' required: false default: '' ignore_words_list: - description: 'Comma-separated list of words to be ignored' + description: 'Comma-separated list of words to be ignored. Words are case sensitive based on how they are written in the dictionary file' + required: false + default: '' + uri_ignore_words_list: + description: 'comma separated list of words to be ignored in URIs and emails only' required: false default: '' path: diff --git a/codespell-problem-matcher/.github/workflows/test.yml b/codespell-problem-matcher/.github/workflows/test.yml index 5116018..39afde8 100644 --- a/codespell-problem-matcher/.github/workflows/test.yml +++ b/codespell-problem-matcher/.github/workflows/test.yml @@ -25,7 +25,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@master - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v4 + with: + python-version:3.x - run: pip install git+https://github.com/codespell-project/codespell.git - uses: ./ - name: Check codespell diff --git a/codespell-problem-matcher/action.yml b/codespell-problem-matcher/action.yml index 6d34e83..eb40b8d 100644 --- a/codespell-problem-matcher/action.yml +++ b/codespell-problem-matcher/action.yml @@ -2,7 +2,7 @@ name: 'codespell problem matcher' author: 'Peter Newman' description: 'Shows codespell errors as annotation (with file and code line) in GitHub Actions' runs: - using: 'node12' + using: 'node20' main: 'index.js' branding: icon: 'search' diff --git a/entrypoint.sh b/entrypoint.sh index 0fc188f..7c3d4ed 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -40,6 +40,10 @@ echo "Ignore words list '${INPUT_IGNORE_WORDS_LIST}'" if [ "x${INPUT_IGNORE_WORDS_LIST}" != "x" ]; then command_args="${command_args} --ignore-words-list ${INPUT_IGNORE_WORDS_LIST}" fi +echo "Ignore URI words list '${INPUT_URI_IGNORE_WORDS_LIST}'" +if [ "x${INPUT_URI_IGNORE_WORDS_LIST}" != "x" ]; then + command_args="${command_args} --uri-ignore-words-list ${INPUT_URI_IGNORE_WORDS_LIST}" +fi echo "Resulting CLI options ${command_args}" exec 5>&1 res=`{ { codespell --count ${command_args} ${INPUT_PATH}; echo $? 1>&4; } 1>&5; } 4>&1` diff --git a/requirements.txt b/requirements.txt index 84d2ed8..291f885 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -codespell>=2.0.0 +codespell[toml]>=2.2.4 diff --git a/test/test.bats b/test/test.bats index db7ac8f..119bc5b 100644 --- a/test/test.bats +++ b/test/test.bats @@ -7,12 +7,13 @@ # This currently breaks the tests, so only enabling when troubleshooting #load teardown -ROOT_MISSPELLING_COUNT=5 +ROOT_MISSPELLING_COUNT=6 FILENAME_MISSPELLING_COUNT=1 HIDDEN_MISSPELLING_COUNT=1 EXCLUDED_MISSPELLING_COUNT=1 BUILTIN_NAMES_MISSPELLING_COUNT=1 IGNORE_WORDS_MISSPELLING_COUNT=5 +URI_IGNORE_WORDS_MISSPELLING_COUNT=1 SUBFOLDER_MISSPELLING_COUNT=1 # From all files called example.txt EXAMPLE_MISSPELLING_COUNT=5 @@ -40,6 +41,7 @@ function setup() { export INPUT_BUILTIN="" export INPUT_IGNORE_WORDS_FILE="" export INPUT_IGNORE_WORDS_LIST="" + export INPUT_URI_IGNORE_WORDS_LIST="" export INPUT_PATH="./test/testdata" export INPUT_ONLY_WARN="" } @@ -103,7 +105,7 @@ function setup() { } @test "Check the skip option" { - errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - EXAMPLE_MISSPELLING_COUNT)) + errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - EXAMPLE_MISSPELLING_COUNT - URI_IGNORE_WORDS_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_SKIP="example.txt" @@ -142,6 +144,16 @@ function setup() { [ "${lines[-4 - $errorCount]}" == "$errorCount" ] } +@test "Use a URI ignore words list" { + errorCount=$((ROOT_MISSPELLING_COUNT + SUBFOLDER_MISSPELLING_COUNT - URI_IGNORE_WORDS_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_URI_IGNORE_WORDS_LIST="bu" + run "./entrypoint.sh" + [ $status -eq $expectedExitStatus ] + [ "${lines[-4 - $errorCount]}" == "$errorCount" ] +} + @test "Custom path" { errorCount=$((SUBFOLDER_MISSPELLING_COUNT)) # codespell's exit status is 0, or 65 if there are errors found diff --git a/test/testdata/example.txt b/test/testdata/example.txt index e1118f6..f27e93b 100644 --- a/test/testdata/example.txt +++ b/test/testdata/example.txt @@ -2,3 +2,4 @@ Abandonned ABANDONNED AbAnDoNnEd +https://www.bu.edu