Skip to content

Commit f62d75e

Browse files
committed
Deployment of coverage to github pages
1 parent d8b76a1 commit f62d75e

1 file changed

Lines changed: 52 additions & 13 deletions

File tree

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
name: Test Coverage
22

33
on:
4+
# Run on pushes to these branches
45
push:
56
branches:
67
- master
78
- feature/*
89
- develop
10+
# Run on pull requests to these branches
911
pull_request:
1012
branches:
1113
- master
1214
- feature/*
1315
- develop
16+
# Allow manual trigger
17+
workflow_dispatch:
18+
19+
# Permissions needed for GitHub Pages
20+
permissions:
21+
contents: read
22+
pages: write
23+
id-token: write
24+
25+
# Allow only one concurrent deployment
26+
concurrency:
27+
group: "pages"
28+
cancel-in-progress: false
1429

1530
jobs:
31+
# First job: Run tests and generate coverage report
1632
test-coverage:
1733
name: Run Tests with Coverage
1834
runs-on: ubuntu-latest
1935
steps:
2036
- name: Checkout code
21-
uses: actions/checkout@v3
37+
uses: actions/checkout@v4
2238

2339
- name: Set up Python 3.9
2440
uses: actions/setup-python@v4
@@ -32,18 +48,41 @@ jobs:
3248
3349
- name: Run tests with coverage
3450
run: |
35-
pytest --cov=backend --cov-report=xml --cov-report=html tests/
36-
37-
- name: Upload coverage to Codecov
38-
uses: codecov/codecov-action@v3
51+
pytest --cov=backend --cov-report=html tests/
52+
53+
- name: Upload coverage reports artifact
54+
if: github.ref == 'refs/heads/master'
55+
uses: actions/upload-artifact@v3
3956
with:
40-
file: ./coverage.xml
41-
fail_ci_if_error: false
57+
name: coverage-report
58+
path: htmlcov/
59+
retention-days: 7
4260

43-
- name: Deploy coverage report to GitHub Pages
44-
uses: JamesIves/github-pages-deploy-action@v4
45-
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'
61+
# Second job: Deploy coverage report to GitHub Pages
62+
deploy:
63+
name: Deploy Coverage Report
64+
needs: test-coverage
65+
# Only deploy from master branch
66+
if: github.ref == 'refs/heads/master'
67+
environment:
68+
name: github-pages
69+
url: ${{ steps.deployment.outputs.page_url }}
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Download coverage reports
73+
uses: actions/download-artifact@v3
74+
with:
75+
name: coverage-report
76+
path: htmlcov/
77+
78+
- name: Setup Pages
79+
uses: actions/configure-pages@v3
80+
81+
- name: Upload pages artifact
82+
uses: actions/upload-pages-artifact@v2
4683
with:
47-
folder: htmlcov
48-
branch: gh-pages
49-
clean: true
84+
path: './htmlcov'
85+
86+
- name: Deploy to GitHub Pages
87+
id: deployment
88+
uses: actions/deploy-pages@v2

0 commit comments

Comments
 (0)