-
Notifications
You must be signed in to change notification settings - Fork 15
79 lines (73 loc) · 3.44 KB
/
run_unit_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Run unit tests
on:
workflow_call:
workflow_dispatch:
env:
POETRY_VERSION: 1.8.2
jobs:
run_unit_tests:
name: Run unit tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
python-version: [3.8, 3.9, '3.10', 3.11, 3.12]
# 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@v4
- name: Set up Python
uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ matrix.python-version }}
- name: Set up Poetry
uses: Gr1N/setup-poetry@v9
with:
poetry-version: ${{ env.POETRY_VERSION }}
# ni-measurement-plugin-sdk-service, no extras
- name: Restore cached virtualenv (ni-measurement-plugin-sdk-service, no extras)
uses: actions/cache/restore@v4
id: restore-nims-no-extras
with:
path: packages/service/.venv
key: ni-measurement-plugin-sdk-service-no-extras-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('packages/service/poetry.lock') }}
- name: Install ni-measurement-plugin-sdk-service (no extras)
run: poetry install -v
working-directory: ./packages/service
- name: Save cached virtualenv (ni-measurement-plugin-sdk-service, no extras)
uses: actions/cache/save@v4
if: steps.restore-nims-no-extras.outputs.cache-hit != 'true'
with:
path: packages/service/.venv
key: ${{ steps.restore-nims-no-extras.outputs.cache-primary-key }}
- name: Run unit tests and code coverage (ni-measurement-plugin-sdk-service, no extras)
run: poetry run pytest ./tests/unit -v --cov=ni_measurement_plugin_sdk_service --junitxml=test_results/nims-${{ matrix.os }}-py${{ matrix.python-version}}-no-extras.xml
working-directory: ./packages/service
# ni-measurement-plugin-sdk-service, all extras
- name: Restore cached virtualenv (ni-measurement-plugin-sdk-service, all extras)
uses: actions/cache/restore@v4
id: restore-nims-all-extras
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
working-directory: ./packages/service
- name: Save cached ni-measurement-plugin-sdk-service virtualenv (all extras)
uses: actions/cache/save@v4
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: Run unit tests and code coverage (ni-measurement-plugin-sdk-service, all extras)
run: poetry run pytest ./tests/unit -v --cov=ni_measurement_plugin_sdk_service --junitxml=test_results/nims-${{ matrix.os }}-py${{ matrix.python-version}}-all-extras.xml
working-directory: ./packages/service
- name: Upload test results
uses: actions/upload-artifact@v4
with:
name: test_results_unit_${{ matrix.os }}_py${{ matrix.python-version }}
path: ./packages/service/test_results/*.xml
if: always()