Repository navigation
53 lines (45 loc) · 1.66 KB
/
Copy pathcode-coverage.yml
File metadata and controls
53 lines (45 loc) · 1.66 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
name: Code Coverage
# Runs the test suite, produces a Cobertura XML coverage report, and uploads it
# to GitHub Code Quality. Once Code Quality is enabled for the repo, a coverage
# summary from github-code-quality[bot] appears on every pull request.
#
# Uploading requires the `code-quality: write` permission below.
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
code-quality: write
jobs:
test:
runs-on: ubuntu-latest
steps:
# Check out the PR head commit (not the merge commit) so coverage line
# numbers map correctly to the diff.
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run tests with coverage
run: pytest --cov=pizzeria --cov-report=xml
- name: Upload coverage report
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: actions/upload-code-coverage@v1
with:
file: coverage.xml
language: Python
label: code-coverage/pytest
# Until Code Quality is enabled the upload endpoint returns 404. Treat
# that as a warning so the workflow stays green out of the box; once
# Code Quality is on, the upload succeeds and coverage shows up on
# pull requests.
fail-on-error: false