-
Notifications
You must be signed in to change notification settings - Fork 132
92 lines (79 loc) · 2.7 KB
/
testcoverage.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
---
name: Generate PyTest Coverage Badge
on:
pull_request:
types:
- closed
push:
branches: [main]
# Run at 4am everyday (see https://crontab.guru)
schedule:
- cron: "0 4 * * *"
env:
PYTHON_VERSION: 3.8.0
SECONDS: 120
jobs:
coverage_if_merged:
if: github.event.pull_request.merged == true || github.event.pull_request == false
runs-on: ubuntu-latest
steps:
- name: Install OS dependencies
run: |
sudo apt update
sudo apt install -y expect \
python3-opengl \
xvfb
echo 'export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python' >> "${HOME}/.bashrc"
- name: Setup Anaconda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: counterfit
auto-update-conda: true
python-version: ${{ env.PYTHON_VERSION }}
- name: Setup Conda Environment
run: |
echo 'conda activate "counterfit"' >> "${HOME}/.profile"
- name: Checkout Counterfit repository
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Populate installation acceptance test
run: |
cp "${GITHUB_WORKSPACE}/.github/helpers/quality-gates/install_test.exp" ./install_test.exp
- name: Setup Counterfit
shell: bash -l {0}
run: |
source "${HOME}/.profile"
cd "${GITHUB_WORKSPACE}/"
pip install --no-input .[dev]
python -c "import nltk; nltk.download('stopwords')"
- name: Test Counterfit installation
shell: bash -l {0}
run: |
source "${HOME}/.profile"
expect -d ./install_test.exp Linux ${{ env.SECONDS }} "${GITHUB_WORKSPACE}/examples/terminal/terminal.py"
- name: Generate coverage report
run: |
source "${HOME}/.profile"
cd "${GITHUB_WORKSPACE}/"
coverage run -m pytest
coverage json
- name: Get Coverage Percentage
id: coverage_percent
uses: notiz-dev/github-action-json-property@release
with:
path: 'coverage.json'
prop_path: 'totals.percent_covered_display'
- run: echo ${{ steps.coverage_percent.outputs.prop }}
- name: Create Coverage Badge
uses: schneegans/dynamic-badges-action@v1.6.0
with:
auth: ${{ secrets.COUNTERFITGISTTOKEN }}
gistID: 45c1f54d01942c69453aac7f60401dc4
filename: counterfit_test_coverage_badge.json
label: Coverage
message: ${{ steps.coverage_percent.outputs.prop }}%
valColorRange: ${{ steps.coverage_percent.outputs.prop }}
maxColorRange: 100
minColorRange: 0