Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,31 @@ jobs:
check_nims:
name: Check NIMS
uses: ./.github/workflows/check_nims.yml
check_nims_docs:
name: Check NIMS docs
uses: ./.github/workflows/check_nims_docs.yml
check_nimg:
name: Check NIMG
uses: ./.github/workflows/check_nimg.yml
checks_succeeded:
name: Checks succeeded
needs: [check_nims, check_nims_docs, check_nimg]
runs-on: ubuntu-latest
steps:
- run: exit 0
check_examples:
name: Check examples
uses: ./.github/workflows/check_examples.yml
run_unit_tests:
name: Run unit tests
uses: ./.github/workflows/run_unit_tests.yml
needs: [check_nims]
unit_tests_succeeded:
name: Unit tests succeeded
needs: [run_unit_tests]
runs-on: ubuntu-latest
steps:
- run: exit 0
run_system_tests:
name: Run system tests
uses: ./.github/workflows/run_system_tests.yml
Expand Down
31 changes: 15 additions & 16 deletions .github/workflows/check_nimg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ on:
jobs:
check_nimg:
name: Check NIMG
runs-on: ubuntu-latest
env:
oldest-python-version: '3.9'
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, 3.13]
runs-on: ${{ matrix.os }}
defaults:
run:
# Set the working-directory for all steps in this job.
Expand All @@ -18,33 +24,26 @@ jobs:
- name: Set up Python
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
- name: Check for lock changes (ni-measurement-plugin-sdk-generator)
run: poetry check --lock
- name: Cache virtualenv (ni-measurement-plugin-sdk-generator)
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: cache
- name: Analyze generator
uses: ni/python-actions/analyze-project@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
with:
path: packages/generator/.venv
key: ni-measurement-plugin-sdk-generator-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/generator/poetry.lock') }}
- name: Install ni-measurement-plugin-sdk-generator
run: poetry install -v
- name: Lint ni-measurement-plugin-sdk-generator
run: poetry run ni-python-styleguide lint
- name: Mypy static analysis (ni-measurement-plugin-sdk-generator, Linux)
run: poetry run mypy
- name: Mypy static analysis (ni-measurement-plugin-sdk-generator, Windows)
run: poetry run mypy --platform win32
project-directory: packages/generator
- name: Bandit security checks (ni-measurement-plugin-sdk-generator, example_renders)
run: poetry run bandit -c pyproject.toml -r ni_measurement_plugin_sdk_generator tests/test_assets/example_renders
- name: Generate gRPC stubs
if: matrix.python-version == env.oldest-python-version
run: |
find tests/utilities/measurements/non_streaming_data_measurement/_stubs -name \*_pb2.py\* -o -name \*_pb2_grpc.py\* -delete
poetry run python scripts/generate_grpc_stubs.py
- name: Check for out-of-date gRPC stubs
if: matrix.python-version == env.oldest-python-version
run: git diff --exit-code
- name: Revert gRPC stubs
if: matrix.python-version == env.oldest-python-version
run: |
git clean -dfx tests/utilities/measurements/non_streaming_data_measurement/_stubs
git restore tests/utilities/measurements/non_streaming_data_measurement/_stubs
63 changes: 16 additions & 47 deletions .github/workflows/check_nims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ on:
jobs:
check_nims:
name: Check NIMS
runs-on: ubuntu-latest
env:
oldest-python-version: '3.9'
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.9, 3.13]
runs-on: ${{ matrix.os }}
defaults:
run:
# Set the working-directory for all steps in this job.
Expand All @@ -20,64 +26,27 @@ jobs:
- name: Set up Python
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
- name: Check for lock changes (ni-measurement-plugin-sdk-service)
run: poetry check --lock

# ni-measurement-plugin-sdk-service, all extras
- name: Restore cached virtualenv (ni-measurement-plugin-sdk-service, all extras)
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: restore-nims-all-extras
- name: Analyze generator
uses: ni/python-actions/analyze-project@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
with:
path: packages/service/.venv
key: ni-measurement-plugin-sdk-service-all-extras-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/service/poetry.lock') }}
- name: Install ni-measurement-plugin-sdk-service (all extras)
run: poetry install -v --all-extras
- name: Save cached virtualenv (ni-measurement-plugin-sdk-service, all extras)
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
if: steps.restore-nims-all-extras.outputs.cache-hit != 'true'
with:
path: packages/service/.venv
key: ${{ steps.restore-nims-all-extras.outputs.cache-primary-key }}
- name: Lint ni-measurement-plugin-sdk-service
run: poetry run ni-python-styleguide lint
- name: Mypy static analysis (ni-measurement-plugin-sdk-service, Linux)
run: poetry run mypy
- name: Mypy static analysis (ni-measurement-plugin-sdk-service, Windows)
run: poetry run mypy --platform win32
project-directory: packages/service
install-args: --all-extras
- name: Bandit security checks (ni-measurement-plugin-sdk-service)
run: poetry run bandit -c pyproject.toml -r ni_measurement_plugin_sdk_service

# ni-measurement-plugin-sdk-service, all extras, docs
- name: Restore cached virtualenv (ni-measurement-plugin-sdk-service, all extras, docs)
uses: actions/cache/restore@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
id: restore-nims-all-extras-docs
with:
path: packages/service/.venv
key: ni-measurement-plugin-sdk-service-all-extras-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/service/poetry.lock') }}
- name: Install ni-measurement-plugin-sdk-service (all extras, docs)
run: poetry install -v --all-extras --with docs
- name: Save cached virtualenv (ni-measurement-plugin-sdk-service, all extras, docs)
uses: actions/cache/save@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
if: steps.restore-nims-all-extras-docs.outputs.cache-hit != 'true'
with:
path: packages/service/.venv
key: ${{ steps.restore-nims-all-extras-docs.outputs.cache-primary-key }}
- name: Build docs and check for errors/warnings
run: |
rm -rf docs
mkdir -p docs
poetry run sphinx-build _docs_source docs -b html -W
- name: Revert docs
run: rm -rf docs
- name: Generate gRPC stubs
if: matrix.python-version == env.oldest-python-version
run: |
find tests/utilities/stubs/ -name \*_pb2.py\* -o -name \*_pb2_grpc.py\* -delete
poetry run python scripts/generate_grpc_stubs.py
- name: Check for out-of-date gRPC stubs
if: matrix.python-version == env.oldest-python-version
run: git diff --exit-code
- name: Revert gRPC stubs
if: matrix.python-version == env.oldest-python-version
run: |
git clean -dfx tests/utilities/stubs/
git restore tests/utilities/stubs/
33 changes: 33 additions & 0 deletions .github/workflows/check_nims_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Check NIMS Docs

on:
workflow_call:
workflow_dispatch:

jobs:
check_nims:
name: Check NIMS Docs
runs-on: ubuntu-latest
defaults:
run:
# Set the working-directory for all steps in this job.
working-directory: ./packages/service
steps:
- name: Check out repo
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
submodules: true
- name: Set up Python
uses: ni/python-actions/setup-python@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
id: setup-python
- name: Set up Poetry
uses: ni/python-actions/setup-poetry@9768589f3e50672173dad75a6fc181e4a85d33fa # v0.7.0
- name: Install ni-measurement-plugin-sdk-service (all extras, docs)
run: poetry install -v --all-extras --with docs
- name: Build docs and check for errors/warnings
run: |
rm -rf docs
mkdir -p docs
poetry run sphinx-build _docs_source docs -b html -W
- name: Revert docs
run: rm -rf docs
5 changes: 4 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ jobs:
check_nims:
name: Check service
uses: ./.github/workflows/check_nims.yml
check_nims_docs:
name: Check NIMS docs
uses: ./.github/workflows/check_nims_docs.yml
build_package:
name: Build ${{ matrix.package }}
runs-on: ubuntu-latest
needs: [check_nimg, check_nims]
needs: [check_nimg, check_nims, check_nims_docs]
strategy:
matrix:
package: [generator, sdk, service]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@

_PREFIX = "MEASUREMENT_PLUGIN"

_config = AutoConfig(str(get_dotenv_search_path()))
# Work around decouple's lack of type hints.
_T = TypeVar("_T")

if TYPE_CHECKING:
# Work around decouple's lack of type hints.
_T = TypeVar("_T")

def _config(
option: str,
default: _T | Undefined = undefined,
cast: Callable[[str], _T] | Undefined = undefined,
) -> _T: ...

else:
_config = AutoConfig(str(get_dotenv_search_path()))


# ----------------------------------------------------------------------
# NI Modular Instrument Driver Options
Expand Down
Loading