-
Notifications
You must be signed in to change notification settings - Fork 0
/
tnd.yml
134 lines (129 loc) · 3.96 KB
/
tnd.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Test and Deploy
on:
push:
branches-ignore:
- template
pull_request:
branches-ignore:
- template
jobs:
UnitTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ github.job }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-
- name: Install dependencies
run: pip install -r requirements.txt
- name: Collect static files
run: python manage.py collectstatic --no-input
- name: Run unit tests
run: |
coverage run --parallel --include="./*" --omit="manage.py,project_name/*" \
manage.py test --exclude-tag=functional
- name: Upload unit test coverage
uses: actions/upload-artifact@v2
with:
name: unittest-coverage
path: .coverage*
FunctionalTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ github.job }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-
- name: Install ChromiumDriver
run: sudo apt-get update -q && sudo apt-get install -yq chromium-driver
- name: Install dependencies
run: pip install -r requirements.txt
- name: Collect static files
run: python manage.py collectstatic --no-input
- name: Run functional tests
run: |
coverage run --parallel --include="./*" --omit="manage.py,project_name/*" \
manage.py test --tag=functional
- name: Upload functional test coverage
uses: actions/upload-artifact@v2
with:
name: functionaltest-coverage
path: .coverage*
Coverage:
runs-on: ubuntu-latest
needs: [UnitTest, FunctionalTest]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: pip-${{ github.job }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-
- name: Install coverage
run: pip install coverage
- name: Download unit test coverage
uses: actions/download-artifact@v2
with:
name: unittest-coverage
- name: Download functional test coverage
uses: actions/download-artifact@v2
with:
name: functionaltest-coverage
- name: Combine unit test and functional test coverage
run: coverage combine
- name: Show coverage report
run: coverage report -m
- name: Generate coverage report to HTML
run: coverage html
- name: Upload overall test coverage
uses: actions/upload-artifact@v2
with:
name: coverage
path: htmlcov/
Deployment:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
needs: [UnitTest, FunctionalTest]
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
HEROKU_APP_NAME: ${{ secrets.HEROKU_APP_NAME }}
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
uses: actions/setup-ruby@v1
with:
ruby-version: 2.7
- name: Install dpl
run: gem install dpl
- name: Install Heroku CLI
run: wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
- name: Deploy to Heroku
run: dpl --provider=heroku --app=$HEROKU_APP_NAME --api-key=$HEROKU_API_KEY
- name: Run migrations on Heroku
run: heroku run --app $HEROKU_APP_NAME migrate
- uses: chrnorm/deployment-action@releases/v1
name: Create GitHub deployment
with:
initial_status: success
token: ${{ github.token }}
target_url: https://${{ secrets.HEROKU_APP_NAME }}.herokuapp.com
environment: production