From 5a28e3eeb517e1b24f2ca772ed3f0f85c4ab4494 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 15:44:25 -0500 Subject: [PATCH 01/16] Add check_analyzers --- .github/workflows/CI.yml | 8 ++- .github/workflows/check_analyzers.yml | 75 +++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check_analyzers.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1445022..940c02c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,4 +13,10 @@ jobs: runs-on: ubuntu-latest steps: - name: CI Inactive - run: echo "This CI is inactive. Please activate it by removing this job." \ No newline at end of file + run: echo "This CI is inactive. Please activate it by removing this job." + check_analyzers: + name: Check analyzers for ni.datastore + uses: ./.github/workflows/check_analyzers.yml + with: + package-name: ni.datastore + package-base-path: . \ No newline at end of file diff --git a/.github/workflows/check_analyzers.yml b/.github/workflows/check_analyzers.yml new file mode 100644 index 0000000..55e6504 --- /dev/null +++ b/.github/workflows/check_analyzers.yml @@ -0,0 +1,75 @@ +name: Check analyzers + +on: + workflow_call: + inputs: + package-name: + description: 'The name of the package to check.' + default: '' + required: true + type: string + package-base-path: + description: 'The parent directory of the package to check. Defaults to packages.' + default: 'packages' + required: false + type: string + install-drivers: + description: 'Whether to install drivers extras' + default: false + required: false + type: boolean + +jobs: + check_analyzers: + name: Check analyzers for ${{ inputs.package-name }} + runs-on: ubuntu-latest + defaults: + run: + # Set the working-directory for all steps in this job. + working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} + 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@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + id: setup-python + - name: Set up Poetry + uses: ni/python-actions/setup-poetry@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + - name: Check for lock changes + run: poetry check --lock + - name: Cache virtualenv + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 + with: + path: ${{ inputs.package-base-path }}/${{ inputs.package-name }}/.venv + key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-base-path, inputs.package-name)) }} + - name: Install ${{ inputs.package-name }} + run: | + if [ "${{ inputs.install-drivers }}" = "true" ]; then + poetry install -v --extras drivers + else + poetry install -v + fi + - name: Lint + run: poetry run ni-python-styleguide lint + - name: Mypy static analysis (Linux) + run: poetry run mypy + - name: Mypy static analysis (Windows) + run: poetry run mypy --platform win32 + - name: Bandit security checks + run: poetry run bandit -c pyproject.toml -r src/ + - name: Add virtualenv to the path for pyright-action + run: echo "$(poetry env info --path)/bin" >> $GITHUB_PATH + - name: Pyright static analysis (Linux) + uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 + with: + python-platform: Linux + version: PATH + working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} + - name: Pyright static analysis (Windows) + uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 + with: + python-platform: Windows + version: PATH + working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} From 74b433960ba464a863813cd27d67dc44b9cdb5e7 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 15:47:08 -0500 Subject: [PATCH 02/16] Fix path to package --- .github/workflows/CI.yml | 5 ----- .github/workflows/check_analyzers.yml | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 940c02c..63d7226 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -9,11 +9,6 @@ on: workflow_dispatch: jobs: - todo_make_a_ci: - runs-on: ubuntu-latest - steps: - - name: CI Inactive - run: echo "This CI is inactive. Please activate it by removing this job." check_analyzers: name: Check analyzers for ni.datastore uses: ./.github/workflows/check_analyzers.yml diff --git a/.github/workflows/check_analyzers.yml b/.github/workflows/check_analyzers.yml index 55e6504..d88204d 100644 --- a/.github/workflows/check_analyzers.yml +++ b/.github/workflows/check_analyzers.yml @@ -26,7 +26,7 @@ jobs: defaults: run: # Set the working-directory for all steps in this job. - working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} + working-directory: . steps: - name: Check out repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 From 3ce4acb0d7f9318c56f288acfb9be2b86e1ba98f Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 15:50:28 -0500 Subject: [PATCH 03/16] Fix ni-python-styleguide linting errors --- examples/placeholder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/placeholder.py b/examples/placeholder.py index da732a9..31f1667 100644 --- a/examples/placeholder.py +++ b/examples/placeholder.py @@ -1 +1 @@ -"""Temporary placeholder example.""" \ No newline at end of file +"""Temporary placeholder example.""" From 786530693f21b376fb2d4a7be7f4d31e2fbd8b3d Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 15:53:57 -0500 Subject: [PATCH 04/16] Fix path for pyright --- .github/workflows/check_analyzers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check_analyzers.yml b/.github/workflows/check_analyzers.yml index d88204d..b8e6a27 100644 --- a/.github/workflows/check_analyzers.yml +++ b/.github/workflows/check_analyzers.yml @@ -66,10 +66,10 @@ jobs: with: python-platform: Linux version: PATH - working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} + working-directory: . - name: Pyright static analysis (Windows) uses: jakebailey/pyright-action@b5d50e5cde6547546a5c4ac92e416a8c2c1a1dfe # v2.3.2 with: python-platform: Windows version: PATH - working-directory: ./${{ inputs.package-base-path }}/${{ inputs.package-name }} + working-directory: . From c7ba90891e0bfc06b7c4c84f3743f82399158c9f Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 16:13:33 -0500 Subject: [PATCH 05/16] Add check docs --- .github/workflows/CI.yml | 7 +++++- .github/workflows/check_docs.yml | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/check_docs.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 63d7226..4081c5f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,4 +14,9 @@ jobs: uses: ./.github/workflows/check_analyzers.yml with: package-name: ni.datastore - package-base-path: . \ No newline at end of file + package-base-path: . + check_docs: + name: Check docs for ni.datastore + uses: ./.github/workflows/check_docs.yml + with: + package-name: ni.datastore \ No newline at end of file diff --git a/.github/workflows/check_docs.yml b/.github/workflows/check_docs.yml new file mode 100644 index 0000000..9903acb --- /dev/null +++ b/.github/workflows/check_docs.yml @@ -0,0 +1,43 @@ +name: Check docs + +on: + workflow_call: + inputs: + package-name: + description: 'The name of the package to check.' + default: '' + required: true + type: string + +jobs: + check_docs: + name: Check docs for ${{ inputs.package-name }} + runs-on: ubuntu-latest + defaults: + run: + # Set the working-directory for all steps in this job. + working-directory: . + steps: + - name: Check out repo + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Set up Python + uses: ni/python-actions/setup-python@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + id: setup-python + - name: Set up Poetry + uses: ni/python-actions/setup-poetry@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + - name: Check for lock changes + run: poetry check --lock + - name: Cache virtualenv (with docs) + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 + with: + path: .venv + key: ${{ inputs.package-name }}-with-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('packages/{0}/poetry.lock', inputs.package-name)) }} + - name: Install nitypes (with docs) + run: poetry install -v --only main,docs + - name: Generate docs + run: poetry run sphinx-build docs docs/_build -b html -W + - name: Upload docs artifact + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: ${{ inputs.package-name }}-docs + path: packages/${{ inputs.package-name }}/docs/_build/ \ No newline at end of file From 967ddd1e6d5e4439d4875bfdf6fd1b1154ba93d0 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 16:20:00 -0500 Subject: [PATCH 06/16] Fix path for docs build artifact upload --- .github/workflows/check_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_docs.yml b/.github/workflows/check_docs.yml index 9903acb..1cb4b9d 100644 --- a/.github/workflows/check_docs.yml +++ b/.github/workflows/check_docs.yml @@ -40,4 +40,4 @@ jobs: uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: ${{ inputs.package-name }}-docs - path: packages/${{ inputs.package-name }}/docs/_build/ \ No newline at end of file + path: ./docs/_build/ \ No newline at end of file From b3830d667152da4430f9e0fae7c7e0a1957e172b Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 16:38:38 -0500 Subject: [PATCH 07/16] Run unit tests --- .../run_and_upload_unit_tests/action.yml | 32 +++++++++++ .github/workflows/CI.yml | 14 ++++- .github/workflows/run_unit_tests.yml | 54 +++++++++++++++++++ tests/placeholder.py | 1 + 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 .github/actions/run_and_upload_unit_tests/action.yml create mode 100644 .github/workflows/run_unit_tests.yml create mode 100644 tests/placeholder.py diff --git a/.github/actions/run_and_upload_unit_tests/action.yml b/.github/actions/run_and_upload_unit_tests/action.yml new file mode 100644 index 0000000..294a6d2 --- /dev/null +++ b/.github/actions/run_and_upload_unit_tests/action.yml @@ -0,0 +1,32 @@ +name: 'Run and upload unit tests' +description: 'Run unit tests using pytest and upload the results as an artifact.' +inputs: + package-name: + description: 'The name of the package to run tests for.' + required: true + package-basepath: + description: 'Relative path to the parent directory of the package.' + required: false + default: 'packages' +runs: + using: "composite" + steps: + - name: Cache ${{ inputs.package-name }} virtualenv + uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 + with: + path: ./.venv + key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ env.pythonVersion }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-basepath, inputs.package-name)) }} + - name: Install ${{ inputs.package-name }} + run: poetry install -v + working-directory: . + shell: bash + - name: Run ${{ inputs.package-name }} unit tests and code coverage + run: poetry run pytest ./tests/unit -v --cov=${{ inputs.package-name }} --junitxml=test_results/${{ inputs.package-name }}-${{ matrix.os }}-py${{ matrix.python-version }}.xml + working-directory: . + shell: bash + - name: Upload ${{ inputs.package-name }} test results + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: test_results_unit_${{ inputs.package-name }}_${{ matrix.os }}_py${{ matrix.python-version }} + path: ./test_results/*.xml + if: always() \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4081c5f..00e7552 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -19,4 +19,16 @@ jobs: name: Check docs for ni.datastore uses: ./.github/workflows/check_docs.yml with: - package-name: ni.datastore \ No newline at end of file + package-name: ni.datastore + run_unit_tests: + strategy: + matrix: + os: [windows-latest, ubuntu-latest] + python-version: [3.9, '3.10', 3.11, 3.12, 3.13] + name: Run unit tests + uses: ./.github/workflows/run_unit_tests.yml + with: + package-name: ni.datastore + package-basepath: . + python-version: ${{ matrix.python-version }} + os: ${{ matrix.os }} diff --git a/.github/workflows/run_unit_tests.yml b/.github/workflows/run_unit_tests.yml new file mode 100644 index 0000000..7f3a95d --- /dev/null +++ b/.github/workflows/run_unit_tests.yml @@ -0,0 +1,54 @@ +name: Run unit tests + +on: + workflow_call: + inputs: + package-name: + description: 'The name of the package folder to check.' + default: '' + required: true + type: string + package-basepath: + description: 'The base path of the package to check, relative to the repo root.' + default: '' + required: true + type: string + python-version: + description: 'The version of Python to use' + default: '' + required: true + type: string + os: + description: 'The name of the OS to use' + required: true + type: string + +jobs: + run_unit_tests: + name: Run unit tests for ${{ inputs.package-name }} with ${{ inputs.python-version }} on ${{ inputs.os }} + runs-on: ${{ inputs.os }} + defaults: + run: + # Set the working-directory for all steps in this job. + working-directory: ${{ github.workspace }}/${{ inputs.package-basepath }}/${{ inputs.package-name }} + strategy: + # Fail-fast skews the pass/fail ratio and seems to make pytest produce + # incomplete JUnit XML results. + fail-fast: false + 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@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + id: setup-python + with: + python-version: ${{ inputs.python-version }} + - name: Set up Poetry + uses: ni/python-actions/setup-poetry@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 + - name: Run and upload unit tests for ${{ inputs.package-name }} + uses: ./.github/actions/run_and_upload_unit_tests + with: + package-name: ${{ inputs.package-name }} + package-basepath: ${{ inputs.package-basepath }} diff --git a/tests/placeholder.py b/tests/placeholder.py new file mode 100644 index 0000000..1ba4e64 --- /dev/null +++ b/tests/placeholder.py @@ -0,0 +1 @@ +"""Temporary placeholder tests.""" From 6e8b6a63ae58dfe9358b334edeb30b67c065bfff Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 16:42:48 -0500 Subject: [PATCH 08/16] Add unit tests folder --- tests/__init__.py | 1 + tests/placeholder.py | 1 - tests/unit/__init__.py | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 tests/__init__.py delete mode 100644 tests/placeholder.py create mode 100644 tests/unit/__init__.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..d420712 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Tests.""" diff --git a/tests/placeholder.py b/tests/placeholder.py deleted file mode 100644 index 1ba4e64..0000000 --- a/tests/placeholder.py +++ /dev/null @@ -1 +0,0 @@ -"""Temporary placeholder tests.""" diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..e0310a0 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1 @@ +"""Unit tests.""" From 4284facfc12348941eb9ca7c8cd0f0b35b9bfcf5 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 16:48:21 -0500 Subject: [PATCH 09/16] Add a dummy unit test --- .github/actions/run_and_upload_unit_tests/action.yml | 2 +- tests/unit/__init__.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/actions/run_and_upload_unit_tests/action.yml b/.github/actions/run_and_upload_unit_tests/action.yml index 294a6d2..b85a221 100644 --- a/.github/actions/run_and_upload_unit_tests/action.yml +++ b/.github/actions/run_and_upload_unit_tests/action.yml @@ -28,5 +28,5 @@ runs: uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: test_results_unit_${{ inputs.package-name }}_${{ matrix.os }}_py${{ matrix.python-version }} - path: ./test_results/*.xml + path: ${{ github.workspace }}/test_results/*.xml if: always() \ No newline at end of file diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index e0310a0..16fcb15 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -1 +1,5 @@ """Unit tests.""" + +def test__sanity_checck(): + """Sanity check.""" + assert True \ No newline at end of file From 7b3f5803b842b927294160b6494d5336a9214726 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 16:56:09 -0500 Subject: [PATCH 10/16] another attempt at unit tests --- tests/unit/__init__.py | 4 ---- tests/unit/test_ni_datastore_client.py | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 tests/unit/test_ni_datastore_client.py diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 16fcb15..e0310a0 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -1,5 +1 @@ """Unit tests.""" - -def test__sanity_checck(): - """Sanity check.""" - assert True \ No newline at end of file diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py new file mode 100644 index 0000000..5651c5b --- /dev/null +++ b/tests/unit/test_ni_datastore_client.py @@ -0,0 +1,9 @@ +"""Contains tests to validate the discovery_client.py.""" + +from __future__ import annotations + +from ni.datastore import Client + + +def test__datastore_client() -> None: + assert True From a5e2e99a8858ab0f0925b438413f4c7d0cfc5641 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 16:58:13 -0500 Subject: [PATCH 11/16] Remove import --- tests/unit/test_ni_datastore_client.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index 5651c5b..3733572 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -2,8 +2,6 @@ from __future__ import annotations -from ni.datastore import Client - def test__datastore_client() -> None: assert True From 68c82a4e0039c40961104f6122ca30dec6adc416 Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Thu, 11 Sep 2025 17:03:21 -0500 Subject: [PATCH 12/16] Fix artifact name --- .github/actions/run_and_upload_unit_tests/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/run_and_upload_unit_tests/action.yml b/.github/actions/run_and_upload_unit_tests/action.yml index b85a221..857e285 100644 --- a/.github/actions/run_and_upload_unit_tests/action.yml +++ b/.github/actions/run_and_upload_unit_tests/action.yml @@ -27,6 +27,6 @@ runs: - name: Upload ${{ inputs.package-name }} test results uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - name: test_results_unit_${{ inputs.package-name }}_${{ matrix.os }}_py${{ matrix.python-version }} + name: test_results_unit_${{ inputs.package-name }}_${{ env.osVersion }}_py${{ env.pythonVersion }} path: ${{ github.workspace }}/test_results/*.xml if: always() \ No newline at end of file From 874d4d5da6761671892df354f57d500e98aa91cf Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Fri, 12 Sep 2025 09:05:34 -0500 Subject: [PATCH 13/16] Read env.OsVersion to make upload artifacts unique --- .github/actions/run_and_upload_unit_tests/action.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/actions/run_and_upload_unit_tests/action.yml b/.github/actions/run_and_upload_unit_tests/action.yml index 857e285..f300355 100644 --- a/.github/actions/run_and_upload_unit_tests/action.yml +++ b/.github/actions/run_and_upload_unit_tests/action.yml @@ -11,6 +11,9 @@ inputs: runs: using: "composite" steps: + - name: Get OS version + run: echo "osVersion=$ImageOS" >> "$GITHUB_ENV" + shell: bash - name: Cache ${{ inputs.package-name }} virtualenv uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: From 253f8d787a6735a59c84b025202e6cd905b8c3fb Mon Sep 17 00:00:00 2001 From: Joel Dixon <38357562+dixonjoel@users.noreply.github.com> Date: Fri, 12 Sep 2025 09:16:09 -0500 Subject: [PATCH 14/16] Update tests/unit/test_ni_datastore_client.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/unit/test_ni_datastore_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_ni_datastore_client.py b/tests/unit/test_ni_datastore_client.py index 3733572..974038b 100644 --- a/tests/unit/test_ni_datastore_client.py +++ b/tests/unit/test_ni_datastore_client.py @@ -1,4 +1,4 @@ -"""Contains tests to validate the discovery_client.py.""" +"""Contains tests to validate the datastore client functionality.""" from __future__ import annotations From d66e6edfd82680d8a887fe299f72872cddec8a41 Mon Sep 17 00:00:00 2001 From: Joel Dixon <38357562+dixonjoel@users.noreply.github.com> Date: Fri, 12 Sep 2025 09:17:58 -0500 Subject: [PATCH 15/16] Update .github/actions/run_and_upload_unit_tests/action.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/actions/run_and_upload_unit_tests/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/run_and_upload_unit_tests/action.yml b/.github/actions/run_and_upload_unit_tests/action.yml index f300355..23eb0c7 100644 --- a/.github/actions/run_and_upload_unit_tests/action.yml +++ b/.github/actions/run_and_upload_unit_tests/action.yml @@ -24,7 +24,7 @@ runs: working-directory: . shell: bash - name: Run ${{ inputs.package-name }} unit tests and code coverage - run: poetry run pytest ./tests/unit -v --cov=${{ inputs.package-name }} --junitxml=test_results/${{ inputs.package-name }}-${{ matrix.os }}-py${{ matrix.python-version }}.xml + run: poetry run pytest ./tests/unit -v --cov=${{ inputs.package-name }} --junitxml=test_results/${{ inputs.package-name }}-${{ env.osVersion }}-py${{ env.pythonVersion }}.xml working-directory: . shell: bash - name: Upload ${{ inputs.package-name }} test results From c665b7dc014b47a965db192d9fc410b5aebd083d Mon Sep 17 00:00:00 2001 From: Joel Dixon Date: Fri, 12 Sep 2025 10:40:32 -0500 Subject: [PATCH 16/16] Simplify workflows, hard-coding ni.datastore and the base path --- .../run_and_upload_unit_tests/action.yml | 22 ++++-------- .github/workflows/CI.yml | 9 +---- .github/workflows/check_docs.yml | 13 +++---- ...k_analyzers.yml => check_ni_datastore.yml} | 35 ++++--------------- .github/workflows/run_unit_tests.yml | 23 ++---------- 5 files changed, 21 insertions(+), 81 deletions(-) rename .github/workflows/{check_analyzers.yml => check_ni_datastore.yml} (58%) diff --git a/.github/actions/run_and_upload_unit_tests/action.yml b/.github/actions/run_and_upload_unit_tests/action.yml index 23eb0c7..d7d5ea7 100644 --- a/.github/actions/run_and_upload_unit_tests/action.yml +++ b/.github/actions/run_and_upload_unit_tests/action.yml @@ -1,35 +1,27 @@ name: 'Run and upload unit tests' description: 'Run unit tests using pytest and upload the results as an artifact.' -inputs: - package-name: - description: 'The name of the package to run tests for.' - required: true - package-basepath: - description: 'Relative path to the parent directory of the package.' - required: false - default: 'packages' runs: using: "composite" steps: - name: Get OS version run: echo "osVersion=$ImageOS" >> "$GITHUB_ENV" shell: bash - - name: Cache ${{ inputs.package-name }} virtualenv + - name: Cache ni.datastore virtualenv uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: ./.venv - key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ env.pythonVersion }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-basepath, inputs.package-name)) }} - - name: Install ${{ inputs.package-name }} + key: ni.datastore-${{ runner.os }}-py${{ env.pythonVersion }}-${{ hashFiles('./poetry.lock') }} + - name: Install ni.datastore run: poetry install -v working-directory: . shell: bash - - name: Run ${{ inputs.package-name }} unit tests and code coverage - run: poetry run pytest ./tests/unit -v --cov=${{ inputs.package-name }} --junitxml=test_results/${{ inputs.package-name }}-${{ env.osVersion }}-py${{ env.pythonVersion }}.xml + - name: Run ni.datastore unit tests and code coverage + run: poetry run pytest ./tests/unit -v --cov=ni.datastore --junitxml=test_results/ni.datastore-${{ env.osVersion }}-py${{ env.pythonVersion }}.xml working-directory: . shell: bash - - name: Upload ${{ inputs.package-name }} test results + - name: Upload ni.datastore test results uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - name: test_results_unit_${{ inputs.package-name }}_${{ env.osVersion }}_py${{ env.pythonVersion }} + name: test_results_unit_ni.datastore_${{ env.osVersion }}_py${{ env.pythonVersion }} path: ${{ github.workspace }}/test_results/*.xml if: always() \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 00e7552..85fa86a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -11,15 +11,10 @@ on: jobs: check_analyzers: name: Check analyzers for ni.datastore - uses: ./.github/workflows/check_analyzers.yml - with: - package-name: ni.datastore - package-base-path: . + uses: ./.github/workflows/check_ni_datastore.yml check_docs: name: Check docs for ni.datastore uses: ./.github/workflows/check_docs.yml - with: - package-name: ni.datastore run_unit_tests: strategy: matrix: @@ -28,7 +23,5 @@ jobs: name: Run unit tests uses: ./.github/workflows/run_unit_tests.yml with: - package-name: ni.datastore - package-basepath: . python-version: ${{ matrix.python-version }} os: ${{ matrix.os }} diff --git a/.github/workflows/check_docs.yml b/.github/workflows/check_docs.yml index 1cb4b9d..c603188 100644 --- a/.github/workflows/check_docs.yml +++ b/.github/workflows/check_docs.yml @@ -2,16 +2,11 @@ name: Check docs on: workflow_call: - inputs: - package-name: - description: 'The name of the package to check.' - default: '' - required: true - type: string + workflow_dispatch: jobs: check_docs: - name: Check docs for ${{ inputs.package-name }} + name: Check docs for ni.datastore runs-on: ubuntu-latest defaults: run: @@ -31,7 +26,7 @@ jobs: uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: path: .venv - key: ${{ inputs.package-name }}-with-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('packages/{0}/poetry.lock', inputs.package-name)) }} + key: ni.datastore-with-docs-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }} - name: Install nitypes (with docs) run: poetry install -v --only main,docs - name: Generate docs @@ -39,5 +34,5 @@ jobs: - name: Upload docs artifact uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - name: ${{ inputs.package-name }}-docs + name: ni.datastore-docs path: ./docs/_build/ \ No newline at end of file diff --git a/.github/workflows/check_analyzers.yml b/.github/workflows/check_ni_datastore.yml similarity index 58% rename from .github/workflows/check_analyzers.yml rename to .github/workflows/check_ni_datastore.yml index b8e6a27..a8ade82 100644 --- a/.github/workflows/check_analyzers.yml +++ b/.github/workflows/check_ni_datastore.yml @@ -2,31 +2,12 @@ name: Check analyzers on: workflow_call: - inputs: - package-name: - description: 'The name of the package to check.' - default: '' - required: true - type: string - package-base-path: - description: 'The parent directory of the package to check. Defaults to packages.' - default: 'packages' - required: false - type: string - install-drivers: - description: 'Whether to install drivers extras' - default: false - required: false - type: boolean + workflow_dispatch: jobs: check_analyzers: - name: Check analyzers for ${{ inputs.package-name }} + name: Check analyzers for ni.datastore runs-on: ubuntu-latest - defaults: - run: - # Set the working-directory for all steps in this job. - working-directory: . steps: - name: Check out repo uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 @@ -42,15 +23,11 @@ jobs: - name: Cache virtualenv uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4 with: - path: ${{ inputs.package-base-path }}/${{ inputs.package-name }}/.venv - key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-base-path, inputs.package-name)) }} - - name: Install ${{ inputs.package-name }} + path: ./.venv + key: ni.datastore-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-{{ hashFiles('./poetry.lock') }} + - name: Install ni.datastore run: | - if [ "${{ inputs.install-drivers }}" = "true" ]; then - poetry install -v --extras drivers - else - poetry install -v - fi + poetry install -v - name: Lint run: poetry run ni-python-styleguide lint - name: Mypy static analysis (Linux) diff --git a/.github/workflows/run_unit_tests.yml b/.github/workflows/run_unit_tests.yml index 7f3a95d..1bee334 100644 --- a/.github/workflows/run_unit_tests.yml +++ b/.github/workflows/run_unit_tests.yml @@ -3,16 +3,6 @@ name: Run unit tests on: workflow_call: inputs: - package-name: - description: 'The name of the package folder to check.' - default: '' - required: true - type: string - package-basepath: - description: 'The base path of the package to check, relative to the repo root.' - default: '' - required: true - type: string python-version: description: 'The version of Python to use' default: '' @@ -25,12 +15,8 @@ on: jobs: run_unit_tests: - name: Run unit tests for ${{ inputs.package-name }} with ${{ inputs.python-version }} on ${{ inputs.os }} + name: Run unit tests for ni.datastore with ${{ inputs.python-version }} on ${{ inputs.os }} runs-on: ${{ inputs.os }} - defaults: - run: - # Set the working-directory for all steps in this job. - working-directory: ${{ github.workspace }}/${{ inputs.package-basepath }}/${{ inputs.package-name }} strategy: # Fail-fast skews the pass/fail ratio and seems to make pytest produce # incomplete JUnit XML results. @@ -47,8 +33,5 @@ jobs: python-version: ${{ inputs.python-version }} - name: Set up Poetry uses: ni/python-actions/setup-poetry@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0 - - name: Run and upload unit tests for ${{ inputs.package-name }} - uses: ./.github/actions/run_and_upload_unit_tests - with: - package-name: ${{ inputs.package-name }} - package-basepath: ${{ inputs.package-basepath }} + - name: Run and upload unit tests for ni.datastore + uses: ./.github/actions/run_and_upload_unit_tests \ No newline at end of file