-
Notifications
You must be signed in to change notification settings - Fork 7
243 lines (236 loc) · 6.87 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
name: CI
on:
push:
branches: [master]
tags: [v*]
pull_request:
branches: [master]
pull_request_target:
branches: [master]
schedule:
- cron: 0 4 * * *
concurrency:
group: ci-${{ github.head_ref }}
cancel-in-progress: true
jobs:
lint:
name: Linter
runs-on: ubuntu-latest
# 5 mins for the linter run, possibly 10 min for pre-commit env reinitialization
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Cache pre-commit hooks
uses: actions/cache@v3
with:
path: ~/.cache/pre-commit
key: pre-commit|py3.9|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Cache PyPI
uses: actions/cache@v3
with:
key: pip-lint-${{ hashFiles('requirements/*.txt') }}
path: ~/.cache/pip
restore-keys: |
pip-lint-
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/ci.txt
- name: Run linters
run: |
make lint
env:
CI_LINT_RUN: 1
# https://github.com/neuro-inc/neuro-cli/issues/2904
#- name: Install spell checker
# run: |
# # sudo apt install libenchant-dev
# pip install -r requirements/doc.txt
#- name: Run docs spelling
# run: |
# make api-doc-spelling
unit:
name: Unit
needs: lint
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu, macos, windows]
cmd: [sdk, cli]
exclude:
- python-version: '3.9'
os: macos
- python-version: '3.9'
os: windows
- python-version: '3.10'
os: macos
- python-version: '3.10'
os: ubuntu
fail-fast: false
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/cache@v3
with:
key: pip-ci-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt')
}}
path: ${{ steps.pip-cache.outputs.dir }}
restore-keys: |
pip-ci-${{ runner.os }}-${{ matrix.python-version }}-
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/ci.txt
- name: Run unittests
env:
COLOR: yes
run: |
make .test-${{ matrix.cmd }} PYTEST_ARGS=-vvv
- name: Upload coverage artifact
uses: aio-libs/prepare-coverage@v22.1.2
if: matrix.os == 'ubuntu'
e2e:
name: E2E
needs: unit
if: |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') ||
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]')
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu, macos, windows]
exclude:
- python-version: '3.9'
os: macos
- python-version: '3.9'
os: windows
- python-version: '3.10'
os: macos
- python-version: '3.10'
os: ubuntu
fail-fast: false
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 90
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)" # - name: Cache
- name: Cache PyPI
uses: actions/cache@v3
with:
key: pip-ci-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('requirements/*.txt')
}}
path: ${{ steps.pip-cache.outputs.dir }}
restore-keys: |
pip-ci-${{ runner.os }}-${{ matrix.python-version }}-
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/ci.txt
- name: Run E2E tests
timeout-minutes: 75
env:
E2E_TOKEN: ${{ secrets.E2E_TOKEN }}
E2E_USER_TOKEN: ${{ secrets.E2E_USER_TOKEN }}
PYTEST_XDIST_NUM_THREADS: 16
COLOR: yes
run: |
make .e2e
- name: Upload coverage artifact
uses: neuro-inc/prepare-coverage@v22.1.2
if: matrix.os == 'ubuntu'
upload-cov:
name: Upload coverage
needs: [unit, e2e]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.sha }}
- name: Upload coverage
uses: aio-libs/upload-coverage@v22.1.4
deploy:
name: Deploy
# TODO y.s. 23.02.20: change back to e2e after tests fix
needs: unit
runs-on: ubuntu-latest
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install dependencies
run: |
make setup
python -m pip install twine build
- name: Make SDK dists
run: |
cd neuro-sdk
python -m build
- name: Make CLI dists
run: |
cd neuro-cli
python -m build
- name: PyPI upload SDK
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_SDK }}
TWINE_NON_INTERACTIVE: 1
run: |
twine upload neuro-sdk/dist/*
- name: PyPI upload CLI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN_CLI }}
TWINE_NON_INTERACTIVE: 1
run: |
twine upload neuro-cli/dist/*
- name: Merge dists for GitHub Release
run: |
mkdir dist
cp neuro-sdk/dist/* dist/
cp neuro-cli/dist/* dist/
- name: GitHub Release
uses: aio-libs/create-release@v1.6.6
with:
changes_file: CHANGELOG.md
name: Neuro SDK/CLI
github_token: ${{ secrets.GITHUB_TOKEN }}
pypi_token: ""
version_file: neuro-sdk/src/neuro_sdk/__init__.py # CLI has the same version
start_line: "[comment]: # (towncrier release notes start)"
head_line: "Neuro SDK/CLI {version}\\s+\\({date}\\)\n====+\n?"
fix_issue_regex: "\\(\\[#(\\d+)\\]\\(https://github.com/neuro-inc/platform-client-python/issues/\\\
1\\)\\)"
fix_issue_repl: "(#\\1)"