forked from AdRoll/python-hll
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (50 loc) · 1.58 KB
/
test.yml
File metadata and controls
60 lines (50 loc) · 1.58 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
name: Run Tests and Update Coverage Badge
on:
push:
branches: [main]
tags:
- "[0-9]+.[0-9]+.[0-9]"
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
save-cache: true
- name: Run Pytest with Coverage
run: |
uv sync --locked --dev
uv run pytest --cov=src --cov-report=term --cov-report=xml
- name: Extract branch name
shell: bash
run: |
BRANCH=${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}
echo "BRANCH=$BRANCH" >> $GITHUB_ENV
echo "BADGE_SOURCE=/tmp/$BRANCH-coverage.svg" >> $GITHUB_ENV
echo "BADGE_DEST=badges/$BRANCH/coverage.svg" >> $GITHUB_ENV
- name: Generate badge
run: |
uv tool install genbadge
uv run genbadge coverage -i coverage.xml -o $BADGE_SOURCE
- uses: actions/checkout@v1
with:
ref: badges
path: badges
- name: Commit badge
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git checkout --
mkdir -p "badges/${BRANCH}"
cp "$BADGE_SOURCE" "$BADGE_DEST"
git add "$BADGE_DEST" && git commit -m "Add/Update badge" || true
- name: Push badge commit
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: badges
directory: badges