-
Notifications
You must be signed in to change notification settings - Fork 3
76 lines (63 loc) · 2.36 KB
/
tests.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
64
65
66
67
68
69
70
71
72
73
74
75
76
# This workflow will run unit tests on pull requests or when manually activated
name: pytest
on:
push:
branches:
main
pull_request:
workflow_dispatch:
jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install
run: pip install .[test]
- name: Run tests
run: |
coverage run -m pytest --junitxml=reports/junit/junit.xml --html=reports/junit/report.html
## everything from here deals with generating and uploading reports and badges to a separate "badges" repo.
- name: Create reports and badges
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
coverage xml -o reports/coverage/coverage.xml
coverage html -d reports/coverage/
genbadge coverage -i reports/coverage/coverage.xml
genbadge tests -i reports/junit/junit.xml
- name: Make badge dir
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
mkdir -p badges
mv *badge.svg badges
- name: Setup assets dir
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
mkdir assets
mv badges assets/
mv reports assets/
- name: Clone badges repo
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/qupath/badges.git badges
## cba handling merging or dealing with stale resources
rm -rf badges/${{ github.event.repository.name }}
mkdir -p badges/${{ github.event.repository.name }}
mv assets/* badges/${{github.event.repository.name}}/
- name: Deploy badges to gh-pages
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
cd badges
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Update badges and reports"
git push