Skip to content

Commit d1faf79

Browse files
authored
github: Update build.yml to use analyze-project and test oldest/newest Python versions (#890)
* github: Update build.yml to use analyze-project and test oldest/newest Python versions * nidaqmx: Address nps/mypy errors caught by testing with older/newer Python * github: Check codegen on Linux and add a variable for codegen-python-version
1 parent bb68aea commit d1faf79

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ jobs:
77
build:
88
name: Build
99
runs-on:
10-
- ubuntu-latest
10+
- ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, windows-latest]
14+
python-version: ["3.9", "3.14"] # oldest supported and latest tested
15+
env:
16+
codegen-python-version: "3.9"
1117
steps:
1218
- name: Check out repo
1319
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -17,30 +23,20 @@ jobs:
1723
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
1824
id: setup-python
1925
with:
20-
# The codegen scripts require Python 3.10 or later.
21-
python-version: "3.10"
26+
python-version: ${{ matrix.python-version }}
2227
- name: Set up Poetry
2328
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
24-
- name: Cache virtualenv (all extras)
25-
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
29+
- name: Run linters and type checkers
30+
uses: ni/python-actions/analyze-project@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
2631
with:
27-
path: .venv
28-
key: nidaqmx-all-extras-and-examples-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
poetry install --all-extras --with examples
33-
- name: Run linters
34-
run: poetry run ni-python-styleguide lint
35-
- name: Run mypy (Linux)
36-
run: poetry run mypy
37-
- name: Run mypy (Windows)
38-
run: poetry run mypy --platform win32
32+
install-args: "--all-extras --with examples"
3933
- name: Run Bandit security checks
4034
run: poetry run bandit -c pyproject.toml -r generated/nidaqmx
4135
- name: Generate ni-daqmx files
36+
if: ${{ runner.os == 'Linux' && matrix.python-version == env.codegen-python-version }}
4237
run: |
4338
rm -fr generated/nidaqmx
4439
poetry run python src/codegen --dest generated/nidaqmx
4540
- name: Check for files dirtied by codegen
41+
if: ${{ runner.os == 'Linux' && matrix.python-version == env.codegen-python-version }}
4642
run: git diff --exit-code

generated/nidaqmx/_feature_toggles.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""nidaqmx feature toggles."""
22

3+
# mypy: no-warn-unreachable
34
from __future__ import annotations
45

56
import functools
@@ -20,8 +21,6 @@
2021

2122
_PREFIX = "NIDAQMX"
2223

23-
_config = AutoConfig(str(get_dotenv_search_path()))
24-
2524
if TYPE_CHECKING:
2625
# Work around decouple's lack of type hints.
2726
def _config(
@@ -30,6 +29,9 @@ def _config(
3029
cast: Callable[[str], _T] | Undefined = undefined,
3130
) -> _T: ...
3231

32+
else:
33+
_config = AutoConfig(str(get_dotenv_search_path()))
34+
3335

3436
# Based on the recipe at https://docs.python.org/3/howto/enum.html
3537
class _OrderedEnum(Enum):

src/handwritten/_feature_toggles.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""nidaqmx feature toggles."""
22

3+
# mypy: no-warn-unreachable
34
from __future__ import annotations
45

56
import functools
@@ -20,8 +21,6 @@
2021

2122
_PREFIX = "NIDAQMX"
2223

23-
_config = AutoConfig(str(get_dotenv_search_path()))
24-
2524
if TYPE_CHECKING:
2625
# Work around decouple's lack of type hints.
2726
def _config(
@@ -30,6 +29,9 @@ def _config(
3029
cast: Callable[[str], _T] | Undefined = undefined,
3130
) -> _T: ...
3231

32+
else:
33+
_config = AutoConfig(str(get_dotenv_search_path()))
34+
3335

3436
# Based on the recipe at https://docs.python.org/3/howto/enum.html
3537
class _OrderedEnum(Enum):

0 commit comments

Comments
 (0)