-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (96 loc) · 3.53 KB
/
Copy pathcoverage-pages.yml
File metadata and controls
120 lines (96 loc) · 3.53 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Tests and Coverage Reports
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: write # Needed for badge commit
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
test-and-deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Verify installation
run: |
python -c "import polystore; print(f'polystore {polystore.__version__} installed successfully')"
- name: Run tests with coverage
run: |
mkdir -p site
python -m pytest --cov=polystore \
--cov-report=xml \
--cov-report=html:site/coverage \
-v
- name: Generate coverage badge
run: |
mkdir -p .github/badges
genbadge coverage -i coverage.xml -o .github/badges/coverage.svg -n "coverage report"
- name: Create index.html and README
run: |
# Create index.html for redirection
cat > site/index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=./coverage/">
<title>Redirecting to coverage report...</title>
</head>
<body>
<p>Redirecting to coverage report... <a href="./coverage/">Click here if not redirected</a></p>
</body>
</html>
EOF
# Create README.md in the site directory
cat > site/README.md << 'EOF'
# Polystore Code Coverage Reports
This site contains the code coverage reports for the [Polystore](https://github.com/trissim/polystore) project.
## Navigation
- [Coverage Report](./coverage/): View the HTML coverage report
## About
These reports are automatically generated by GitHub Actions whenever changes are pushed to the main branch.
They show the percentage of code that is covered by automated tests.
Last updated: $(date)
EOF
- name: Commit and push if coverage badge changed
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add .github/badges/coverage.svg -f
git commit -m "chore: update coverage badge" || exit 0
git push
- name: Check GitHub Pages status
run: |
echo "⚠️ IMPORTANT: Make sure GitHub Pages is enabled in your repository settings!"
echo "Go to https://github.com/trissim/polystore/settings/pages"
echo "Set 'Source' to 'GitHub Actions' to enable GitHub Pages deployment."
- name: Setup Pages
continue-on-error: true
uses: actions/configure-pages@v4
- name: Upload Pages artifact
continue-on-error: true
uses: actions/upload-pages-artifact@v3
with:
path: 'site'
retention-days: 1
- name: Deploy to GitHub Pages
id: deployment
continue-on-error: true
uses: actions/deploy-pages@v4
timeout-minutes: 10