From 95898014211a0b63b0b22a95135636bb70065b87 Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Tue, 12 May 2020 19:12:41 +0100 Subject: [PATCH] Initial attempt at converting flake8 codebase to run codespell instead --- Dockerfile | 2 +- LICENSE | 3 ++- README.md | 18 +++++++++--------- action.yml | 8 ++++---- flake8-matcher.json => codespell-matcher.json | 2 +- entrypoint.sh | 18 +++++++++--------- example/example.py | 5 ----- example/example.txt | 4 ++++ requirements.txt | 2 +- 9 files changed, 31 insertions(+), 31 deletions(-) rename flake8-matcher.json => codespell-matcher.json (91%) delete mode 100644 example/example.py create mode 100644 example/example.txt diff --git a/Dockerfile b/Dockerfile index 240ed43..3c04f03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.8-alpine COPY LICENSE \ README.md \ entrypoint.sh \ - flake8-matcher.json \ + codespell-matcher.json \ requirements.txt \ /code/ diff --git a/LICENSE b/LICENSE index c83254c..4110bbd 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ The MIT License -Copyright (c) 2019, Patric "TrueBrain" Stout +Copyright (c) 2020 Peter Newman +Based on flake8 code copyright 2019, Patric "TrueBrain" Stout Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index af68f7c..f0de7e8 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ -# Flake8 with GitHub Actions -- including annotations for Pull Requests +# Codespell with GitHub Actions -- including annotations for Pull Requests -This GitHub Actions runs flake8 over your code. -Any warnings or errors will be annoted in the Pull Request. +This GitHub Actions runs codespell over your code. +Any warnings or errors will be annotated in the Pull Request. ## Usage ``` -uses: TrueBrain/actions-flake8@master +uses: peternewman/actions-codespell@master ``` ### Parameter: path -Indicates the path to run `flake8` in. -This can be useful if your project is more than Python code. +Indicates the path to run `codespell` in. +This can be useful if your project has code you don't want to spell check for some reason. -This parameter is optional; by default `flake8` will run on your whole repository. +This parameter is optional; by default `codespell` will run on your whole repository. ``` -uses: TrueBrain/actions-flake8@master +uses: peternewman/actions-codespell@master with: path: src ``` @@ -31,7 +31,7 @@ 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: TrueBrain/actions-flake8@master +uses: peternewman/actions-codespell@master with: only_warn: 1 ``` diff --git a/action.yml b/action.yml index 42b35b3..5abf3bb 100644 --- a/action.yml +++ b/action.yml @@ -1,9 +1,9 @@ -name: 'Flake8 with annotations' -author: 'Patric "TrueBrain" Stout' -description: 'Flake8 with annotations for Pull Request' +name: 'Codespell with annotations' +author: 'Peter Newman' +description: 'Codespell with annotations for Pull Request' inputs: path: - description: 'Path to run flake8 in' + description: 'Path to run codespell in' requred: false default: '' only_warn: diff --git a/flake8-matcher.json b/codespell-matcher.json similarity index 91% rename from flake8-matcher.json rename to codespell-matcher.json index 9c998e9..ad2f414 100644 --- a/flake8-matcher.json +++ b/codespell-matcher.json @@ -1,7 +1,7 @@ { "problemMatcher": [ { - "owner": "flake8", + "owner": "codespell", "pattern": [ { "regexp": "^([^:]*):(\\d+):(\\d+): (error|warning): (\\w\\d\\d\\d) (.*)$", diff --git a/entrypoint.sh b/entrypoint.sh index 2f21f05..aae164a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,25 +1,25 @@ #!/bin/sh # Copy the matcher to the host system; otherwise "add-matcher" can't find it. -cp /code/flake8-matcher.json /github/workflow/flake8-matcher.json -echo "::add-matcher::${RUNNER_TEMP}/_github_workflow/flake8-matcher.json" +cp /code/codespell-matcher.json /github/workflow/codespell-matcher.json +echo "::add-matcher::${RUNNER_TEMP}/_github_workflow/codespell-matcher.json" -# Run flake8. We add 'error/warning' as GitHub Actions ProblemMatcher needs +# Run codespell. We add 'error/warning' as GitHub Actions ProblemMatcher needs # the text 'error/warning' to know how to classify it. -# The weird piping is needed because we want to get the exitcode from flake8, +# The weird piping is needed because we want to get the exitcode from codespell, # but there is no other good universal way of doing so. # e.g. PIPESTATUS and pipestatus only work in bash/zsh respectively. -echo "Running flake8 on '${INPUT_PATH}' ..." +echo "Running codespell on '${INPUT_PATH}' ..." exec 5>&1 -res=`{ { flake8 ${INPUT_PATH}; echo $? 1>&4; } | sed -r 's/: ([^W][0-9][0-9][0-9])/: error: \1/;s/: (W[0-9][0-9][0-9])/: warning: \1/' 1>&5; } 4>&1` +res=`{ { codespell ${INPUT_PATH}; echo $? 1>&4; } | sed -r 's/: ([^W][0-9][0-9][0-9])/: error: \1/;s/: (W[0-9][0-9][0-9])/: warning: \1/' 1>&5; } 4>&1` if [ "$res" = "0" ]; then - echo "Flake8 found no problems" + echo "Codespell found no problems" else - echo "Flake8 found one or more problems" + echo "Codespell found one or more problems" fi # Remove the matcher, so no other jobs hit it. -echo "::remove-matcher owner=flake8::" +echo "::remove-matcher owner=codespell::" # If we are in warn-only mode, return always as if we pass if [ -n "${INPUT_ONLY_WARN}" ]; then diff --git a/example/example.py b/example/example.py deleted file mode 100644 index 6e36ab9..0000000 --- a/example/example.py +++ /dev/null @@ -1,5 +0,0 @@ - -def test(): - pass -def test() : - pass diff --git a/example/example.txt b/example/example.txt new file mode 100644 index 0000000..024f418 --- /dev/null +++ b/example/example.txt @@ -0,0 +1,4 @@ +abandonned +Abandonned +ABANDONNED +AbAnDoNnEd diff --git a/requirements.txt b/requirements.txt index 5c71e7d..0a53b73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -flake8==3.7.9 +codespell==1.16.0