-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (46 loc) · 1.41 KB
/
python_ci.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
name: Recommendation Engine CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
- name: "Setup Python"
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: "Install Poetry"
run: |
pip install pkginfo virtualenv poetry
# - name: "Install poetry"
# run: |
# curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: |
poetry install --no-root --no-dev -vvv
- name: Poetry virtualenv configuration
run: |
poetry config virtualenvs.in-project true
- name: Run main.py
run: |
timeout 5s poetry run python main.py || true
- name: Run tests and coverage report
run: |
poetry run coverage run --data-file .coverage -m pytest -s
poetry run coverage json
- name: Set total coverage to COVERAGE_REPORT environment variable
run: |
export COVERAGE_REPORT=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered'])")
echo "##TOTAL COVERAGE: ${COVERAGE_REPORT}"
COVERAGE_RESULT=$(echo "$COVERAGE_REPORT < 60" | bc)
if [ "$COVERAGE_RESULT" -eq 1 ]; then
echo "Coverage less than 60%. Exiting..."
exit 1
fi