From dfae4d5bb4406de20e9e29f1fb82ecfd504ba37d Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 20 May 2020 19:56:51 +0100 Subject: [PATCH 1/5] Squashed 'codespell-problem-matcher/' content from commit b508e1b git-subtree-dir: codespell-problem-matcher git-subtree-split: b508e1bce5d902037845870f0b4cb75f57cd568d --- .github/workflows/test.yml | 20 ++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.md | 22 ++++++++++++++++++++++ action.yml | 9 +++++++++ codespell-matcher.json | 15 +++++++++++++++ index.js | 2 ++ test/test.txt | 4 ++++ test/test:2.txt | 1 + 8 files changed, 94 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 action.yml create mode 100644 codespell-matcher.json create mode 100755 index.js create mode 100644 test/test.txt create mode 100644 test/test:2.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..62878d2 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +name: Test +on: + push: + branches: + - master + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@master + - uses: actions/setup-python@v1 + - run: pip install codespell + - uses: ./ + - name: Check codespell + run: codespell test/test.txt || true + - name: Check codespell on an unusually named file + run: codespell test/test:2.txt || true diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b98f145 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Peter Newman, based on korelstar's xmllint-problem-matcher + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..5b399b0 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# codespell-problem-matcher + +This problem matcher lets you show errors from `codespell` as annotation in +GitHub Actions. + +Based on [korelstar](https://github.com/korelstar)'s [xmllint-problem-matcher](https://github.com/korelstar/xmllint-problem-matcher). + +## Inputs + +No inputs are required. + +## Outputs + +No outputs are generated apart from a configured problem matcher. + +## Usage + +Add the step to your workflow, before `codespell` is called. + +```yaml + - uses: codespell-project/codespell-problem-matcher@v1 +``` diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..6d34e83 --- /dev/null +++ b/action.yml @@ -0,0 +1,9 @@ +name: 'codespell problem matcher' +author: 'Peter Newman' +description: 'Shows codespell errors as annotation (with file and code line) in GitHub Actions' +runs: + using: 'node12' + main: 'index.js' +branding: + icon: 'search' + color: 'green' diff --git a/codespell-matcher.json b/codespell-matcher.json new file mode 100644 index 0000000..4ea7d93 --- /dev/null +++ b/codespell-matcher.json @@ -0,0 +1,15 @@ +{ + "problemMatcher": [ + { + "owner": "codespell-matcher", + "pattern": [ + { + "regexp": "^(.+):(\\d+):\\s+(.+)$", + "file": 1, + "line": 2, + "message": 3 + } + ] + } + ] +} diff --git a/index.js b/index.js new file mode 100755 index 0000000..b3552d0 --- /dev/null +++ b/index.js @@ -0,0 +1,2 @@ +#!/usr/bin/env node +console.log(`::add-matcher::${__dirname}/codespell-matcher.json`); diff --git a/test/test.txt b/test/test.txt new file mode 100644 index 0000000..024f418 --- /dev/null +++ b/test/test.txt @@ -0,0 +1,4 @@ +abandonned +Abandonned +ABANDONNED +AbAnDoNnEd diff --git a/test/test:2.txt b/test/test:2.txt new file mode 100644 index 0000000..50a0985 --- /dev/null +++ b/test/test:2.txt @@ -0,0 +1 @@ +It's ackward when you make a spelling mistake. From 8e164a7b5af673df49216b68c5c8f5cd64378d73 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 24 May 2020 14:08:59 +0100 Subject: [PATCH 2/5] Use the common matcher --- codespell-matcher.json | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 codespell-matcher.json diff --git a/codespell-matcher.json b/codespell-matcher.json deleted file mode 100644 index 5d2324e..0000000 --- a/codespell-matcher.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "problemMatcher": [ - { - "owner": "codespell", - "pattern": [ - { - "regexp": "^([^:]*):(\\d+): (.*)$", - "file": 1, - "line": 2, - "message": 3 - } - ] - } - ] -} From 793331e5ec74622db3b4bf512533389cd8fc88e9 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 24 May 2020 14:10:54 +0100 Subject: [PATCH 3/5] Actually use the common problem matcher --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index aae164a..af5ee83 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copy the matcher to the host system; otherwise "add-matcher" can't find it. -cp /code/codespell-matcher.json /github/workflow/codespell-matcher.json +cp /code/codespell-problem-matcher/codespell-matcher.json /github/workflow/codespell-matcher.json echo "::add-matcher::${RUNNER_TEMP}/_github_workflow/codespell-matcher.json" # Run codespell. We add 'error/warning' as GitHub Actions ProblemMatcher needs From 6005def6da95107090457a3833ae95c52df0a696 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 24 May 2020 14:13:34 +0100 Subject: [PATCH 4/5] Undo the change and correct it in the right place --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index af5ee83..aae164a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh # Copy the matcher to the host system; otherwise "add-matcher" can't find it. -cp /code/codespell-problem-matcher/codespell-matcher.json /github/workflow/codespell-matcher.json +cp /code/codespell-matcher.json /github/workflow/codespell-matcher.json echo "::add-matcher::${RUNNER_TEMP}/_github_workflow/codespell-matcher.json" # Run codespell. We add 'error/warning' as GitHub Actions ProblemMatcher needs From 4fedcc7dee0574d5601f2c797e3b1cbe33234435 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Sun, 24 May 2020 14:14:19 +0100 Subject: [PATCH 5/5] Move the file in the right place --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3c04f03..6c96f60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.8-alpine COPY LICENSE \ README.md \ entrypoint.sh \ - codespell-matcher.json \ + codespell-problem-matcher/codespell-matcher.json \ requirements.txt \ /code/