mirror of
https://gh.wpcy.net/https://github.com/WeblateOrg/weblate.git
synced 2026-04-30 10:23:51 +08:00
* chore(deps): update dependency astral-sh/uv to v0.11.6 * chore(deps): update lockfile --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
99 lines
3.5 KiB
YAML
99 lines
3.5 KiB
YAML
# Copyright © Michal Čihař <michal@weblate.org>
|
|
#
|
|
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
name: mypy
|
|
|
|
on:
|
|
push:
|
|
branches-ignore:
|
|
- renovate/**
|
|
- weblate
|
|
- dependabot/**
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
mypy:
|
|
runs-on: ubuntu-24.04
|
|
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
with:
|
|
fetch-depth: 2
|
|
persist-credentials: false
|
|
- name: Get changed files
|
|
if: github.event_name == 'pull_request'
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
|
|
with:
|
|
files: '**.py'
|
|
- name: List all changed files
|
|
if: github.event_name == 'pull_request'
|
|
env:
|
|
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
|
|
run: |
|
|
touch changed-files.txt
|
|
for file in ${ALL_CHANGED_FILES}; do
|
|
echo "$file" >> changed-files.txt
|
|
done
|
|
cat changed-files.txt
|
|
|
|
- name: Install apt dependencies
|
|
run: sudo ./ci/apt-install
|
|
- name: Setup Python
|
|
id: setup_python
|
|
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
|
|
with:
|
|
python-version: '3.14'
|
|
- uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57 # v8.0.0
|
|
with:
|
|
save-cache: ${{ github.ref == 'refs/heads/main' }}
|
|
cache-suffix: ${{ steps.setup_python.outputs.python-version }}
|
|
|
|
version: 0.11.6
|
|
- name: Install deps
|
|
run: uv sync --no-binary-package lxml --no-binary-package xmlsec --all-extras --group types
|
|
- name: Run mypy
|
|
run: |
|
|
set +e
|
|
uv run --no-sync mypy --show-column-numbers weblate scripts/*.py ./*.py | ./scripts/filter-mypy.sh | tee mypy.log
|
|
# Temporary hack until we have mypy fully passing
|
|
mypy_err="$?"
|
|
if [ "$mypy_err" -ne 0 ] && [ "$mypy_err" -ne 1 ] ; then
|
|
exit "$mypy_err"
|
|
fi
|
|
if [ ! -s mypy.log ] ; then
|
|
echo "mypy log not found!"
|
|
exit 1
|
|
fi
|
|
# Use summary as step summary
|
|
tail -n1 mypy.log >> "$GITHUB_STEP_SUMMARY"
|
|
# Remove summary and .venv hints from the log
|
|
cp mypy.log mypy.log.tmp
|
|
head -n-1 mypy.log.tmp | grep -v '^\.venv/' > mypy.log
|
|
rm mypy.log.tmp
|
|
- name: Enforced mypy
|
|
# TODO: Enforce mypy to pass on certain modules, this should eventually grow to complete codebase
|
|
env:
|
|
EXCLUDED_MODULES: accounts/|addons/(base|models|resx|views|gettext|tests)|api/|auth/|billing/|fonts/|checks/|lang/|machinery/|metrics/|trans/(admin|autofixes|autotranslate|context_processors|debug|feeds|forms|guide|management|mixins|models/(agreement|pending|suggestion|comment|announcement|category|unit|translation|component)|tests|views|widgets)|vcs/(gpg|base|git|tests/test_vcs)
|
|
run: |
|
|
echo "::add-matcher::.github/matchers/mypy.json"
|
|
if grep --silent --invert-match --extended-regexp "^weblate/($EXCLUDED_MODULES)" mypy.log ; then
|
|
grep --invert-match --extended-regexp "^weblate/($EXCLUDED_MODULES)" mypy.log
|
|
exit 1
|
|
fi
|
|
echo "::remove-matcher owner=mypy::"
|
|
- name: Report mypy
|
|
run: |
|
|
echo "::add-matcher::.github/matchers/mypy.json"
|
|
if [ -f changed-files.txt ] ; then
|
|
if grep --silent --fixed-strings --file=changed-files.txt mypy.log ; then
|
|
grep --fixed-strings --file=changed-files.txt mypy.log
|
|
fi
|
|
else
|
|
cat mypy.log
|
|
fi
|
|
echo "::remove-matcher owner=mypy::"
|