-
Notifications
You must be signed in to change notification settings - Fork 91
291 lines (290 loc) · 11.5 KB
/
ci.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# WARNING: Do not edit this file manually! Edit ci/spec.yml and run ci/regen-workflow.py.
{
"name": "CI",
"on": [
"push",
"pull_request"
],
"defaults": {
"run": {
"shell": "bash"
}
},
"env": {
"PRODUCTION": "TRUE"
},
"jobs": {
"linting": {
"runs-on": "ubuntu-latest",
"strategy": {
"matrix": {
"python-version": [
3.8
]
},
"fail-fast": false
},
"steps": [
{
"name": "Set up repo",
"uses": "actions/checkout@v2"
},
{
"name": "Set up Python ${{ matrix.python-version }}",
"uses": "actions/setup-python@v2",
"with": {
"python-version": "${{ matrix.python-version }}"
}
},
{
"name": "Set up pip cache",
"uses": "actions/cache@v2",
"with": {
"path": "~/.cache/pip",
"key": "pip-${{ matrix.python-version }}"
}
},
{
"name": "Set up packages",
"run": "set -e\n\npip install -U pip setuptools wheel\npip install -U \\\n pre-commit coveralls pyyaml pytest-django\npip install -U -r requirements.txt\n\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
},
{
"name": "Copy secret.py",
"run": "cp intranet/settings/ci_secret.py intranet/settings/secret.py"
},
{
"name": "Run pre-commit",
"run": "pre-commit run --all-files"
}
]
},
"build": {
"runs-on": "ubuntu-latest",
"strategy": {
"matrix": {
"python-version": [
3.8
]
},
"fail-fast": false
},
"steps": [
{
"name": "Set up repo (fetching all commits)",
"uses": "actions/checkout@v2",
"with": {
"fetch-depth": 0
}
},
{
"name": "Set up Python ${{ matrix.python-version }}",
"uses": "actions/setup-python@v2",
"with": {
"python-version": "${{ matrix.python-version }}"
}
},
{
"name": "Set up pip cache",
"uses": "actions/cache@v2",
"with": {
"path": "~/.cache/pip",
"key": "pip-${{ matrix.python-version }}"
}
},
{
"name": "Set up packages",
"run": "set -e\n\npip install -U pip setuptools wheel\npip install -U \\\n pre-commit coveralls pyyaml pytest-django\npip install -U -r requirements.txt\n\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
},
{
"name": "Copy secret.py",
"run": "cp intranet/settings/ci_secret.py intranet/settings/secret.py"
},
{
"name": "Regenerate workflow YAML file and check for changes",
"run": "./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py"
},
{
"name": "Check for changes to CI spec",
"run": "./scripts/build_ensure_no_changes.sh ./ci/regen-workflow.py"
},
{
"name": "Validate PR commit messages",
"if": "github.event_name == 'pull_request'",
"run": "./scripts/validate-commit-messages.py ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}"
},
{
"name": "Validate push commit messages",
"if": "github.event_name == 'push' && (github.repository_owner != 'tjcsl' || github.ref != 'refs/heads/master' || github.ref != 'refs/heads/dev')",
"run": "git fetch origin ${{ github.event.before }} && ./scripts/validate-commit-messages.py ${{ github.event.before }}..${{ github.event.after }}"
},
{
"name": "Build docs",
"run": "./scripts/build_ensure_no_changes.sh ./scripts/build_docs.sh"
},
{
"name": "Push docs",
"if": "github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository_owner == 'tjcsl' && matrix.python-version == 3.8",
"run": "./scripts/push_docs.sh",
"env": {
"GH_TOKEN": "${{ secrets.DOCS_GH_TOKEN }}"
}
}
]
},
"tests": {
"runs-on": "ubuntu-latest",
"strategy": {
"matrix": {
"python-version": [
3.8
],
"node-version": [
"14.x"
]
},
"fail-fast": false
},
"services": {
"rabbitmq": {
"image": "rabbitmq:latest",
"ports": [
"5672:5672"
],
"options": "--health-cmd \"rabbitmqctl node_health_check\" --health-interval 6s --health-timeout 5s --health-retries 10"
},
"redis": {
"image": "redis:latest",
"ports": [
"6379:6379"
],
"options": "--entrypoint redis-server"
},
"postgres": {
"image": "postgres:latest",
"env": {
"POSTGRES_USER": "postgres",
"POSTGRES_PASSWORD": "postgres",
"POSTGRES_DB": "postgres"
},
"ports": [
"5432:5432"
],
"options": "--health-cmd pg_isready --health-interval 6s --health-timeout 5s --health-retries 9"
}
},
"steps": [
{
"name": "Set up repo",
"uses": "actions/checkout@v2"
},
{
"name": "Set up Python ${{ matrix.python-version }}",
"uses": "actions/setup-python@v2",
"with": {
"python-version": "${{ matrix.python-version }}"
}
},
{
"name": "Set up pip cache",
"uses": "actions/cache@v2",
"with": {
"path": "~/.cache/pip",
"key": "pip-${{ matrix.python-version }}"
}
},
{
"name": "Set up packages",
"run": "set -e\n\npip install -U pip setuptools wheel\npip install -U \\\n pre-commit coveralls pyyaml pytest-django\npip install -U -r requirements.txt\n\necho \"PATH=$PATH\" >> $GITHUB_ENV\n"
},
{
"name": "Copy secret.py",
"run": "cp intranet/settings/ci_secret.py intranet/settings/secret.py"
},
{
"name": "Set up Node.js ${{ matrix.node-version }}",
"uses": "actions/setup-node@v1",
"with": {
"node-version": "${{ matrix.node-version }}"
}
},
{
"name": "Install Sass and add Node modules bin to PATH",
"run": "set -e\nnpm install sass\necho \"PATH=${{ github.workspace }}/node_modules/.bin:$PATH\" >> $GITHUB_ENV\n"
},
{
"name": "Set and create PGPASSFILE",
"run": "set -e\nPGPASSFILE=${{ runner.temp }}/.pgpass\necho \"PGPASSFILE=$PGPASSFILE\" >> $GITHUB_ENV\necho 127.0.0.1:5432:postgres:postgres:postgres >$PGPASSFILE\nchmod 600 $PGPASSFILE\n"
},
{
"name": "Create database",
"run": "psql -U postgres -h 127.0.0.1 -c 'create database ion'"
},
{
"name": "install Kerberos",
"run": "sudo apt update\nsudo apt install -y krb5-user\n"
},
{
"name": "Run tests (Fork)",
"if": "github.repository_owner != 'tjcsl'",
"run": "coverage run -a ./manage.py test --noinput --parallel 4"
},
{
"name": "Run tests (PR/Push)",
"if": "github.repository_owner == 'tjcsl'",
"run": "coverage run -a ./manage.py test --noinput"
},
{
"name": "Check for unmigrated changes",
"run": "coverage run -a ./manage.py makemigrations --noinput --check"
},
{
"name": "Migrate database",
"run": "coverage run -a ./manage.py migrate"
},
{
"name": "Collect static files",
"run": "coverage run -a ./manage.py collectstatic --noinput -v 0"
},
{
"name": "Report coverage to Coveralls",
"uses": "AndreMiras/coveralls-python-action@develop",
"with": {
"parallel": true
}
},
{
"name": "Build coverage XML file",
"if": "github.repository_owner == 'tjcsl' && github.event_name != 'pull_request'",
"run": "coverage xml"
},
{
"name": "Report coverage to Codacy",
"uses": "codacy/codacy-coverage-reporter-action@master",
"if": "github.repository_owner == 'tjcsl' && github.event_name != 'pull_request'",
"with": {
"coverage-reports": "coverage.xml",
"project-token": "${{ secrets.CODACY_PROJECT_TOKEN }}"
}
}
]
},
"finish_success": {
"needs": [
"linting",
"build",
"tests"
],
"runs-on": "ubuntu-latest",
"steps": [
{
"name": "Tell Coveralls that parallel jobs have finished",
"uses": "coverallsapp/github-action@master",
"with": {
"github-token": "${{ secrets.GITHUB_TOKEN }}",
"parallel-finished": true
}
}
]
}
}
}