-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (79 loc) · 2.94 KB
/
pycov.yaml
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
name: Python Coverage
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]
poetry-version: ["1.3.1"]
steps:
- uses: actions/checkout@v3
- name: Setup gcloud Auth
uses: google-github-actions/auth@v1
with:
credentials_json: "${{ secrets.GC_SERVICE_KEY }}"
- name: Setup gcloud CLI
uses: google-github-actions/setup-gcloud@main
with:
version: "412.0.0"
project_id: ${{ secrets.GC_PROJECT_ID }}
- name: Set up Poetry
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'
- name: Install dependencies
run: poetry install --with dev
- name: Run tests
run: |
# Generate coverage report via tests. Does not matter if the tests
# pass here; that's covered by dedicated actions.
poetry run coverage run --source blind_charging -m pytest || true
- name: Generate coverage XML
run: poetry run coverage xml
- name: Interpret coverage report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md
- name: Upload coverage artifacts
if: github.event_name == 'push'
run: |
# Get the badge URL from the first line of the coverage comment.
BADGE_URL=$(cat code-coverage-results.md | head -1 | sed -r 's/.*\((.+)\).*/\1/')
# Download the badge
curl $BADGE_URL > badge.svg
# Generate web assets for coverage report.
poetry run coverage html
# Upload artifacts
gsutil cp badge.svg gs://scpl-blind-charging/coverage/badge.svg
# Remove any old static assets for coverage
gsutil -m rm -r gs://scpl-blind-charging/coverage/www
# Upload coverage static assets
gsutil -m cp -z html,js,json,css,png -r htmlcov/* gs://scpl-blind-charging/coverage/www/
# Make sure no assets get cached
gsutil -m setmeta -r -h "Cache-Control: private, max-age=0, no-transform, no-store, no-cache" gs://scpl-blind-charging/coverage/
# Publish all the artifacts
gsutil -m acl ch -r -u AllUsers:R gs://scpl-blind-charging/coverage/