diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 49397323..2636495c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,13 @@ jobs: build: name: Build runs-on: - - ubuntu-latest + - ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + python-version: ["3.9", "3.14"] # oldest supported and latest tested + env: + codegen-python-version: "3.9" steps: - name: Check out repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -17,30 +23,20 @@ jobs: uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0 id: setup-python with: - # The codegen scripts require Python 3.10 or later. - python-version: "3.10" + python-version: ${{ matrix.python-version }} - name: Set up Poetry uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0 - - name: Cache virtualenv (all extras) - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + - name: Run linters and type checkers + uses: ni/python-actions/analyze-project@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0 with: - path: .venv - key: nidaqmx-all-extras-and-examples-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - poetry install --all-extras --with examples - - name: Run linters - run: poetry run ni-python-styleguide lint - - name: Run mypy (Linux) - run: poetry run mypy - - name: Run mypy (Windows) - run: poetry run mypy --platform win32 + install-args: "--all-extras --with examples" - name: Run Bandit security checks run: poetry run bandit -c pyproject.toml -r generated/nidaqmx - name: Generate ni-daqmx files + if: ${{ runner.os == 'Linux' && matrix.python-version == env.codegen-python-version }} run: | rm -fr generated/nidaqmx poetry run python src/codegen --dest generated/nidaqmx - name: Check for files dirtied by codegen + if: ${{ runner.os == 'Linux' && matrix.python-version == env.codegen-python-version }} run: git diff --exit-code diff --git a/generated/nidaqmx/_feature_toggles.py b/generated/nidaqmx/_feature_toggles.py index 908ab1e2..beda1173 100644 --- a/generated/nidaqmx/_feature_toggles.py +++ b/generated/nidaqmx/_feature_toggles.py @@ -1,5 +1,6 @@ """nidaqmx feature toggles.""" +# mypy: no-warn-unreachable from __future__ import annotations import functools @@ -20,8 +21,6 @@ _PREFIX = "NIDAQMX" -_config = AutoConfig(str(get_dotenv_search_path())) - if TYPE_CHECKING: # Work around decouple's lack of type hints. def _config( @@ -30,6 +29,9 @@ def _config( cast: Callable[[str], _T] | Undefined = undefined, ) -> _T: ... +else: + _config = AutoConfig(str(get_dotenv_search_path())) + # Based on the recipe at https://docs.python.org/3/howto/enum.html class _OrderedEnum(Enum): diff --git a/src/handwritten/_feature_toggles.py b/src/handwritten/_feature_toggles.py index 908ab1e2..beda1173 100644 --- a/src/handwritten/_feature_toggles.py +++ b/src/handwritten/_feature_toggles.py @@ -1,5 +1,6 @@ """nidaqmx feature toggles.""" +# mypy: no-warn-unreachable from __future__ import annotations import functools @@ -20,8 +21,6 @@ _PREFIX = "NIDAQMX" -_config = AutoConfig(str(get_dotenv_search_path())) - if TYPE_CHECKING: # Work around decouple's lack of type hints. def _config( @@ -30,6 +29,9 @@ def _config( cast: Callable[[str], _T] | Undefined = undefined, ) -> _T: ... +else: + _config = AutoConfig(str(get_dotenv_search_path())) + # Based on the recipe at https://docs.python.org/3/howto/enum.html class _OrderedEnum(Enum):