Initial attempt at converting flake8 codebase to run codespell instead
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ FROM python:3.8-alpine
|
||||
COPY LICENSE \
|
||||
README.md \
|
||||
entrypoint.sh \
|
||||
flake8-matcher.json \
|
||||
codespell-matcher.json \
|
||||
requirements.txt \
|
||||
/code/
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
```
|
||||
|
||||
+4
-4
@@ -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:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "flake8",
|
||||
"owner": "codespell",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^([^:]*):(\\d+):(\\d+): (error|warning): (\\w\\d\\d\\d) (.*)$",
|
||||
+9
-9
@@ -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
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
def test():
|
||||
pass
|
||||
def test() :
|
||||
pass
|
||||
@@ -0,0 +1,4 @@
|
||||
abandonned
|
||||
Abandonned
|
||||
ABANDONNED
|
||||
AbAnDoNnEd
|
||||
+1
-1
@@ -1 +1 @@
|
||||
flake8==3.7.9
|
||||
codespell==1.16.0
|
||||
|
||||
Reference in New Issue
Block a user