-
Notifications
You must be signed in to change notification settings - Fork 16
199 lines (190 loc) · 5.74 KB
/
main.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
name: ci-checks
# run on all pull requests and on select branch pushes
on:
pull_request:
push:
branches:
- main
- next
jobs:
backend:
name: backend
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:12-alpine
env:
POSTGRES_USER: hawc
POSTGRES_PASSWORD: password
POSTGRES_DB: hawc
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
redis:
image: redis:6-alpine
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.11'
architecture: 'x64'
- name: try to restore pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: install
run: |
mv tests/data/ci-webpack-stats.json hawc/webpack-stats.json
pip install -U pip wheel
pip install -r requirements/dev.txt
- name: lint
run: |
make lint-py
- name: Setup linux environment
if: startsWith(runner.os, 'Linux')
run: |
sudo apt-get update -y
sudo apt-get install -y make libgslcblas0 libgsl-dev
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib"
sudo cp vendor/libnlopt.so /usr/local/lib/libnlopt.so.0
sudo ln -s /lib/x86_64-linux-gnu/libgsl.so /usr/local/lib/libgsl.so.25
export SITE_PKG=`python -c "import sysconfig; print(sysconfig.get_path('purelib'))"`
export "BMD_DLL=$SITE_PKG/bmds/bin/BMDS330/libDRBMD.so"
echo $BMD_DLL
ldd $BMD_DLL
- name: test
env:
DJANGO_DB_NAME: hawc
DJANGO_DB_USER: hawc
DJANGO_DB_PW: password
DJANGO_DB_HOST: localhost
DJANGO_CACHE_LOCATION: redis://localhost:6379/0
PUBMED_API_KEY: ${{ secrets.PUBMED_API_KEY }}
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
export "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib"
fi
coverage run -m pytest --vcr-record=none
coverage html -d coverage_report
echo "# Python coverage report" >> $GITHUB_STEP_SUMMARY
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
- name: loc
run: |
sudo apt-get install -y cloc
echo "# Lines of code report" >> $GITHUB_STEP_SUMMARY
make loc >> $GITHUB_STEP_SUMMARY
- name: upload-coverage-report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage_report
frontend:
name: frontend
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: try to restore yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('frontend/package.json') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: install
run: |
yarn --cwd ./frontend install
- name: lint
run: |
make lint-js
- name: test
run: |
npm --prefix ./frontend run test
- name: build for integration tests
run: |
npm --prefix ./frontend run build
- name: Upload webpack build
uses: actions/upload-artifact@v3
with:
name: webpack-build
path: |
hawc/webpack-stats.json
hawc/static/bundles/
integration:
name: integration
needs: [backend, frontend]
runs-on: ubuntu-22.04
services:
postgres:
image: postgres:12-alpine
env:
POSTGRES_USER: hawc
POSTGRES_PASSWORD: password
POSTGRES_DB: hawc
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports:
- 5432:5432
env:
DJANGO_DB_HOST: localhost
DJANGO_DB_NAME: hawc
DJANGO_DB_PW: password
DJANGO_DB_USER: hawc
INTEGRATION_TESTS: 1
LIVESERVER_HOST: localhost
LIVESERVER_PORT: 8000
PUBMED_API_KEY: ${{ secrets.PUBMED_API_KEY }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.11'
architecture: 'x64'
- name: try to restore pip cache
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/*.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Download webpack build
uses: actions/download-artifact@v3
with:
name: webpack-build
path: hawc
- name: install hawc
run: |
pip install -U pip
pip install -r requirements/dev.txt
playwright install --with-deps chromium
# https://github.community/t/how-to-retry-a-failed-step-in-github-actions-workflow/125880
- name: run integration tests
id: test
continue-on-error: true
run: |
py.test -sv tests/integration/
- name: run integration tests (retry)
if: steps.test.outcome=='failure'
id: retry
continue-on-error: true
run: |
py.test -sv --lf tests/integration/
- name: set status
if: always()
run: |
if ${{ steps.test.outcome=='success' || steps.retry.outcome=='success' }}; then
echo success!
else
exit 1
fi