Skip to content

Commit 5819b3b

Browse files
PR review: Add PR review comments for mypy and pylint warnings
Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
1 parent fb8fc55 commit 5819b3b

2 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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: [in_progress]
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+
GITHUB_EVENT_PATH: event.json
28+
GITHUB_EVENT_NAME: ${{ github.event.workflow_run.event }}
29+
GITHUB_SHA: ${{ github.event.workflow_run.head_sha }}
30+
steps:
31+
- run: |
32+
echo "Triggered repo: ${{ github.event.workflow_run.head_repository.full_name }}"
33+
- run: |
34+
echo "Triggered by: ${{ github.event.workflow_run.event }}"
35+
- run: |
36+
echo "SHA of triggering workflow: ${{ github.event.workflow_run.head_sha }}"
37+
- run: echo "GITHUB_EVENT_PATH=${GITHUB_EVENT_PATH}"
38+
- run: echo "GITHUB_EVENT_NAME=${GITHUB_EVENT_NAME}"
39+
- run: echo "GITHUB_SHA=${GITHUB_SHA}"
40+
- uses: actions/checkout@v4
41+
with:
42+
repository: ${{ github.event.workflow_run.head_repository.full_name }}
43+
ref: ${{ github.event.workflow_run.head_sha }}
44+
45+
- name: Download PR event payload
46+
uses: actions/download-artifact@v4
47+
with:
48+
name: pr-event
49+
50+
- run: cat ${GITHUB_EVENT_PATH}
51+
52+
- uses: actions/setup-python@v5
53+
with:
54+
python-version: 3.11
55+
56+
- name: Install uv and activate the environment
57+
uses: astral-sh/setup-uv@v6
58+
with:
59+
activate-environment: true
60+
61+
- run: uv pip install pylint tox types-setuptools -r pyproject.toml --extra mypy
62+
63+
- uses: tsuyoshicho/action-mypy@v4
64+
name: Run mypy with reviewdog to submit GitHub checks for warnings
65+
with:
66+
install_types: false
67+
reporter: github-pr-review
68+
level: warning
69+
github_token: ${{ secrets.GITHUB_TOKEN }}
70+
71+
- uses: dciborow/action-pylint@0.1.0
72+
name: Run pylint with reviewdog to submit GitHub checks for warnings
73+
with:
74+
reporter: github-pr-review
75+
glob_pattern: "xcp tests"
76+
github_token: ${{ secrets.GITHUB_TOKEN }}
77+
78+
# - name: Run tox to run pytest in the defined tox environments
79+
# run: tox -e py311-covcp
80+
# continue-on-error: true
81+
# env:
82+
# DIFF_COVERAGE_MIN: 0 # reviewdog-action-code-coverage shows coverage
83+
#
84+
# - uses: aki77/reviewdog-action-code-coverage@v2
85+
# with:
86+
# lcov_path: coverage.lcov
87+
# github_token: ${{ secrets.GITHUB_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)