-
Notifications
You must be signed in to change notification settings - Fork 2.2k
248 lines (239 loc) · 9.8 KB
/
cd.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
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
name: CD
on:
push:
branches:
- master
#on:
# push:
# branches-ignore:
# - '**' # temporally ignore all
jobs:
update-doc:
if: |
!startsWith(github.event.head_commit.message, 'chore') &&
!startsWith(github.event.head_commit.message, 'build: hotfix') &&
!endsWith(github.event.head_commit.message, 'reformatted by jina-dev-bot')
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 100
- run: |
truncate --size=24KB README.md > README-trunc.md
- uses: peter-evans/dockerhub-description@v2.3.0
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_DEVBOT_USER }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_DEVBOT_PWD }}
DOCKERHUB_REPOSITORY: jinaai/jina
readme-filepath: ./README-trunc.md
- uses: actions/checkout@v2
with:
repository: jina-ai/api
path: schema
token: ${{ secrets.JINA_DEV_BOT }}
- uses: actions/setup-python@v1
with:
python-version: 3.7
- run: |
pip install .[daemon] --no-cache-dir
JINA_VERSION=$(sed -n '/^__version__/p' ./jina/__init__.py | cut -d \' -f2)-master
echo "JINA_VERSION=${JINA_VERSION}" >> $GITHUB_ENV
pip install css-html-js-minify
css-html-js-minify ./jina/resources/hub-builder-success
cp ./jina/resources/hub-builder-success/index.html ./schema/hub
cp ./jina/resources/hub-builder-success/script.min.js ./schema/hub
cp ./jina/resources/hub-builder-success/style.min.css ./schema/hub
cd schema
mkdir -p schemas
jina export-api --schema-path schemas/"$JINA_VERSION.json" schemas/master.json schemas/master --yaml-path "$JINA_VERSION.yml" master.yml --json-path "$JINA_VERSION.json" master.json master
python -c "from daemon import _write_openapi_schema; _write_openapi_schema()"
python ../scripts/get-gateway-openapi.py
cd -
- name: redoc-cli-jinad
uses: seeebiii/redoc-cli-github-action@v10
with:
args: 'bundle schema/daemon.json -o jinad.html'
- name: redoc-cli-gateway
uses: seeebiii/redoc-cli-github-action@v10
with:
args: 'bundle schema/gateway.json -o rest.html'
- name: push-to-api-repo
run: |
mkdir -p schema/daemon/
cp jinad.html schema/daemon/master.html
rm schema/daemon.json
rm -rf schema/jinad
mkdir -p schema/rest/
cp rest.html schema/rest/master.html
rm schema/gateway.json
cd schema
git config --local user.email "dev-bot@jina.ai"
git config --local user.name "Jina Dev Bot"
git add . && git commit -m "update ${{env.JINA_VERSION}} due to ${{github.event_name}} on ${{github.repository}}" && git push
- name: Pre-release
run: |
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
pip install twine wheel
./scripts/release.sh
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
JINA_SLACK_WEBHOOK: ${{ secrets.JINA_SLACK_WEBHOOK }}
# Tell docs repo jina is going to release
- name: send-repository-dispatch-event-to-docs
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.JINA_DEV_BOT }}
repository: jina-ai/docs
event-type: jina-merge-event
update-docker:
needs: update-doc
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
tag_stage: ["", "-devel", "-daemon"]
tag_pyversion: ["-py37", "-py38", "-py39"]
steps:
- uses: actions/checkout@v2
with:
submodules: true # this job build devel image, devel image includes hub submodule
- name: Set envs and versions
run: |
echo "VCS_REF=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
echo "JINA_VERSION=$(sed -n '/^__version__/p' ./jina/__init__.py | cut -d \' -f2)-master" >> $GITHUB_ENV
if [[ "${{ matrix.tag_pyversion }}" == "-py38" ]]; then
echo "PY_VERSION=3.8" >> $GITHUB_ENV
elif [[ "${{ matrix.tag_pyversion }}" == "-py39" ]]; then
echo "PY_VERSION=3.9" >> $GITHUB_ENV
else
echo "PY_VERSION=3.7" >> $GITHUB_ENV
echo "TAG_ALIAS=jinaai/jina:master${{ matrix.tag_stage }}" >> $GITHUB_ENV
fi
if [[ "${{ matrix.tag_stage }}" == "-daemon" ]]; then
echo "BUILD_ARG=jina_daemon" >> $GITHUB_ENV
elif [[ "${{ matrix.tag_stage }}" == "-devel" ]]; then
echo "BUILD_ARG=jina_devel" >> $GITHUB_ENV
else
echo "BUILD_ARG=jina_base" >> $GITHUB_ENV
fi
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_DEVBOT_USER }}
password: ${{ secrets.DOCKERHUB_DEVBOT_TOKEN }}
- run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfiles/debianx.Dockerfile
platforms: linux/armhf,linux/amd64,linux/arm/v6
push: true
tags: jinaai/jina:master${{ matrix.tag_pyversion }}${{ matrix.tag_stage }}, ${{env.TAG_ALIAS}}
build-args: BUILD_DATE, JINA_VERSION, VCS_REF, PY_VERSION
target: ${{env.BUILD_ARG}}
prep-testbed:
needs: update-doc
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
- run: |
echo "PIP_TAG='[devel]'" >> $GITHUB_ENV
- name: Upload to Github Docker Registry
uses: elgohr/Publish-Docker-Github-Action@3.02
with:
name: jina-ai/jina/jina
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
registry: docker.pkg.github.com
dockerfile: Dockerfiles/pip.Dockerfile
buildargs: PIP_TAG
buildoptions: ${{ matrix.build_option }}
tags: "test-pip"
- id: set-matrix
run: |
sudo apt-get install jq
echo "::set-output name=matrix::$(bash scripts/get-all-test-paths.sh tests)"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
core-test:
needs: prep-testbed
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: [3.7]
test-path: ${{fromJson(needs.prep-testbed.outputs.matrix)}}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Prepare enviroment
run: |
docker login docker.pkg.github.com -u $GITHUB_ACTOR -p $GITHUB_TOKEN
docker pull docker.pkg.github.com/jina-ai/jina/jina:test-pip
docker tag docker.pkg.github.com/jina-ai/jina/jina:test-pip jinaai/jina:test-pip
python -m pip install --upgrade pip
python -m pip install wheel
pip install ".[cicd,test,daemon]" --no-cache-dir
jina check
export JINA_LOG_LEVEL="ERROR"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test
id: test
run: |
if [[ "${{ matrix.test-path }}" == "tests/distributed/test_against_external_daemon/" ]]; then
docker build -f Dockerfiles/debianx.Dockerfile -t jinaai/jina:test-daemon .
docker run --name jinad -v /var/run/docker.sock:/var/run/docker.sock --network=host -d jinaai/jina:test-daemon
pytest --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml --timeout=300 -v -s --ignore-glob='tests/integration/hub_usage/dummyhub*' ${{ matrix.test-path }}
docker rm -f jinad
else
SUB='daemon'
if [[ "${{ matrix.test-path }}" == *"$SUB"* ]]; then
pytest --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=daemon --cov-report=xml --timeout=300 -v -s --ignore-glob='tests/integration/hub_usage/dummyhub*' ${{ matrix.test-path }}
else
pytest --suppress-no-test-exit-code --force-flaky --min-passes 1 --max-runs 5 --cov=jina --cov-report=xml --timeout=300 -v -s --ignore-glob='tests/integration/hub_usage/dummyhub*' ${{ matrix.test-path }}
fi
fi
SUB='daemon'
if [[ "${{ matrix.test-path }}" == *"$SUB"* ]]; then
echo "flag it as daemon for codeoverage"
echo "::set-output name=codecov_flag::daemon"
else
echo "flag it as jina for codeoverage"
echo "::set-output name=codecov_flag::jina"
fi
timeout-minutes: 15
env:
JINAHUB_USERNAME: ${{ secrets.JINAHUB_USERNAME }}
JINAHUB_PASSWORD: ${{ secrets.JINAHUB_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check file existence
id: check_files
uses: andstor/file-existence-action@v1
with:
files: "coverage.xml"
- name: Upload coverage from test to Codecov
uses: codecov/codecov-action@v1
if: steps.check_files.outputs.files_exists == 'true' && ${{ matrix.python-version }} == '3.7'
with:
file: coverage.xml
name: ${{ matrix.test-path }}-codecov
flags: ${{ steps.test.outputs.codecov_flag }}
fail_ci_if_error: false