-
Notifications
You must be signed in to change notification settings - Fork 1
269 lines (246 loc) · 9.64 KB
/
ci.yaml
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
name: "CI"
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: 0 14 * * *
jobs:
lint:
name: Linter
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Cache PyPI
uses: actions/cache@v4
with:
key: ${{ runner.os }}-py-3.9-${{ hashFiles('requirements/*.txt') }}
path: ${{ env.pythonLocation }}
- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-python-3.9-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
run: |
python -m pip install -U pip
make setup
- name: Run linters
run: |
make lint
pretest:
name: Prepare for tests
needs: [lint]
runs-on: ubuntu-latest
env:
PYTHONIOENCODING: utf-8
NEURO_STAGING_URL: ${{ secrets.NEURO_STAGING_URL }}
APOLO_TOKEN: ${{ secrets.NEURO_TOKEN }}
APOLO_CLUSTER: default
APOLO_PROJECT: e2e-tests
APOLO_EXTRAS_PRESET: cpu-small
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
steps:
- name: Checkout commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Cache Python and its deps
uses: actions/cache@v4
with:
key: ${{ runner.os }}-py-3.9-${{ hashFiles('requirements/base.txt') }}
path: ${{ env.pythonLocation }}
- name: Install and configure apolo
run: |
python -m pip install -r requirements/base.txt
apolo config login-with-token ${{ env.APOLO_TOKEN }} ${{ env.NEURO_STAGING_URL }}
apolo config switch-cluster ${{ env.APOLO_CLUSTER }}
apolo config switch-project ${{ env.APOLO_PROJECT }}
apolo --color=no config show
- name: Login to ghcr.io
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build test image
run: |
export REPO_URL=https://github.com/neuro-inc/neuro-extras.git
export PACKAGE="git+$REPO_URL@$SHA"
docker build -t ghcr.io/neuro-inc/apolo-extras:$SHA \
--build-arg APOLO_EXTRAS_PACKAGE=$PACKAGE .
- name: Push test image
run: |
docker push ghcr.io/neuro-inc/apolo-extras:$SHA
test:
name: Run tests
needs: [pretest]
strategy:
max-parallel: 2 # to avoid overloading the platform
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu, macos, windows]
exclude:
# not to overload the platform, we will remove this eventually
# see https://github.com/neuro-inc/neuro-extras/pull/249
- python-version: 3.10
os: macos
- python-version: 3.10
os: windows
- python-version: 3.11
os: macos
- python-version: 3.11
os: windows
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 90
env:
PYTHONIOENCODING: utf-8
steps:
- name: Checkout commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Authorize GCP
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.E2E_COOKIECUTTER_GCP_SA_KEY }}
- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v2
- name: Configure AWS access
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.E2E_COOKIECUTTER_AWS_KEY_ID }}
aws-secret-access-key: ${{ secrets.E2E_COOKIECUTTER_AWS_ACCESS_KEY }}
aws-region: us-east-1
- name: Install python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache Python and its deps
uses: actions/cache@v4
with:
key: ${{ runner.os }}-py-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'requirements/*.txt') }}
path: ${{ env.pythonLocation }}
- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-python-${{ matrix.python-version }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install libraries on Linux
if: (matrix.os == 'ubuntu') || (matrix.os == 'macos')
shell: bash
run: |
curl https://rclone.org/install.sh | sudo bash
- name: Install python dependencies
run: |
make setup
- name: Configure environment
env:
NEURO_STAGING_URL: ${{ secrets.NEURO_STAGING_URL }}
APOLO_TOKEN: ${{ secrets.NEURO_TOKEN }}
APOLO_CLUSTER: default
APOLO_PROJECT: e2e-tests
APOLO_EXTRAS_PRESET: cpu-small
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }}
run: |
apolo config login-with-token ${{ env.APOLO_TOKEN }} ${{ env.NEURO_STAGING_URL }}
apolo config switch-cluster ${{ env.APOLO_CLUSTER }}
apolo config switch-project ${{ env.APOLO_PROJECT }}
apolo --color=no config show
- name: Read PR labels
uses: joerick/[email protected]
id: pr_labels
- name: Run all tests
if: |
github.ref_type == 'branch' && github.ref_name == 'master'
env:
COLOR: "yes"
DOCKER_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }}
DOCKER_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }}
APOLO_CLUSTER: default
#APOLO_CLUSTER_SECONDARY: cato-poc # TODO: uncomment when cato-poc cluster is fixed
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }}
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
# Note: see tests/e2e/conftest.py:get_tested_archive_types()
PYTEST_DATA_COPY_ARCHIVE_TYPES: ".tar.gz"
PYTEST_PARALLEL: 6
shell: bash
run: |
export APOLO_EXTRAS_IMAGE=ghcr.io/neuro-inc/apolo-extras:$SHA
make test
- name: Run smoke tests
if: |
!(github.ref_type == 'branch' && github.ref_name == 'master')
env:
COLOR: "yes"
DOCKER_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }}
DOCKER_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }}
APOLO_CLUSTER: default
APOLO_EXTRAS_PRESET: cpu-small
#APOLO_CLUSTER_SECONDARY: cato-poc # TODO: uncomment when cato-poc cluster is fixed
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }}
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
# Note: see tests/e2e/conftest.py:get_tested_archive_types()
PYTEST_DATA_COPY_ARCHIVE_TYPES: ".tar.gz"
PYTEST_PARALLEL: 6
shell: bash
run: |
export APOLO_EXTRAS_IMAGE=ghcr.io/neuro-inc/apolo-extras:$SHA
make test_smoke
- name: Run data tests
if: |
!(github.ref_type == 'branch' && github.ref_name == 'master') &&
contains(steps.pr_labels.outputs.labels, ' e2e-data ')
env:
COLOR: "yes"
DOCKER_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }}
DOCKER_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }}
APOLO_CLUSTER: default
#APOLO_CLUSTER_SECONDARY: cato-poc # TODO: uncomment when cato-poc cluster is fixed
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }}
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
# Note: see tests/e2e/conftest.py:get_tested_archive_types()
PYTEST_DATA_COPY_ARCHIVE_TYPES: ".tar.gz"
PYTEST_PARALLEL: 6
shell: bash
run: |
export APOLO_EXTRAS_IMAGE=ghcr.io/neuro-inc/apolo-extras:$SHA
make test_data
- name: Run image tests
if: |
!(github.ref_type == 'branch' && github.ref_name == 'master') &&
contains(steps.pr_labels.outputs.labels, ' e2e-image ')
env:
COLOR: "yes"
DOCKER_CI_USERNAME: ${{ secrets.DOCKERHUB_CI_USERNAME }}
DOCKER_CI_TOKEN: ${{ secrets.DOCKERHUB_CI_TOKEN }}
APOLO_CLUSTER: default
APOLO_EXTRAS_PRESET: cpu-small
#APOLO_CLUSTER_SECONDARY: cato-poc # TODO: uncomment when cato-poc cluster is fixed
AZURE_SAS_TOKEN: ${{ secrets.AZURE_SAS_TOKEN }}
# Note: ${{ github.sha }} not working, see https://github.com/actions/checkout/issues/299
SHA: ${{ github.event.pull_request.head.sha || github.sha }}
# Note: see tests/e2e/conftest.py:get_tested_archive_types()
PYTEST_DATA_COPY_ARCHIVE_TYPES: ".tar.gz"
PYTEST_PARALLEL: auto
shell: bash
run: |
export APOLO_EXTRAS_IMAGE=ghcr.io/neuro-inc/apolo-extras:$SHA
make test_image