-
Notifications
You must be signed in to change notification settings - Fork 1
64 lines (60 loc) · 1.91 KB
/
ci.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
name: CI
on:
push:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
pull_request:
branches:
- main
paths:
- 'src/**'
- 'tests/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
test:
name: "Test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install dependencies
run: make install-no-cuda
- name: Run pre-checks
run: make lint
- name: Run tests
run: make test
- name: Get coverage
uses: orgoro/[email protected]
if: github.event_name == 'pull_request'
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
thresholdAll: 0.9
- name: Update and push coverage badge
# Only update the badge on the main branch
if: github.ref == 'refs/heads/main'
run: |
pip install genbadge[coverage]
genbadge coverage -i coverage.xml
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git clone --single-branch --branch gh-pages https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} gh-pages
mkdir -p gh-pages/badges
mv coverage-badge.svg gh-pages/badges/coverage.svg
cd gh-pages
git add badges/coverage.svg
# Check if there are any changes
if git diff --staged --quiet; then
echo "No changes in coverage"
else
git commit -m 'Update coverage badge'
git push origin gh-pages
fi