-
Notifications
You must be signed in to change notification settings - Fork 2
242 lines (236 loc) · 7.44 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
name: CI
on:
push:
branches: [master]
tags: [v*]
pull_request:
branches: [master]
pull_request_target:
branches: [master]
schedule:
- cron: 0 15 * * *
jobs:
lint:
name: Linter
runs-on: ubuntu-latest
if: |
(github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') ||
(github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]')
timeout-minutes: 5
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Cache pre-commit hooks
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|py3.9|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Cache PyPI
uses: actions/cache@v4
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
- name: Save the package version
id: version
run: |
echo "version=$(python setup.py --version)" >> $GITHUB_OUTPUT
- name: Show version
run: |
echo ${{ steps.version.outputs.version }}
unit:
name: Unit
needs: [lint]
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.10"
os: windows
fail-fast: false
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 10
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache PyPI
uses: actions/cache@v4
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: Authorize ssh agent
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.MLOPS_TEST_ACTION_SSH_KEY }}
- name: Run unittests
env:
E2E_USER_TOKEN: ${{ secrets.CLIENT_TEST_E2E_USER_NAME }}
E2E_API_ENDPOINT: https://dev.neu.ro/api/v1
E2E_CLUSTER: default
COLOR: yes
run: |
make test
e2e:
name: E2E
needs: [unit]
continue-on-error: true
strategy:
max-parallel: 2
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.10"
os: windows
fail-fast: false
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 20
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache
run: |
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
- name: Cache PyPI
uses: actions/cache@v4
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
env:
E2E_USER_TOKEN: ${{ secrets.CLIENT_TEST_E2E_USER_NAME }}
E2E_API_ENDPOINT: https://dev.neu.ro/api/v1
E2E_CLUSTER: default
COLOR: yes
run: |
make test-e2e
check: # This job does nothing and is only used for the branch protection
name: Check
needs: [lint, unit, e2e]
runs-on: ubuntu-latest
steps:
- name: Check
run: |
echo "All checks have passed"
deploy:
name: Deploy on PyPI
needs: [lint, check]
runs-on: ubuntu-latest
# Run only on pushing a tag
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
steps:
- name: Sanity check for tag and version
run: |
if [ "refs/tags/v${{ needs.lint.outputs.version }}" != "${{ github.ref }}" ]
then
echo "Tag ${{ github.ref }} mismatches with ${{ needs.lint.outputs.version }}"
exit 1
else
echo "Tag matches version ${{ needs.lint.outputs.version }}"
fi
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
uses: py-actions/py-dependency-install@v4
with:
path: requirements/ci.txt
- name: Login to DockerHub
uses: docker/login-action@v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Make dists
run: |
python setup.py sdist bdist_wheel
- name: Build Docker Image
run: |
docker build -t "ghcr.io/neuro-inc/apolo-flow:${VERSION}" \
--build-arg APOLO_FLOW_DIST="$( find dist -name '*.whl' )" \
.
env:
VERSION: ${{ needs.lint.outputs.version }}
- name: Push Docker Image
run: |
docker push ghcr.io/neuro-inc/apolo-flow:${{ needs.lint.outputs.version }}
- name: GitHub Release
uses: aio-libs/create-release@v1.6.6
with:
changes_file: CHANGELOG.md
name: Apolo Flow
github_token: ${{ secrets.GITHUB_TOKEN }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
version_file: src/apolo_flow/__init__.py # CLI has the same version
start_line: "[comment]: # (towncrier release notes start)"
head_line: "# Apolo Flow {version}\\s+\\({date}\\)\n?"
fix_issue_regex:
"\\(\\[#(\\d+)\\]\\(https://github.com/neuro-inc/neuro-flow/issues/\\\
1\\)\\)"
fix_issue_repl: "(#\\1)"
- name: Make publish neuro dist
# publishing neuro-flow for backward compatibility
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_NEURO_TOKEN }}
run: |
rm -r dist build
python -m pip install twine
sed -i 's/name = apolo-flow/name = neuro-flow/g' setup.cfg
python setup.py sdist bdist_wheel
twine upload dist/*