-
-
Notifications
You must be signed in to change notification settings - Fork 17
166 lines (136 loc) · 4.71 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
# Run Python unit tests in continuous integration mode.
name: Continuous Integration
on:
pull_request:
push:
branches:
- main
jobs:
python-tests:
runs-on: ubuntu-20.04
services:
# Unit test rely on a local MySQL instance with an empty root password.
mysql:
image: mariadb:10.4
env:
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: yes
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
redis:
# Some unit tests also try to write to Redis
image: redis
ports:
- 6379:6379
options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v4
# Don't need lfs because we're not referencing the dev-db in this workflow.
- name: Set up Python 3.12.0
uses: actions/setup-python@v5
with:
python-version: '3.12.0'
- name: Install dependencies
run: |
pip install --upgrade pip
pip install pipenv
pipenv install --system --deploy --ignore-pipfile --dev
- name: Verify MySQL connection from host
run: |
mysql --host 127.0.0.1 --port 3306 -uroot -e "SHOW DATABASES"
- name: Create test databases
run: |
mysql --host 127.0.0.1 --port 3306 -uroot -e 'CREATE DATABASE enwp10_test; CREATE DATABASE enwikip_test;'
- name: Copy credentials
run: |
cp wp1/credentials.py.e2e wp1/credentials.py
cp wp1/credentials.py.dev.e2e wp1/credentials.py.dev
- name: Test with pytest, with coverage
run: |
pipenv run pytest --cov=wp1
- name: Upload to Codecov
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: true
frontend-cypress:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
with:
lfs: true
- name: Set up Python 3.12.0
uses: actions/setup-python@v5
with:
python-version: '3.12.0'
- uses: actions/cache@v4
name: Cache pip dependencies
id: pip-cache
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
run: |
pip install --upgrade pip
pip install pipenv
pipenv install --system --deploy --dev
- name: Get yarn cache directory path
id: yarn-dep-cache-dir-path
run: cd wp1-frontend && echo "YARN_CACHE_DIR=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
name: Setup Yarn dep cache
id: yarn-dep-cache
with:
path: ${{ steps.yarn-dep-cache-dir-path.outputs.YARN_CACHE_DIR }}
key: ${{ runner.os }}-yarn-dep-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-dep-
- name: Install Javascript dependencies
run: cd wp1-frontend && yarn install --frozen-lockfile
- name: Copy credentials
run: |
cp wp1/credentials.py.e2e wp1/credentials.py
cp wp1/credentials.py.dev.e2e wp1/credentials.py.dev
# This is the dev database, the dev redis, and the dev workers.
# We don't technically need the last one.
- name: Start Docker dev services
run: docker compose -f docker-compose-dev.yml up -d --build
- name: Wait for Docker dev services to be up (30s)
run: sleep 30s
shell: bash
- name: Start web API server
timeout-minutes: 2
env:
FLASK_APP: wp1.web.app
FLASK_DEBUG: 1
run: pipenv run gunicorn -b 0.0.0.0:5000 'wp1.web.app:create_app()' --log-file=output.log -D
- name: Build frontend server
run: |
cd wp1-frontend
yarn build --mode staging
- name: Start frontend server
run: |
cd wp1-frontend
pipenv run python -m http.server 5173 --directory dist/ &
- name: Wait for API and frontend server to be up (10s)
run: sleep 10s
shell: bash
- name: Run frontend tests
run: |
cd wp1-frontend
$(yarn bin)/cypress run
- name: Stop containers
continue-on-error: true
if: always()
run: docker compose -f "docker-compose-dev.yml" down
- uses: actions/upload-artifact@v4
continue-on-error: true
if: always()
with:
name: screenshots
path: |
wp1-frontend/cypress/screenshots/*
output.log