Skip to content

Commit 957904e

Browse files
mjohanse-emrMichael Johansen
andauthored
Add a workflow step to run the grpc_generator unit tests. (#25)
* Add a workflow step to run the grpc_generator unit tests. Signed-off-by: Michael Johansen <[email protected]> * Move grpc_generator tests into a 'unit' subfolder to work with workflows. Signed-off-by: Michael Johansen <[email protected]> * Only run grpc_generator tests on python >= 3.11. Signed-off-by: Michael Johansen <[email protected]> * Treat the version as a string when comparing. Signed-off-by: Michael Johansen <[email protected]> * Try not using the ${{ }} dereference. Also just try a simple equals. Signed-off-by: Michael Johansen <[email protected]> * Try switching back to 'greater than'. Signed-off-by: Michael Johansen <[email protected]> * Use fromJSON to convert the version to a number for easier comparision. Signed-off-by: Michael Johansen <[email protected]> * Just go back to == 3.11. Testing against the oldest supported version is sufficient. Signed-off-by: Michael Johansen <[email protected]> * Fix broken syntax. Signed-off-by: Michael Johansen <[email protected]> * Address review feedback. Try a new if statement. Signed-off-by: Michael Johansen <[email protected]> --------- Signed-off-by: Michael Johansen <[email protected]> Co-authored-by: Michael Johansen <[email protected]>
1 parent 6e0f609 commit 957904e

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

.github/actions/run_and_upload_unit_tests/action.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,29 @@ inputs:
44
package-name:
55
description: 'The name of the package to run tests for.'
66
required: true
7+
package-basepath:
8+
description: 'Relative path to the parent directory of the package.'
9+
required: false
10+
default: 'packages'
711
runs:
812
using: "composite"
913
steps:
1014
- name: Cache ${{ inputs.package-name }} virtualenv
1115
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
1216
with:
13-
path: ./packages/${{ inputs.package-name }}/.venv
14-
key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ env.pythonVersion }}-${{ hashFiles(format('packages/{0}/poetry.lock', inputs.package-name)) }}
17+
path: ./${{ inputs.package-basepath }}/${{ inputs.package-name }}/.venv
18+
key: ${{ inputs.package-name }}-${{ runner.os }}-py${{ env.pythonVersion }}-${{ hashFiles(format('{0}/{1}/poetry.lock', inputs.package-basepath, inputs.package-name)) }}
1519
- name: Install ${{ inputs.package-name }}
1620
run: poetry install -v
17-
working-directory: ./packages/${{ inputs.package-name }}
21+
working-directory: ./${{ inputs.package-basepath }}/${{ inputs.package-name }}
1822
shell: bash
1923
- name: Run ${{ inputs.package-name }} unit tests and code coverage
2024
run: poetry run pytest ./tests/unit -v --cov=${{ inputs.package-name }} --junitxml=test_results/${{ inputs.package-name }}-${{ matrix.os }}-py${{ matrix.python-version }}.xml
21-
working-directory: ./packages/${{ inputs.package-name }}
25+
working-directory: ./${{ inputs.package-basepath }}/${{ inputs.package-name }}
2226
shell: bash
2327
- name: Upload ${{ inputs.package-name }} test results
2428
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
2529
with:
2630
name: test_results_unit_${{ inputs.package-name }}_${{ matrix.os }}_py${{ matrix.python-version }}
27-
path: ./packages/${{ inputs.package-name }}/test_results/*.xml
31+
path: ./${{ inputs.package-basepath }}/${{ inputs.package-name }}/test_results/*.xml
2832
if: always()

.github/workflows/run_unit_tests.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,10 @@ jobs:
3535
uses: ./.github/actions/run_and_upload_unit_tests
3636
with:
3737
package-name: ni.pythonpanel.v1.proto
38+
# Run grpc_generator unit tests on its oldest supported version.
39+
- name: Run and upload unit tests - grpc_generator
40+
if: ${{ !contains(fromJSON('["3.9", "3.10"]'), matrix.python-version) }}
41+
uses: ./.github/actions/run_and_upload_unit_tests
42+
with:
43+
package-name: grpc_generator
44+
package-basepath: tools
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Unit tests for grpc_generator."""

0 commit comments

Comments
 (0)