Skip to content

Commit 13a6c0d

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

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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-comments:
24+
if: ${{ github.event.workflow_run.event == 'pull_request' }}
25+
runs-on: ubuntu-22.04
26+
env:
27+
PR_REVIEW_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN || secrets.GITHUB_TOKEN }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event.pull_request.head.ref }}
32+
repository: ${{ github.event.pull_request.head.repo.full_name }}
33+
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version: 3.11
37+
38+
- name: Install uv and activate the environment
39+
uses: astral-sh/setup-uv@v6
40+
with:
41+
activate-environment: true
42+
43+
- run: uv pip install pylint tox types-setuptools -r pyproject.toml --extra mypy
44+
45+
- uses: tsuyoshicho/action-mypy@v4
46+
name: Run mypy with reviewdog to submit GitHub checks for warnings
47+
with:
48+
install_types: false
49+
reporter: github-pr-review
50+
level: warning
51+
github_token: ${{ env.PR_REVIEW_TOKEN }}
52+
53+
- uses: dciborow/[email protected]
54+
name: Run pylint with reviewdog to submit GitHub checks for warnings
55+
with:
56+
reporter: github-pr-review
57+
glob_pattern: "xcp tests"
58+
github_token: ${{ env.PR_REVIEW_TOKEN }}
59+
60+
- name: Run tox to run pytest in the defined tox environments
61+
run: tox -e py311-covcp
62+
continue-on-error: true
63+
env:
64+
DIFF_COVERAGE_MIN: 0 # reviewdog-action-code-coverage shows coverage
65+
66+
- uses: aki77/reviewdog-action-code-coverage@v2
67+
with:
68+
lcov_path: coverage.lcov
69+
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)