-
Notifications
You must be signed in to change notification settings - Fork 14
157 lines (137 loc) · 5.42 KB
/
unittests.yaml
File metadata and controls
157 lines (137 loc) · 5.42 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
name: Unit Tests
on:
pull_request:
branches:
- main
paths:
- 'tests/**'
- 'tools/**'
- '.github/workflows/unittests.yaml'
- 'requirements*.txt'
workflow_call:
inputs:
ml_ref:
description: 'luxonis-ml version (branch/tag/SHA)'
required: true
type: string
tools_ref:
description: 'tools version (branch/tag/SHA)'
required: true
type: string
jobs:
run_tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
version: ['3.10', '3.11']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout at tools_ref
if: ${{ inputs.tools_ref != '' }}
uses: actions/checkout@v4
with:
repository: Luxonis/tools
ref: ${{ inputs.tools_ref }}
path: tools
submodules: recursive # Ensures submodules are cloned
- name: Checkout
if: ${{ inputs.tools_ref == '' && inputs.ml_ref == '' }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive # Ensures submodules are cloned
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version }}
cache: pip
- name: Install dependencies
shell: bash
working-directory: ${{ inputs.tools_ref != '' && 'tools' || '' }}
run: |
CONSTRAINTS_FILE="$GITHUB_WORKSPACE/constraints.txt"
echo "setuptools<81" > "$CONSTRAINTS_FILE"
export PIP_CONSTRAINT="$CONSTRAINTS_FILE"
pip install -e .[dev]
pip install coverage-badge>=1.1.0 pytest-cov>=4.1.0
- name: Install specified luxonis-ml
shell: bash
if: inputs.ml_ref != ''
working-directory: tools
env:
ML_REF: ${{ inputs.ml_ref }}
run: |
pip uninstall luxonis-ml -y
pip install \
"luxonis-ml[data,nn_archive,utils] @ git+https://github.com/luxonis/luxonis-ml.git@${ML_REF}" \
--upgrade --force-reinstall
- name: Run tests with coverage [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
working-directory: ${{ inputs.tools_ref != '' && 'tools' || '' }}
env:
COVERAGE_PROCESS_START: .coveragerc
run: |
coverage erase
coverage run -m pytest tests/test_unittests.py --download-weights --delete-weights-now -s -v --junit-xml pytest.xml
coverage combine
coverage xml -o coverage.xml -i # Recent changes to coverage 7.13 make it stricter where it was previously passing https://coverage.readthedocs.io/en/7.13.0/messages.html#error-no-source
- name: Run tests [Windows, macOS]
if: matrix.os != 'ubuntu-latest' || matrix.version != '3.10'
working-directory: ${{ inputs.tools_ref != '' && 'tools' || '' }}
run: pytest tests/test_unittests.py --download-weights --delete-weights-now -s -v --junit-xml pytest.xml
- name: Generate coverage badge [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' && inputs.tools_ref == '' && inputs.ml_ref == ''
run: coverage-badge -f -o media/coverage_badge.svg
- name: Generate coverage report [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' && inputs.tools_ref == '' && inputs.ml_ref == ''
uses: orgoro/coverage@v3.1
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
# Skip coverage badge for forks because we cannot push to another fork without their PAT
- name: Commit coverage badge [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' && inputs.tools_ref == '' && inputs.ml_ref == '' && github.event.pull_request.head.repo.full_name == github.repository
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
git diff --quiet media/coverage_badge.svg || {
git add media/coverage_badge.svg
git commit -m "[Automated] Updated coverage badge"
}
- name: Push changes [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10' && inputs.tools_ref == '' && inputs.ml_ref == '' && github.event.pull_request.head.repo.full_name == github.repository
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}
- name: Upload Test Results
if: always() && inputs.tools_ref == '' && inputs.ml_ref == ''
uses: actions/upload-artifact@v4
with:
name: Test Results [${{ matrix.os }}] (Python ${{ matrix.version }})
path: pytest.xml
retention-days: 10
if-no-files-found: error
publish-test-results:
name: "Publish Tests Results"
needs: run_tests
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
if: always() && inputs.tools_ref == '' && inputs.ml_ref == ''
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/*.xml"