-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yaml
More file actions
78 lines (66 loc) · 1.93 KB
/
action.yaml
File metadata and controls
78 lines (66 loc) · 1.93 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
name: Pytest
description: Run pytest with given minimum coverage.
inputs:
package-name:
description: "Main module name for code coverage report."
required: false
default: ""
min-cov:
description: "Minimum code coverage."
required: false
default: "0"
retention-days:
description: "Retention days for artifacts."
required: false
default: "10"
target:
description: "Folder which contains the targeted tests."
required: false
default: "tests/"
logs:
description: "Logs from test run. Can be overloaded with wildcard pattern."
required: false
default: "*log"
runs:
using: "composite"
steps:
- name: Poetry install
uses: wintero92/poetry-install-action@v1
- name: Pytest with code coverage
if: inputs.package-name != ''
shell: bash
run: |
source .venv/bin/activate
coverage run --source=${{inputs.package-name}} -m pytest -s ${{inputs.target}}
coverage html
coverage report --fail-under=${{inputs.min-cov}}
- name: Pytest
if: inputs.package-name == ''
shell: bash
run: |
source .venv/bin/activate
pytest -s ${{inputs.target}}
- name: Prepare artifact name
if: always()
shell: bash
run: |
TARGET=${{inputs.target}}
TARGET=${TARGET//\//-}
TARGET=${TARGET%-}
TIMESTAMP=$(date +%s)
echo ARTIFACT_NAME=${TARGET}-${TIMESTAMP} >> $GITHUB_ENV
- name: Upload pytest report
uses: actions/upload-artifact@v3
with:
name: pytest-report-${{env.ARTIFACT_NAME}}
path: htmlcov
retention-days: ${{inputs.retention-days}}
if-no-files-found: ignore
- name: Upload logs
if: always()
uses: actions/upload-artifact@v3
with:
name: logs-${{env.ARTIFACT_NAME}}
path: ${{inputs.logs}}
retention-days: ${{inputs.retention-days}}
if-no-files-found: ignore