Skip to content

Commit

Permalink
chore(ci): filter mypy for changed files only
Browse files Browse the repository at this point in the history
There are too many errors for now so filter pull request output to changed files only.
  • Loading branch information
nijel committed Oct 4, 2024
1 parent a3fa4b4 commit 97369d3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 4 deletions.
18 changes: 18 additions & 0 deletions .github/matchers/mypy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"problemMatcher": [
{
"owner": "mypy",
"pattern": [
{
"regexp": "^([^:]*):(\\d+):(?:(\\d+):)? ([^:]*): (.*?)(?: \\[(\\S+)\\])?$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5,
"code": 6
}
]
}
]
}
5 changes: 5 additions & 0 deletions .github/matchers/mypy.json.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Copyright © Michal Čihař <michal@weblate.org>

SPDX-License-Identifier: CC0-1.0

This file is maintained in https://github.com/WeblateOrg/meta/
35 changes: 31 additions & 4 deletions .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get changed files
if: github.event_name == 'pull_request'
id: changed-files
uses: tj-actions/changed-files@v45
- name: List all changed files
if: github.event_name == 'pull_request'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: |
for file in ${ALL_CHANGED_FILES}; do
echo "$file" >> .changed-files
done
if [ ! -f .changed-files ] ; then
echo "No changed files!"
else
cat .changed-files
fi
- name: Install apt dependencies
run: sudo ./ci/apt-install
- uses: astral-sh/setup-uv@v3
Expand All @@ -36,9 +56,16 @@ jobs:
run: ./ci/pip-install mypy

- name: Run mypy
uses: liskin/gh-problem-matcher-wrap@v3
with:
linters: mypy
run: mypy --show-column-numbers weblate
run: mypy --show-column-numbers weblate > mypy.log
# Temporary hack until we have this fully working
continue-on-error: true
- name: Report mypy
if: always()
run: |
echo "::add-matcher::.github/matchers/mypy.json"
if [ -f .changed-files ] ; then
grep -F -f .changed-files mypy.log
else
cat mypy.log
fi
echo "::remove-matcher owner=mypy::"

0 comments on commit 97369d3

Please sign in to comment.