-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (65 loc) · 2.01 KB
/
_check-coverage-action.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
name: 'Test Coverage Definition'
on:
workflow_call:
inputs:
coverage-module:
description: "Module to test coverage for"
type: string
required: true
python-version:
description: Python version to set up'
default: '3.13'
type: string
runner-os:
description: 'Runner OS'
default: 'ubuntu-latest'
type: string
upload-coverage:
description: 'Upload coverage results'
default: true
type: boolean
required-coverage:
description: 'Required coverage percentage'
default: 100
type: string
show-test-traceback:
description: "Show traceback for failed tests"
type: string
default: "no"
jobs:
run-tests:
runs-on: ${{ inputs.runner-os }}
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
if [[ "$RUNNER_OS" == "macOS" ]]; then
echo "/Users/runner/.local/bin:$PATH" >> $GITHUB_PATH
fi
- name: Configure Poetry
run: poetry config virtualenvs.create false
- name: Install dependencies with Poetry
run: poetry install
- name: Test with pytest
run: |
poetry run pytest tests \
--tb=${{ inputs.show-test-traceback }} \
--cov=${{ inputs.coverage-module }} \
--cov-report=term \
--cov-report=html \
--cov-fail-under=${{ inputs.required-coverage }} > coverage_report.txt
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage_report.txt
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report-html
path: htmlcov