Skip to content

Commit 71e6e12

Browse files
Merge branch 'main' into henryiii-patch-2
2 parents 054084b + 500c53c commit 71e6e12

File tree

9 files changed

+220
-79
lines changed

9 files changed

+220
-79
lines changed

.github/workflows/deploy.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
11
name: deploy
22

33
on:
4+
workflow_dispatch:
5+
pull_request:
46
push:
7+
branches:
8+
- main
59
tags:
610
- v*
711

812
jobs:
9-
deploy:
13+
dist:
1014
runs-on: ubuntu-latest
1115
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
16+
- uses: actions/checkout@v4
17+
- uses: hynek/build-and-inspect-python-package@v2
1418

15-
- name: Set up Python
16-
uses: actions/setup-python@v5
19+
deploy:
20+
runs-on: ubuntu-latest
21+
if: startsWith(github.ref, 'refs/tags/v')
22+
steps:
23+
- uses: actions/download-artifact@v4
1724
with:
18-
python-version: '3.11'
19-
20-
- name: Install dependencies for build
21-
run: pip install --upgrade setuptools build
22-
23-
- name: Build
24-
run: python -m build
25+
name: Packages
26+
path: dist
2527

2628
- name: Publish package
2729
uses: pypa/gh-action-pypi-publish@release/v1
2830
with:
29-
user: __token__
3031
password: ${{ secrets.pypi_password }}

.github/workflows/test.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ env:
1717
jobs:
1818
test:
1919
strategy:
20+
fail-fast: false
2021
matrix:
2122
os: [ubuntu-latest, windows-latest]
2223
python-version:
23-
- '3.7'
2424
- '3.8'
2525
- '3.9'
2626
- '3.10'
@@ -38,11 +38,10 @@ jobs:
3838
with:
3939
python-version: ${{ matrix.python-version }}
4040

41-
- name: Install test dependencies
42-
run: pip install tox tox-gh-actions
41+
- uses: astral-sh/setup-uv@v3
4342

44-
- name: Test packaging
45-
run: tox -e pkg
43+
- name: Install tox
44+
run: uv tool install --with tox-gh-actions --with tox-uv tox
4645

4746
- name: Run tests with PyTest 8
4847
run: tox
@@ -64,7 +63,12 @@ jobs:
6463

6564
post-test:
6665
name: All tests passed
66+
if: always()
67+
needs: [test]
6768
runs-on: ubuntu-latest
68-
needs: test
69+
timeout-minutes: 2
6970
steps:
70-
- run: echo ok
71+
- name: Decide whether the needed jobs succeeded or failed
72+
uses: re-actors/alls-green@release/v1
73+
with:
74+
jobs: ${{ toJSON(needs) }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Incompatible changes
66

7+
- Require python 3.8+ #87 (thanks to @edgarrmondragon)
78
- Require pytest 6+ #86 (thanks to @edgarrmondragon)
89

910
## 0.2.0 (2023-05-04)

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
- uses: actions/setup-python@v4
2121
with:
22-
python-version: 3.7
22+
python-version: 3.8
2323

2424
- name: Install dependencies
2525
run: |
@@ -36,5 +36,9 @@ If your test is running in a Docker container, you have to install this plugin a
3636

3737
If your tests are run from a subdirectory of the git repository, you have to set the `PYTEST_RUN_PATH` environment variable to the path of that directory relative to the repository root in order for GitHub to identify the files with errors correctly.
3838

39+
### Warning annotations
40+
41+
This plugin also supports warning annotations when used with Pytest 6.0+. To disable warning annotations, pass `--exclude-warning-annotations` to pytest.
42+
3943
## Screenshot
4044
[![Image from Gyazo](https://i.gyazo.com/b578304465dd1b755ceb0e04692a57d9.png)](https://gyazo.com/b578304465dd1b755ceb0e04692a57d9)

plugin_test.py

Lines changed: 98 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@
55
import pytest
66
from packaging import version
77

8+
PYTEST_VERSION = version.parse(pytest.__version__)
89
pytest_plugins = "pytester"
910

1011

11-
# result.stderr.no_fnmatch_line() is added to testdir on pytest 5.3.0
12+
# result.stderr.no_fnmatch_line() was added to testdir on pytest 5.3.0
1213
# https://docs.pytest.org/en/stable/changelog.html#pytest-5-3-0-2019-11-19
13-
def no_fnmatch_line(result, pattern):
14-
if version.parse(pytest.__version__) >= version.parse("5.3.0"):
15-
result.stderr.no_fnmatch_line(pattern + "*",)
16-
else:
17-
assert pattern not in result.stderr.str()
14+
def no_fnmatch_line(result: pytest.RunResult, pattern: str):
15+
result.stderr.no_fnmatch_line(pattern + "*")
1816

1917

20-
def test_annotation_succeed_no_output(testdir):
18+
def test_annotation_succeed_no_output(testdir: pytest.Testdir):
2119
testdir.makepyfile(
2220
"""
2321
import pytest
@@ -33,7 +31,7 @@ def test_success():
3331
no_fnmatch_line(result, "::error file=test_annotation_succeed_no_output.py")
3432

3533

36-
def test_annotation_pytest_error(testdir):
34+
def test_annotation_pytest_error(testdir: pytest.Testdir):
3735
testdir.makepyfile(
3836
"""
3937
import pytest
@@ -55,7 +53,7 @@ def test_error():
5553
)
5654

5755

58-
def test_annotation_fail(testdir):
56+
def test_annotation_fail(testdir: pytest.Testdir):
5957
testdir.makepyfile(
6058
"""
6159
import pytest
@@ -68,11 +66,13 @@ def test_fail():
6866
testdir.monkeypatch.setenv("GITHUB_ACTIONS", "true")
6967
result = testdir.runpytest_subprocess()
7068
result.stderr.fnmatch_lines(
71-
["::error file=test_annotation_fail.py,line=5::test_fail*assert 0*",]
69+
[
70+
"::error file=test_annotation_fail.py,line=5::test_fail*assert 0*",
71+
]
7272
)
7373

7474

75-
def test_annotation_exception(testdir):
75+
def test_annotation_exception(testdir: pytest.Testdir):
7676
testdir.makepyfile(
7777
"""
7878
import pytest
@@ -86,11 +86,51 @@ def test_fail():
8686
testdir.monkeypatch.setenv("GITHUB_ACTIONS", "true")
8787
result = testdir.runpytest_subprocess()
8888
result.stderr.fnmatch_lines(
89-
["::error file=test_annotation_exception.py,line=5::test_fail*oops*",]
89+
[
90+
"::error file=test_annotation_exception.py,line=5::test_fail*oops*",
91+
]
92+
)
93+
94+
95+
def test_annotation_warning(testdir: pytest.Testdir):
96+
testdir.makepyfile(
97+
"""
98+
import warnings
99+
import pytest
100+
pytest_plugins = 'pytest_github_actions_annotate_failures'
101+
102+
def test_warning():
103+
warnings.warn('beware', Warning)
104+
assert 1
105+
"""
90106
)
107+
testdir.monkeypatch.setenv("GITHUB_ACTIONS", "true")
108+
result = testdir.runpytest_subprocess()
109+
result.stderr.fnmatch_lines(
110+
[
111+
"::warning file=test_annotation_warning.py,line=6::beware",
112+
]
113+
)
114+
115+
116+
def test_annotation_exclude_warnings(testdir: pytest.Testdir):
117+
testdir.makepyfile(
118+
"""
119+
import warnings
120+
import pytest
121+
pytest_plugins = 'pytest_github_actions_annotate_failures'
122+
123+
def test_warning():
124+
warnings.warn('beware', Warning)
125+
assert 1
126+
"""
127+
)
128+
testdir.monkeypatch.setenv("GITHUB_ACTIONS", "true")
129+
result = testdir.runpytest_subprocess("--exclude-warning-annotations")
130+
assert not result.stderr.lines
91131

92132

93-
def test_annotation_third_party_exception(testdir):
133+
def test_annotation_third_party_exception(testdir: pytest.Testdir):
94134
testdir.makepyfile(
95135
my_module="""
96136
def fn():
@@ -111,11 +151,43 @@ def test_fail():
111151
testdir.monkeypatch.setenv("GITHUB_ACTIONS", "true")
112152
result = testdir.runpytest_subprocess()
113153
result.stderr.fnmatch_lines(
114-
["::error file=test_annotation_third_party_exception.py,line=6::test_fail*oops*",]
154+
[
155+
"::error file=test_annotation_third_party_exception.py,line=6::test_fail*oops*",
156+
]
157+
)
158+
159+
160+
def test_annotation_third_party_warning(testdir: pytest.Testdir):
161+
testdir.makepyfile(
162+
my_module="""
163+
import warnings
164+
165+
def fn():
166+
warnings.warn('beware', Warning)
167+
"""
168+
)
169+
170+
testdir.makepyfile(
171+
"""
172+
import pytest
173+
from my_module import fn
174+
pytest_plugins = 'pytest_github_actions_annotate_failures'
175+
176+
def test_warning():
177+
fn()
178+
"""
179+
)
180+
testdir.monkeypatch.setenv("GITHUB_ACTIONS", "true")
181+
result = testdir.runpytest_subprocess()
182+
result.stderr.fnmatch_lines(
183+
# ["::warning file=test_annotation_third_party_warning.py,line=6::beware",]
184+
[
185+
"::warning file=my_module.py,line=4::beware",
186+
]
115187
)
116188

117189

118-
def test_annotation_fail_disabled_outside_workflow(testdir):
190+
def test_annotation_fail_disabled_outside_workflow(testdir: pytest.Testdir):
119191
testdir.makepyfile(
120192
"""
121193
import pytest
@@ -132,7 +204,7 @@ def test_fail():
132204
)
133205

134206

135-
def test_annotation_fail_cwd(testdir):
207+
def test_annotation_fail_cwd(testdir: pytest.Testdir):
136208
testdir.makepyfile(
137209
"""
138210
import pytest
@@ -148,11 +220,13 @@ def test_fail():
148220
testdir.makefile(".ini", pytest="[pytest]\ntestpaths=..")
149221
result = testdir.runpytest_subprocess("--rootdir=foo")
150222
result.stderr.fnmatch_lines(
151-
["::error file=test_annotation_fail_cwd.py,line=5::test_fail*assert 0*",]
223+
[
224+
"::error file=test_annotation_fail_cwd.py,line=5::test_fail*assert 0*",
225+
]
152226
)
153227

154228

155-
def test_annotation_fail_runpath(testdir):
229+
def test_annotation_fail_runpath(testdir: pytest.Testdir):
156230
testdir.makepyfile(
157231
"""
158232
import pytest
@@ -166,11 +240,13 @@ def test_fail():
166240
testdir.monkeypatch.setenv("PYTEST_RUN_PATH", "some_path")
167241
result = testdir.runpytest_subprocess()
168242
result.stderr.fnmatch_lines(
169-
["::error file=some_path/test_annotation_fail_runpath.py,line=5::test_fail*assert 0*",]
243+
[
244+
"::error file=some_path/test_annotation_fail_runpath.py,line=5::test_fail*assert 0*",
245+
]
170246
)
171247

172248

173-
def test_annotation_long(testdir):
249+
def test_annotation_long(testdir: pytest.Testdir):
174250
testdir.makepyfile(
175251
"""
176252
import pytest
@@ -202,7 +278,7 @@ def test_fail():
202278
no_fnmatch_line(result, "::*assert x += 1*")
203279

204280

205-
def test_class_method(testdir):
281+
def test_class_method(testdir: pytest.Testdir):
206282
testdir.makepyfile(
207283
"""
208284
import pytest
@@ -224,7 +300,7 @@ def test_method(self):
224300
no_fnmatch_line(result, "::*x = 1*")
225301

226302

227-
def test_annotation_param(testdir):
303+
def test_annotation_param(testdir: pytest.Testdir):
228304
testdir.makepyfile(
229305
"""
230306
import pytest

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
# https://peps.python.org/pep-0621/#readme
11-
requires-python = ">=3.7"
11+
requires-python = ">=3.8"
1212
version = "0.2.0"
1313
name = "pytest-github-actions-annotate-failures"
1414
description = "pytest plugin to annotate failed tests with a workflow command for GitHub Actions"
@@ -25,7 +25,6 @@ classifiers = [
2525
"License :: OSI Approved :: MIT License",
2626
"Framework :: Pytest",
2727
"Programming Language :: Python :: 3",
28-
"Programming Language :: Python :: 3.7",
2928
"Programming Language :: Python :: 3.8",
3029
"Programming Language :: Python :: 3.9",
3130
"Programming Language :: Python :: 3.10",
@@ -52,6 +51,9 @@ changelog = "https://github.com/pytest-dev/pytest-github-actions-annotate-failur
5251
[project.entry-points.pytest11]
5352
pytest_github_actions_annotate_failures = "pytest_github_actions_annotate_failures.plugin"
5453

54+
[project.optional-dependencies]
55+
test = ["packaging"]
56+
5557

5658
[tool.ruff.lint]
5759
extend-select = [

0 commit comments

Comments
 (0)