-
Notifications
You must be signed in to change notification settings - Fork 28
84 lines (66 loc) · 2.12 KB
/
pr_checks.yml
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
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
Pytest:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
env:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install Requirements
run: |
python -m pip install --upgrade pip
pip install -r api/requirements.test.txt
- name: Run Test Cases
run: |
export GIT_COMMIT_SHA=${{ github.event.pull_request.head.sha }}
export GIT_BRANCH=$GITHUB_HEAD_REF
cd api
source .env.test
export CC_TEST_REPORTER_ID=${{ secrets.CODE_CLIMATE_TEST_REPORTER_ID }}
echo "Downloading test_reporter"
curl https://s3.amazonaws.com/codeclimate/test-reporter/test-reporter-latest-linux-amd64 > test_reporter
chmod +x test_reporter
./test_reporter before-build
echo "Running pytest"
if coverage run -m pytest -q -x --tb=auto --cov=./ --cov-report=xml; then
if [ -e coverage.xml ]
then
echo " ---------------- Coverage.xml file found --------------------- "
else
echo " ---------------- Coverage.xml file not found --------------------"
fi
cd ../
cp api/coverage.xml coverage.xml
echo "Uploading report"
./api/test_reporter after-build --debug -r $CC_TEST_REPORTER_ID
echo "checking if github repo"
git status
echo "printing branch"
git rev-parse --abbrev-ref HEAD
else
echo "Test cases failed"
exit 1
fi