Skip to content

Commit b5c6d16

Browse files
PR review: Add PR review comments for mypy and pylint warnings
Signed-off-by: Bernhard Kaindl <[email protected]>
1 parent 59b499a commit b5c6d16

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
# The reviewdog workflow steps use reporter: github-pr-review,
3+
# which submits mypy and pylint warnings using review comment
4+
# on the pull request. It needs write permissions for the pull request
5+
# to post the comments and can only be used in the context of a pull request.
6+
#
7+
name: mypy, pylint and coverage PR review comments
8+
9+
on:
10+
workflow_run:
11+
workflows: ["Unit tests"]
12+
types: [requested]
13+
14+
concurrency: # On new workflow, cancel old workflows from the same PR, branch or tag:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: write
20+
pull-requests: write
21+
22+
jobs:
23+
mypy-pylint-coverage-PR-comments:
24+
runs-on: ubuntu-22.04
25+
env:
26+
PR_REVIEW_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN || secrets.GITHUB_TOKEN }}
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
ref: ${{ github.event.pull_request.head.ref }}
31+
repository: ${{ github.event.pull_request.head.repo.full_name }}
32+
33+
- uses: actions/setup-python@v5
34+
with:
35+
python-version: 3.11
36+
37+
- name: Install uv and activate the environment
38+
uses: astral-sh/setup-uv@v6
39+
with:
40+
activate-environment: true
41+
42+
- run: uv pip install pylint tox types-setuptools -r pyproject.toml --extra mypy
43+
44+
- uses: tsuyoshicho/action-mypy@v4
45+
name: Run mypy with reviewdog to submit GitHub checks for warnings
46+
with:
47+
install_types: false
48+
reporter: github-pr-review
49+
level: warning
50+
github_token: ${{ env.PR_REVIEW_TOKEN }}
51+
52+
- uses: dciborow/[email protected]
53+
name: Run pylint with reviewdog to submit GitHub checks for warnings
54+
with:
55+
reporter: github-pr-review
56+
glob_pattern: "xcp tests"
57+
github_token: ${{ env.PR_REVIEW_TOKEN }}
58+
59+
- name: Run tox to run pytest in the defined tox environments
60+
run: tox -e py311-covcp
61+
continue-on-error: true
62+
env:
63+
DIFF_COVERAGE_MIN: 0 # reviewdog-action-code-coverage shows coverage
64+
65+
- uses: aki77/reviewdog-action-code-coverage@v2
66+
with:
67+
lcov_path: coverage.lcov
68+
github_token: ${{ env.PR_REVIEW_TOKEN }}

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ test = [
5858
"typing_extensions"
5959
]
6060
coverage = [
61+
"python-libs[test]",
6162
"coverage[toml]",
6263
"diff_cover"
6364
]
6465
mypy = [
66+
"python-libs[test]",
6567
"lxml",
6668
"mypy",
6769
"mypy-extensions",

0 commit comments

Comments
 (0)