Skip to content

Commit 3caf781

Browse files
committed
Convert versioned website utility script tests to pytest
The Tooling Team standard framework for Python tests is pytest. Following this standard for the versioned website utility script's tests allows the existing frameworks to be used to run these tests.
1 parent 50ed453 commit 3caf781

File tree

12 files changed

+300
-46
lines changed

12 files changed

+300
-46
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/test-python-poetry-task.md
2+
name: Test Python
3+
4+
env:
5+
# See: https://github.com/actions/setup-python/tree/v2#available-versions-of-python
6+
PYTHON_VERSION: "3.9"
7+
8+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
9+
on:
10+
push:
11+
paths:
12+
- ".github/workflows/test-python-poetry-task.ya?ml"
13+
- "Taskfile.ya?ml"
14+
- "poetry.lock"
15+
- "pyproject.toml"
16+
- "tests/**"
17+
- "**.py"
18+
pull_request:
19+
paths:
20+
- ".github/workflows/test-python-poetry-task.ya?ml"
21+
- "Taskfile.ya?ml"
22+
- "poetry.lock"
23+
- "pyproject.toml"
24+
- "tests/**"
25+
- "**.py"
26+
workflow_dispatch:
27+
repository_dispatch:
28+
29+
jobs:
30+
test:
31+
runs-on: ubuntu-latest
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v2
36+
37+
- name: Install Python
38+
uses: actions/setup-python@v2
39+
with:
40+
python-version: ${{ env.PYTHON_VERSION }}
41+
42+
- name: Install Poetry
43+
run: pip install poetry
44+
45+
- name: Install Taskfile
46+
uses: arduino/setup-task@v1
47+
with:
48+
repo-token: ${{ secrets.GITHUB_TOKEN }}
49+
version: 3.x
50+
51+
- name: Run tests
52+
uses: liskin/gh-problem-matcher-wrap@v1
53+
with:
54+
linters: pytest
55+
run: task python:test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__pycache__/
2+
.idea/

Taskfile.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ tasks:
2222
- task: markdown:lint
2323
- task: markdown:check-links
2424
- task: python:lint
25+
- task: python:test
2526
- task: yaml:lint
2627

2728
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml
@@ -73,6 +74,7 @@ tasks:
7374
"{{.WORKFLOW_TEMPLATES_PATH}}/check-yaml-task.yml" \
7475
"{{.WORKFLOW_TEMPLATES_PATH}}/sync-labels.yml" \
7576
"{{.WORKFLOW_TEMPLATES_PATH}}/spell-check-task.yml" \
77+
"{{.WORKFLOW_TEMPLATES_PATH}}/test-python-poetry-task.yml" \
7678
"{{.WORKFLOWS_PATH}}"
7779
7880
config:sync:
@@ -224,6 +226,13 @@ tasks:
224226
cmds:
225227
- poetry update
226228

229+
python:test:
230+
desc: Run Python tests
231+
deps:
232+
- task: poetry:install-deps
233+
cmds:
234+
- poetry run pytest workflow-templates/assets/deploy-mkdocs-versioned/build/tests
235+
227236
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-python-task/Taskfile.yml
228237
python:lint:
229238
desc: Lint Python code

poetry.lock

Lines changed: 168 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ codespell = "^2.1.0"
1616
black = "^21.5b0"
1717
flake8 = "^3.9.2"
1818
pep8-naming = "^0.11.1"
19+
pytest = "^6.2.4"
20+
click = "<7.2"
21+
GitPython = "^3.1.1"
1922

2023
[build-system]
2124
requires = ["poetry-core>=1.0.0"]

0 commit comments

Comments
 (0)