Skip to content

Commit 3d69009

Browse files
committed
init pytest as action
1 parent 5bd6f94 commit 3d69009

File tree

10 files changed

+536
-25
lines changed

10 files changed

+536
-25
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77
jobs:
88
test-check:
9-
name: runner / <linter-name> (github-check)
9+
name: runner / pytest (github-check)
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
@@ -19,7 +19,7 @@ jobs:
1919

2020
test-pr-check:
2121
if: github.event_name == 'pull_request'
22-
name: runner / <linter-name> (github-pr-check)
22+
name: runner / pytest (github-pr-check)
2323
runs-on: ubuntu-latest
2424
steps:
2525
- uses: actions/checkout@v2
@@ -33,7 +33,7 @@ jobs:
3333

3434
test-pr-review:
3535
if: github.event_name == 'pull_request'
36-
name: runner / <linter-name> (github-pr-review)
36+
name: runner / pytest (github-pr-review)
3737
runs-on: ubuntu-latest
3838
steps:
3939
- uses: actions/checkout@v2

.gitignore

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,155 @@
11
# Folders to ignore
2-
.vscode/
2+
.vscode/
3+
4+
# Byte-compiled / optimized / DLL files
5+
__pycache__/
6+
*.py[cod]
7+
*$py.class
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
share/python-wheels/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
MANIFEST
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
*.py,cover
53+
.hypothesis/
54+
.pytest_cache/
55+
cover/
56+
57+
# Translations
58+
*.mo
59+
*.pot
60+
61+
# Django stuff:
62+
*.log
63+
local_settings.py
64+
db.sqlite3
65+
db.sqlite3-journal
66+
67+
# Flask stuff:
68+
instance/
69+
.webassets-cache
70+
71+
# Scrapy stuff:
72+
.scrapy
73+
74+
# Sphinx documentation
75+
docs/_build/
76+
77+
# PyBuilder
78+
.pybuilder/
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
# For a library or package, you might want to ignore these files since the code is
90+
# intended to run in multiple environments; otherwise, check them in:
91+
# .python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# poetry
101+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102+
# This is especially recommended for binary packages to ensure reproducibility, and is more
103+
# commonly ignored for libraries.
104+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105+
#poetry.lock
106+
107+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
108+
__pypackages__/
109+
110+
# Celery stuff
111+
celerybeat-schedule
112+
celerybeat.pid
113+
114+
# SageMath parsed files
115+
*.sage.py
116+
117+
# Environments
118+
.env
119+
.venv
120+
env/
121+
venv/
122+
ENV/
123+
env.bak/
124+
venv.bak/
125+
126+
# Spyder project settings
127+
.spyderproject
128+
.spyproject
129+
130+
# Rope project settings
131+
.ropeproject
132+
133+
# mkdocs documentation
134+
/site
135+
136+
# mypy
137+
.mypy_cache/
138+
.dmypy.json
139+
dmypy.json
140+
141+
# Pyre type checker
142+
.pyre/
143+
144+
# pytype static type analyzer
145+
.pytype/
146+
147+
# Cython debug symbols
148+
cython_debug/
149+
150+
# PyCharm
151+
# JetBrains specific template is maintainted in a separate JetBrains.gitignore that can
152+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
153+
# and can be added to the global gitignore or merged into this file. For a more nuclear
154+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
155+
#.idea/

Dockerfile

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
FROM alpine:3.15
1+
FROM python:alpine
22

33
ENV REVIEWDOG_VERSION=v0.13.0
44

5+
WORKDIR /src
6+
57
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
68

7-
# hadolint ignore=DL3006
8-
RUN apk --no-cache add git
9+
# hadolint ignore=DL3006,DL3018
10+
RUN apk --no-cache add build-base libffi-dev git graphviz
11+
12+
COPY pyproject.toml pyproject.toml
13+
COPY poetry.lock poetry.lock
914

10-
RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin/ ${REVIEWDOG_VERSION}
15+
RUN wget -O - -q https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh| sh -s -- -b /usr/local/bin ${REVIEWDOG_VERSION} && \
16+
wget -O - -q https://git.io/misspell | sh -s -- -b /usr/local/bin
1117

12-
# TODO: Install a linter and/or change docker image as you need.
13-
RUN wget -O - -q https://git.io/misspell | sh -s -- -b /usr/local/bin/
18+
# hadolint ignore=DL3013,SC2169,SC3001
19+
RUN python -m pip install --no-cache-dir --upgrade pip && \
20+
python -m pip install --no-cache-dir --upgrade poetry && \
21+
python -m pip install --no-cache-dir --requirement <(poetry export --format requirements.txt)
1422

15-
COPY entrypoint.sh /entrypoint.sh
23+
COPY entrypoint.sh entrypoint.sh
1624

17-
ENTRYPOINT ["/entrypoint.sh"]
25+
ENTRYPOINT ["./entrypoint.sh"]

action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: 'TODO: Run <linter-name> with reviewdog'
2-
description: 'TODO: 🐶 Run <linter-name> with reviewdog on pull requests to improve code review experience.'
3-
author: 'TODO: <your-name>'
1+
name: 'Run pytest with reviewdog'
2+
description: '🐶 Run pytest with reviewdog on pull requests to improve code review experience.'
3+
author: 'Ross Chadwick'
44
inputs:
55
github_token:
66
description: 'GITHUB_TOKEN'
@@ -28,7 +28,7 @@ inputs:
2828
reviewdog_flags:
2929
description: 'Additional reviewdog flags'
3030
default: ''
31-
### Flags for <linter-name> ###
31+
### Flags for pytest ###
3232
locale:
3333
description: '-locale flag of misspell. (US/UK)'
3434
default: ''

entrypoint.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
#!/bin/sh
22
set -e
33

4-
if [ -n "${GITHUB_WORKSPACE}" ] ; then
4+
if [ -n "${GITHUB_WORKSPACE}" ]; then
55
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit
66
fi
77

88
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
99

10-
misspell -locale="${INPUT_LOCALE}" . \
11-
| reviewdog -efm="%f:%l:%c: %m" \
12-
-name="linter-name (misspell)" \
13-
-reporter="${INPUT_REPORTER:-github-pr-check}" \
14-
-filter-mode="${INPUT_FILTER_MODE}" \
15-
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
16-
-level="${INPUT_LEVEL}" \
17-
${INPUT_REVIEWDOG_FLAGS}
10+
misspell -locale="${INPUT_LOCALE}" . |
11+
reviewdog -efm="%f:%l:%c: %m" \
12+
-name="pytest (misspell)" \
13+
-reporter="${INPUT_REPORTER:-github-pr-check}" \
14+
-filter-mode="${INPUT_FILTER_MODE}" \
15+
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
16+
-level="${INPUT_LEVEL}" \
17+
"${INPUT_REVIEWDOG_FLAGS}"
18+
19+
echo "[action-pytest] Running pytest on \"${INPUT_WORKDIR}\"..."
20+
pytest --profile-svg --cov="${INPUT_WORKDIR}" "${INPUT_WORKDIR}"

0 commit comments

Comments
 (0)