Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e845c1e
First pass at dispatching test runs
jfriedri-ni Sep 10, 2025
87a33d9
Move python matrix up one level
jfriedri-ni Sep 10, 2025
a5b732e
Prevent name collisions by passing python version
jfriedri-ni Sep 10, 2025
d1e5b1c
Move os matrix to match python location
jfriedri-ni Sep 10, 2025
dc8f39e
Fix run_unit_tests variable usage
jfriedri-ni Sep 10, 2025
f139179
Let grpc_generator use all supported Python versions
jfriedri-ni Sep 10, 2025
800f211
Use if-elif instead of match to support Python 3.9
jfriedri-ni Sep 10, 2025
20a549a
Use mixin enum for Python 3.9 and 3.10
jfriedri-ni Sep 10, 2025
5ff5834
Tidy workflow titles
jfriedri-ni Sep 10, 2025
a9a8095
Upgrade grpc_generator to poetry 2.x
jfriedri-ni Sep 10, 2025
a9d5015
Remove template refs that aren't filled when skipped
jfriedri-ni Sep 10, 2025
17b5808
Try moving the os/python matrix up one more level
jfriedri-ni Sep 10, 2025
431f7c5
Revert "Try moving the os/python matrix up one more level"
jfriedri-ni Sep 10, 2025
725263a
Run tests in parallel with checks
jfriedri-ni Sep 10, 2025
d83dfb3
Move workflow_dispatch to test_package
jfriedri-ni Sep 11, 2025
a3714b8
Fix email format in pyproject.toml
jfriedri-ni Sep 11, 2025
3bbe863
Raise when the caller uses an invalid output format
jfriedri-ni Sep 11, 2025
069b4e4
Use env.pythonVersion rather than an input
jfriedri-ni Sep 11, 2025
67556ed
(fixup) Missed a python version reference
jfriedri-ni Sep 11, 2025
1cddcef
Try env.ImageOS in artifact name
jfriedri-ni Sep 11, 2025
628535a
Print env to job log
jfriedri-ni Sep 11, 2025
8f3d0de
Use the env command
jfriedri-ni Sep 11, 2025
44b124a
Update the job's environment explicitly
jfriedri-ni Sep 11, 2025
80ccebd
Remove unused inputs
jfriedri-ni Sep 11, 2025
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
7 changes: 5 additions & 2 deletions .github/actions/run_and_upload_unit_tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -21,12 +24,12 @@ runs:
working-directory: ${{ github.workspace }}/${{ inputs.package-basepath }}/${{ inputs.package-name }}
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: ${{ github.workspace }}/${{ inputs.package-basepath }}/${{ inputs.package-name }}
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 }}
name: test_results_unit_${{ inputs.package-name }}_${{ env.osVersion }}_py${{ env.pythonVersion }}
path: ${{ github.workspace }}/${{ inputs.package-basepath }}/${{ inputs.package-name }}/test_results/*.xml
if: always()
15 changes: 10 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ jobs:
uses: ./.github/workflows/check_package.yml
with:
package-name: ${{ matrix.package-name }}
run_unit_tests:
name: Run unit tests
uses: ./.github/workflows/run_unit_tests.yml
needs: check_package
test_package:
name: Test ${{ matrix.package-name }}
needs: get_package_names
strategy:
matrix:
package-name: ${{ fromJson(needs.get_package_names.outputs.package-names) }}
uses: ./.github/workflows/test_package.yml
with:
package-name: ${{ matrix.package-name }}
report_test_results:
name: Report test results
uses: ./.github/workflows/report_test_results.yml
needs: run_unit_tests
needs: test_package
if: always()
permissions:
contents: read
Expand Down
70 changes: 30 additions & 40 deletions .github/workflows/run_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,36 @@ name: Run unit tests

on:
workflow_call:
workflow_dispatch:
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
runs-on: ${{ matrix.os }}
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:
matrix:
os: [windows-latest, ubuntu-latest]
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]
# Fail-fast skews the pass/fail ratio and seems to make pytest produce
# incomplete JUnit XML results.
fail-fast: false
Expand All @@ -24,41 +44,11 @@ jobs:
uses: ni/python-actions/setup-python@f0276f7f58868ec0d0d1a86377287c9e6fe0c6e7 # v0.5.0
id: setup-python
with:
python-version: ${{ matrix.python-version }}
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 - ni.protobuf.types
- name: Run and upload unit tests for ${{ inputs.package-name }}
uses: ./.github/actions/run_and_upload_unit_tests
with:
package-name: ni.protobuf.types
- name: Run and upload unit tests - ni.panels.v1.proto
uses: ./.github/actions/run_and_upload_unit_tests
with:
package-name: ni.panels.v1.proto
- name: Run and upload unit tests - ni.measurementlink.measurement.v1.proto
uses: ./.github/actions/run_and_upload_unit_tests
with:
package-name: ni.measurementlink.measurement.v1.proto
- name: Run and upload unit tests - ni.measurementlink.measurement.v2.proto
uses: ./.github/actions/run_and_upload_unit_tests
with:
package-name: ni.measurementlink.measurement.v2.proto
- name: Run and upload unit tests - ni-grpc-extensions
uses: ./.github/actions/run_and_upload_unit_tests
with:
package-name: ni-grpc-extensions
- name: Run and upload unit tests - ni.measurementlink.discovery.v1.client
uses: ./.github/actions/run_and_upload_unit_tests
with:
package-name: ni.measurementlink.discovery.v1.client
- name: Run and upload unit tests - ni.measurementlink.pinmap.v1.client
uses: ./.github/actions/run_and_upload_unit_tests
with:
package-name: ni.measurementlink.pinmap.v1.client
# Run grpc_generator unit tests on its oldest supported version.
- name: Run and upload unit tests - grpc_generator
if: ${{ !contains(fromJSON('["3.9", "3.10"]'), matrix.python-version) }}
uses: ./.github/actions/run_and_upload_unit_tests
with:
package-name: grpc_generator
package-basepath: tools
package-name: ${{ inputs.package-name }}
package-basepath: ${{ inputs.package-basepath }}
38 changes: 38 additions & 0 deletions .github/workflows/test_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Test package

on:
workflow_call:
inputs:
package-name:
description: 'The name of the package folder to test.'
default: ''
required: true
type: string
workflow_dispatch:
inputs:
package-name:
description: 'The name of the package folder to test.'
default: ''
required: true
type: string

jobs:
get_package_info:
name: Get package info for ${{ inputs.package-name }}
uses: ./.github/workflows/get_package_info.yml
with:
package-name: ${{ inputs.package-name }}
run_unit_tests:
if: ${{ needs.get_package_info.outputs.should-run-tests == 'true' }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]
name: Run unit tests
needs: get_package_info
uses: ./.github/workflows/run_unit_tests.yml
with:
package-name: ${{ inputs.package-name }}
package-basepath: ${{ needs.get_package_info.outputs.package-basepath }}
python-version: ${{ matrix.python-version }}
os: ${{ matrix.os }}
Loading
Loading