generated from iai-group/template-project
-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (50 loc) · 1.55 KB
/
merge.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
name: Deploy
on:
push:
branches:
- main
jobs:
build-and-test:
name: "Build and Test Python 3.9"
runs-on: ubuntu-latest
if: always()
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Setup python
uses: actions/setup-python@v4
with:
python-version: "3.9"
cache: "pip"
- name: Install Dependencies
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install pytest-github-actions-annotate-failures
- name: PyTest with code coverage
continue-on-error: true
run: |
pytest --cov=. --cov-report=term-missing --cov-report=xml --cov-branch
- name: Get the Coverage
shell: bash
run: |
regex='<coverage.+line-rate="([0-9).[0-9]+)".+>'
line=$(grep -oP $regex coverage.xml)
[[ $line =~ $regex ]]
coverage=$( bc <<< ${BASH_REMATCH[1]}*100 )
if (( $(echo "$coverage > 90" |bc -l) )); then
COLOR=green
else
COLOR=red
fi
echo "COVERAGE=${coverage%.*}%" >> $GITHUB_ENV
echo "COLOR=$COLOR" >> $GITHUB_ENV
- name: Create the Badge
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 8446f35dc373966dc971fb9237483cce
filename: coverage.${{ github.event.repository.name }}.main.json
label: coverage
message: ${{ env.COVERAGE }}
color: ${{ env.COLOR }}