Skip to content

Commit 836d148

Browse files
committed
Change Python tests to run with different Python versions
1 parent 22e907e commit 836d148

9 files changed

Lines changed: 214 additions & 122 deletions

File tree

.github/workflows/linting.yml

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Python linting
2+
3+
# Build on every branch push, tag push, and pull request change:
4+
on: [push, pull_request]
5+
6+
jobs:
7+
mypy:
8+
name: mypy
9+
runs-on: ubuntu-22.04
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
py_version:
14+
- '3.8'
15+
16+
steps:
17+
- name: Checkout reposistory
18+
uses: actions/checkout@main
19+
20+
- name: Set up Python ${{ matrix.py_version }}
21+
uses: actions/setup-python@main
22+
with:
23+
python-version: ${{ matrix.py_version }}
24+
25+
- name: Install uv
26+
uses: astral-sh/setup-uv@v7
27+
28+
# Setup venv and install dependencies without building the project from source.
29+
- name: Install Dependencies
30+
run: |
31+
uv venv --no-project --python ${{ matrix.py_version }}
32+
uv sync --no-install-project
33+
uv pip install -U mypy
34+
35+
- name: mypy
36+
run: |
37+
uv run --no-sync mypy --show-column-numbers --hide-error-context .
38+
39+
ruff:
40+
name: ruff
41+
runs-on: ubuntu-22.04
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
py_version:
46+
- '3.8'
47+
48+
steps:
49+
- name: Checkout repository
50+
uses: actions/checkout@main
51+
52+
- name: Set up Python ${{ matrix.py_version }}
53+
uses: actions/setup-python@main
54+
with:
55+
python-version: ${{ matrix.py_version }}
56+
57+
- name: Install uv
58+
uses: astral-sh/setup-uv@v7
59+
60+
# Setup venv and install dependencies without building the project from source.
61+
- name: Install Dependencies
62+
run: |
63+
uv venv --no-project --python ${{ matrix.py_version }}
64+
uv sync --no-install-project
65+
uv pip install -U ruff
66+
67+
- name: ruff
68+
run: |
69+
ruff check src/
70+
71+
ruff_format:
72+
name: ruff format
73+
runs-on: ubuntu-22.04
74+
strategy:
75+
fail-fast: false
76+
matrix:
77+
py_version:
78+
- '3.8'
79+
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@main
83+
84+
- name: Set up Python ${{ matrix.py_version }}
85+
uses: actions/setup-python@main
86+
with:
87+
python-version: ${{ matrix.py_version }}
88+
89+
- name: Install uv
90+
uses: astral-sh/setup-uv@v7
91+
92+
# Setup venv and install dependencies without building the project from source.
93+
- name: Install Dependencies
94+
run: |
95+
uv venv --no-project --python ${{ matrix.py_version }}
96+
uv sync --no-install-project
97+
uv pip install -U ruff
98+
99+
- name: ruff
100+
run: |
101+
ruff format src/ --check

.github/workflows/tests.yml

Lines changed: 102 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@ on: [push, pull_request]
55

66
jobs:
77
check_if_output_files_changed:
8-
name: Check if output files changed
9-
runs-on: ubuntu-latest
8+
name: Check if output files changed (Python ${{ matrix.py_version }})
9+
runs-on: ubuntu-22.04
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
py_version:
14+
- '3.7'
15+
- '3.8'
16+
- '3.9'
17+
- '3.10'
18+
- '3.11'
19+
- '3.12'
20+
- '3.13'
21+
- '3.14'
22+
- '3.14t'
23+
- '3.x' # Explicit latest
1024

1125
steps:
1226
- name: Checkout reposistory
@@ -15,16 +29,31 @@ jobs:
1529
- name: Setup Rust toolchain
1630
uses: dtolnay/rust-toolchain@stable
1731

18-
- name: Setup requirements
32+
- name: Set up Python ${{ matrix.py_version }}
33+
uses: actions/setup-python@main
34+
with:
35+
python-version: ${{ matrix.py_version }}
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v7
39+
40+
- name: Setup venv ${{ matrix.py_version }}
41+
if: ${{ matrix.py_version != '3.x' }}
42+
run: |
43+
uv venv --python ${{ matrix.py_version }}
44+
# `--python 3 --managed-python` makes uv to install the latest python version available
45+
- name: Setup venv 3.x
46+
if: ${{ matrix.py_version == '3.x' }}
1947
run: |
20-
python3 -m pip install -U -r requirements.txt
21-
python3 -m pip install -U maturin
48+
uv venv --python 3 --managed-python
2249
23-
- name: Install local mapfile_parser
24-
run: python3 -m pip install .
50+
- name: Sync venv
51+
run: |
52+
uv sync
2553
2654
- name: Update tests outputs
27-
run: python3 tests/update_outputs.py
55+
run: |
56+
uv run tests/update_outputs.py
2857
2958
- name: Check if there are any changes in the test cases
3059
id: tests_changes
@@ -38,8 +67,22 @@ jobs:
3867
exit 1
3968
4069
check_progress_nonmatchings:
41-
name: Check progress by NON_MATCHING symbols
42-
runs-on: ubuntu-latest
70+
name: Check progress by NON_MATCHING symbols (Python ${{ matrix.py_version }})
71+
runs-on: ubuntu-22.04
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
py_version:
76+
- '3.7'
77+
- '3.8'
78+
- '3.9'
79+
- '3.10'
80+
- '3.11'
81+
- '3.12'
82+
- '3.13'
83+
- '3.14'
84+
- '3.14t'
85+
- '3.x' # Explicit latest
4386

4487
steps:
4588
- name: Checkout reposistory
@@ -48,20 +91,40 @@ jobs:
4891
- name: Setup Rust toolchain
4992
uses: dtolnay/rust-toolchain@stable
5093

51-
- name: Setup requirements
52-
run: |
53-
python3 -m pip install -U -r requirements.txt
54-
python3 -m pip install -U maturin
94+
- name: Set up Python ${{ matrix.py_version }}
95+
uses: actions/setup-python@main
96+
with:
97+
python-version: ${{ matrix.py_version }}
5598

56-
- name: Install local mapfile_parser
57-
run: python3 -m pip install .
99+
- name: Install uv
100+
uses: astral-sh/setup-uv@v7
101+
102+
- name: Setup project
103+
run: |
104+
uv venv --python ${{ matrix.py_version }}
105+
uv sync
58106
59107
- name: Update tests outputs
60-
run: python3 tests/check_progress_nonmatchings.py
108+
run: |
109+
uv run tests/check_progress_nonmatchings.py
61110
62111
check_frontends:
63-
name: Check frontends aren't broken
64-
runs-on: ubuntu-latest
112+
name: Check frontends aren't broken (Python ${{ matrix.py_version }})
113+
runs-on: ubuntu-22.04
114+
strategy:
115+
fail-fast: false
116+
matrix:
117+
py_version:
118+
- '3.7'
119+
- '3.8'
120+
- '3.9'
121+
- '3.10'
122+
- '3.11'
123+
- '3.12'
124+
- '3.13'
125+
- '3.14'
126+
- '3.14t'
127+
- '3.x' # Explicit latest
65128

66129
steps:
67130
- name: Checkout reposistory
@@ -70,37 +133,42 @@ jobs:
70133
- name: Setup Rust toolchain
71134
uses: dtolnay/rust-toolchain@stable
72135

73-
- name: Setup requirements
74-
run: |
75-
python3 -m pip install -U -r requirements.txt
76-
python3 -m pip install -U maturin
136+
- name: Set up Python ${{ matrix.py_version }}
137+
uses: actions/setup-python@main
138+
with:
139+
python-version: ${{ matrix.py_version }}
140+
141+
- name: Install uv
142+
uses: astral-sh/setup-uv@v7
77143

78-
- name: Install local mapfile_parser
79-
run: python3 -m pip install .
144+
- name: Setup project
145+
run: |
146+
uv venv --python ${{ matrix.py_version }}
147+
uv sync
80148
81149
- name: bss_check
82-
run: python3 -m mapfile_parser bss_check tests/maps/gnuld/n64/drmario64.us.map tests/maps/gnuld/n64/drmario64.us.map
150+
run: uv run mapfile_parser bss_check tests/maps/gnuld/n64/drmario64.us.map tests/maps/gnuld/n64/drmario64.us.map
83151

84152
- name: first_diff
85-
run: python3 -m mapfile_parser first_diff tests/maps/gnuld/n64/drmario64.us.map tests/maps/gnuld/n64/drmario64.us.map tests/maps/gnuld/n64/drmario64.us.map tests/maps/gnuld/n64/drmario64.us.map
153+
run: uv run mapfile_parser first_diff tests/maps/gnuld/n64/drmario64.us.map tests/maps/gnuld/n64/drmario64.us.map tests/maps/gnuld/n64/drmario64.us.map tests/maps/gnuld/n64/drmario64.us.map
86154

87155
- name: jsonify
88-
run: python3 -m mapfile_parser jsonify tests/maps/gnuld/n64/drmario64.us.map
156+
run: uv run mapfile_parser jsonify tests/maps/gnuld/n64/drmario64.us.map
89157

90158
- name: objdiff_report
91-
run: python3 -m mapfile_parser objdiff_report tests/maps/gnuld/n64/drmario64.us.map objdiff_report.json
159+
run: uv run mapfile_parser objdiff_report tests/maps/gnuld/n64/drmario64.us.map objdiff_report.json
92160

93161
- name: pj64_syms
94-
run: python3 -m mapfile_parser pj64_syms tests/maps/gnuld/n64/drmario64.us.map
162+
run: uv run mapfile_parser pj64_syms tests/maps/gnuld/n64/drmario64.us.map
95163

96164
- name: progress
97-
run: python3 -m mapfile_parser progress tests/maps/gnuld/n64/drmario64.us.map asm asm/nonmatchings
165+
run: uv run mapfile_parser progress tests/maps/gnuld/n64/drmario64.us.map asm asm/nonmatchings
98166

99167
- name: sym_info
100-
run: python3 -m mapfile_parser sym_info tests/maps/gnuld/n64/drmario64.us.map entrypoint
168+
run: uv run mapfile_parser sym_info tests/maps/gnuld/n64/drmario64.us.map entrypoint
101169

102170
- name: symbol_sizes_csv
103-
run: python3 -m mapfile_parser symbol_sizes_csv tests/maps/gnuld/n64/drmario64.us.map
171+
run: uv run mapfile_parser symbol_sizes_csv tests/maps/gnuld/n64/drmario64.us.map
104172

105173
- name: upload_frogress
106-
run: python3 -m mapfile_parser upload_frogress tests/maps/gnuld/n64/drmario64.us.map asm asm/nonmatchings drmario64 us code --verbose --dry-run
174+
run: uv run mapfile_parser upload_frogress tests/maps/gnuld/n64/drmario64.us.map asm asm/nonmatchings drmario64 us code --verbose --dry-run

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ serde = { version = "1", features = ["derive"], optional = true }
4747
objdiff-core = { version = "2.3.3", default-features = false, features = ["bindings"], optional = true }
4848
# objdiff-core = { git = "https://github.com/encounter/objdiff.git", rev="a367af612b8b30b5bdf40e5c1d0e45df46a5e3e9", default-features = false, features = ["bindings", "std"], optional = true }
4949
serde_json = { version = "1", optional = true }
50-
pyo3 = { version = "0.26", optional = true, features = ["extension-module"]}
50+
pyo3 = { version = "0.26", optional = true, features = ["extension-module", "abi3"]}

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[mypy]
2-
python_version = 3.9
2+
python_version = 3.8
33
check_untyped_defs = True

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ build-backend = "maturin"
2828
[project.scripts]
2929
mapfile_parser = "mapfile_parser.__main__:mapfileParserMain"
3030

31-
[tool.cibuildwheel]
32-
skip = ["cp36-*"]
3331

3432
[tool.maturin]
3533
features = ["pyo3/extension-module", "python_bindings"]

0 commit comments

Comments
 (0)