| 1 |
name: Python package |
| 2 |
|
| 3 |
on: |
| 4 |
- push |
| 5 |
- pull_request |
| 6 |
|
| 7 |
permissions: |
| 8 |
contents: read |
| 9 |
|
| 10 |
jobs: |
| 11 |
lint: |
| 12 |
name: Lint and type check |
| 13 |
runs-on: ubuntu-latest |
| 14 |
steps: |
| 15 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 16 |
- name: Check the license copyright year is current |
| 17 |
run: | |
| 18 |
year="$(date -u +%Y)" |
| 19 |
license_year="$(grep -m1 '^Copyright' LICENSE.md | grep -oE '[0-9]{4}' | tail -1)" |
| 20 |
if [ "$license_year" != "$year" ]; then |
| 21 |
echo "::error file=LICENSE.md::Copyright year $license_year is not the current year $year; update LICENSE.md" >&2 |
| 22 |
exit 1 |
| 23 |
fi |
| 24 |
- name: Set up Python |
| 25 |
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 26 |
with: |
| 27 |
python-version: '3.14' |
| 28 |
- name: Install dependencies |
| 29 |
run: python -m pip install --require-hashes -r .github/requirements/lint.txt |
| 30 |
- name: Check code style with ruff |
| 31 |
run: | |
| 32 |
ruff format --check idna tests/fuzz_*.py |
| 33 |
ruff check idna tests |
| 34 |
- name: Check types with mypy |
| 35 |
run: mypy --strict idna |
| 36 |
- name: Check types with ty |
| 37 |
run: ty check idna tests |
| 38 |
|
| 39 |
tables: |
| 40 |
name: Verify generated tables |
| 41 |
runs-on: ubuntu-latest |
| 42 |
steps: |
| 43 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 44 |
- name: Set up Python |
| 45 |
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 46 |
with: |
| 47 |
python-version: '3.14' |
| 48 |
- name: Read pinned Unicode version |
| 49 |
id: unicode |
| 50 |
run: echo "version=$(sed -n 's/^PREFERRED_VERSION = "\(.*\)"$/\1/p' tools/idna-data)" >> "$GITHUB_OUTPUT" |
| 51 |
- name: Cache Unicode Character Database |
| 52 |
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 53 |
with: |
| 54 |
path: ~/.cache/unidata |
| 55 |
key: unidata-${{ steps.unicode.outputs.version }} |
| 56 |
- name: Regenerate tables and conformance tests from Unicode ${{ steps.unicode.outputs.version }} |
| 57 |
run: python tools/idna-data make-libdata --dir idna --test-dir tests |
| 58 |
- name: Verify checked-in files match generator output |
| 59 |
run: git diff --exit-code -- idna/idnadata.py idna/uts46data.py tests/test_idna_uts46.py |
| 60 |
|
| 61 |
test: |
| 62 |
name: Test on Python ${{ matrix.python-version }} |
| 63 |
strategy: |
| 64 |
fail-fast: false |
| 65 |
matrix: |
| 66 |
python-version: |
| 67 |
- '3.9' |
| 68 |
- '3.10' |
| 69 |
- '3.11' |
| 70 |
- '3.12' |
| 71 |
- '3.13' |
| 72 |
- '3.14' |
| 73 |
- '3.15-dev' |
| 74 |
- 'pypy-3.11' |
| 75 |
include: |
| 76 |
# Free-threaded builds, run with the GIL disabled; the suite checks |
| 77 |
# that it stays off. (PYTHON_GIL=0 is a fatal error on other builds, |
| 78 |
# so it is only set here.) |
| 79 |
- python-version: '3.14t' |
| 80 |
gil: '0' |
| 81 |
- python-version: '3.15t-dev' |
| 82 |
gil: '0' |
| 83 |
runs-on: ubuntu-latest |
| 84 |
steps: |
| 85 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 86 |
- name: Set up Python ${{ matrix.python-version }} |
| 87 |
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 88 |
with: |
| 89 |
python-version: ${{ matrix.python-version }} |
| 90 |
allow-prereleases: true |
| 91 |
- name: Install dependencies |
| 92 |
run: python -m pip install --require-hashes -r .github/requirements/test.txt |
| 93 |
- name: Test with pytest |
| 94 |
env: |
| 95 |
PYTHON_GIL: ${{ matrix.gil }} |
| 96 |
# Measured under coverage on CPython; PyPy runs the suite plain since |
| 97 |
# tracing there is an order of magnitude slower. |
| 98 |
run: | |
| 99 |
if [[ "${{ matrix.python-version }}" == pypy* ]]; then |
| 100 |
pytest |
| 101 |
else |
| 102 |
coverage run -m pytest |
| 103 |
coverage report |
| 104 |
fi |