-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (100 loc) · 3.85 KB
/
dynamic_badges.yaml
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
name: Dynamic Badges
on:
push:
branches: [main]
jobs:
coverage-badge:
name: Update Coverage and Tests Passing Badge
runs-on: ubuntu-latest
steps:
- name: Check-out repository
uses: actions/checkout@v3
- name: Setup python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v3
with:
path: ~/.local
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
- name: Configure Poetry
run: poetry config virtualenvs.in-project true
- name: Load cached venv
id: cached-poetry-dependencies-2
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
if: steps.cached-poetry-dependencies-2.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --with dev
- name: Install project
run: poetry install --no-interaction --with dev
- name: Run Coverage
run: |
poetry run pytest --cov src/*
echo "COVERAGE=$(poetry run coverage report --format markdown --precision 1 | awk -F'|' 'END{gsub(/ *(\*\*|%)* */, "", $(NF-1)); print $(NF-1)}')" >> $GITHUB_ENV
- name: Create Coverage Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 1ab4eefed81ec381e29f7d4feb9856bc
filename: coverage.json
label: test coverage
message: ${{ env.COVERAGE }}%
valColorRange: ${{ env.COVERAGE }}
minColorRange: 0
maxColorRange: 100
- name: Run Tests
run: |
echo "COLLECTED=$(poetry run pytest --collect-only | grep -m 1 "collected" | awk '{print $2;}' | tr -d '[:space:]\n')" >> $GITHUB_ENV
echo "PASSED=$(poetry run pytest --verbose | grep -o "PASSED" | wc -l | tr -d '[:space:]\n')" >> $GITHUB_ENV
- name: Create Tests Passing Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 1ab4eefed81ec381e29f7d4feb9856bc
filename: tests.json
label: tests passing
message: ${{ env.PASSED }} / ${{ env.COLLECTED }}
valColorRange: ${{ env.PASSED }}
minColorRange: 0
maxColorRange: ${{ env.COLLECTED }}
update-badges:
name: Update CLOC Badges
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Download cloc
run: sudo apt-get update -y && sudo apt-get install -y cloc
- name: Get the Numbers
run: |
echo "CODE_LINES=$(.github/cloc.sh --loc)" >> $GITHUB_ENV
echo "COMMENT_PERCENTAGE=$(.github/cloc.sh --percentage)" >> $GITHUB_ENV
- name: Create Lines-of-Code Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 1ab4eefed81ec381e29f7d4feb9856bc
filename: loc.json
label: lines of code
message: ${{ env.CODE_LINES }}
color: blue
- name: Create Comments Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 1ab4eefed81ec381e29f7d4feb9856bc
filename: comments.json
label: comment percentage
message: ${{ env.COMMENT_PERCENTAGE }}%
valColorRange: ${{ env.COMMENT_PERCENTAGE }}
maxColorRange: 40
minColorRange: 0