-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from rojopolis/issue213
Addressing issue 213
- Loading branch information
Showing
5 changed files
with
128 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,14 @@ LABEL "com.github.actions.description"="Check spelling of files in repository" | |
LABEL "com.github.actions.icon"="clipboard" | ||
LABEL "com.github.actions.color"="green" | ||
LABEL "repository"="https://github.com/rojopolis/spellcheck-github-actions" | ||
LABEL "homepage"="http://github.com/actions" | ||
LABEL "homepage"="https://github.com/marketplace/actions/github-spellcheck-action" | ||
LABEL "maintainer"="rojopolis <[email protected]>" | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
COPY requirements.txt /requirements.txt | ||
COPY constraint.txt /constraint.txt | ||
COPY spellcheck.yaml /spellcheck.yaml | ||
COPY pwc.py /pwc.py | ||
|
||
ENV PIP_CONSTRAINT=/constraint.txt | ||
RUN pip3 install -r /requirements.txt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!python3 | ||
|
||
# This little helper script was implemented to extract the sources from the spellcheck configuration file | ||
# The name pwc comes from Python WCMatch, which is used to match the files against the sources | ||
# That is the short name I call it PriceWaterhouseCoopers, since it revises the file listing | ||
|
||
# read file and interpret it as yaml | ||
def read_yaml(file): | ||
|
||
with open(file) as f: | ||
data = yaml.safe_load(f) | ||
return data | ||
|
||
import sys | ||
import yaml | ||
from wcmatch import glob | ||
|
||
# read filename from command line as first argument | ||
spellcheck_configuration_file = sys.argv[1] | ||
|
||
data = read_yaml(spellcheck_configuration_file) | ||
|
||
# fetch the sources from the YAML data | ||
sources = data.get('matrix')[0].get('sources') | ||
|
||
for changed_file in sys.stdin: | ||
if 'q' == changed_file.rstrip(): | ||
break | ||
changed_file = changed_file.rstrip() | ||
|
||
matched = glob.globmatch(changed_file, sources, flags=glob.NEGATE | glob.GLOBSTAR | glob.SPLIT) | ||
|
||
if matched: | ||
exit(0) | ||
else: | ||
exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@test "can do basic run using Docker image with two input files" { | ||
docker run -e INPUT_SOURCE_FILES="README.md CHANGELOG.md" \ | ||
-e INPUT_TASK_NAME=Markdown -it -v $PWD:/tmp \ | ||
jonasbn/github-action-spellcheck:local | ||
} | ||
|
||
@test "can do basic run using Docker image with unignored and ignored input files" { | ||
docker run -e INPUT_SOURCE_FILES="README.md venv/lib/python3.13/site-packages/pyspelling-2.10.dist-info/licenses/LICENSE.md" \ | ||
-e INPUT_TASK_NAME=Markdown -it -v $PWD:/tmp \ | ||
jonasbn/github-action-spellcheck:local | ||
} | ||
|
||
@test "can do basic run using Docker image with just ignored input file" { | ||
docker run -e INPUT_SOURCE_FILES="venv/lib/python3.13/site-packages/pyspelling-2.10.dist-info/licenses/LICENSE.md" \ | ||
-e INPUT_TASK_NAME=Markdown -it -v $PWD:/tmp \ | ||
jonasbn/github-action-spellcheck:local | ||
} | ||
|
||
@test "can do basic run using Docker image without any input files" { | ||
docker run \ | ||
-e INPUT_TASK_NAME=Markdown -it -v $PWD:/tmp \ | ||
jonasbn/github-action-spellcheck:local | ||
} | ||
|
||
@test "can do basic run using Docker image without task parameter" { | ||
docker run \ | ||
-it -v $PWD:/tmp \ | ||
jonasbn/github-action-spellcheck:local | ||
} | ||
|
||
@test "can do basic run using Docker image with two input files but not task parameter" { | ||
! docker run -e INPUT_SOURCE_FILES="README.md CHANGELOG.md" \ | ||
-it -v $PWD:/tmp \ | ||
jonasbn/github-action-spellcheck:local | ||
} | ||
|
||
@test "can do basic run using Docker image with two non-existing input files" { | ||
! docker run -e INPUT_SOURCE_FILES="DONOTREADME.md LOGCHANGE.md" \ | ||
-e INPUT_TASK_NAME=Markdown -it -v $PWD:/tmp \ | ||
jonasbn/github-action-spellcheck:local | ||
} |