-
Notifications
You must be signed in to change notification settings - Fork 2
216 lines (210 loc) · 10 KB
/
test.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
name: OneFlow Serving
on:
pull_request:
types: [review_requested]
branches:
- "*"
release:
types:
- published
schedule:
- cron: "0 18 * * *"
workflow_dispatch:
inputs:
tag:
description: "Docker image tag"
required: true
type: string
env:
TRITON_VERSION: "21.10"
SERVING_IMAGE: "oneflow-serving"
MANYLINUX_CACHE_DIR: ~/manylinux-cache-dir/triton-cu114
REGION_ID: cn-beijing
REGISTRY: registry.cn-beijing.aliyuncs.com
NAMESPACE: oneflow
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
cancel_previous:
name: Cancel previous runs
runs-on: ubuntu-latest
if: github.event_name == 'release' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event.pull_request.draft == false && github.base_ref == 'main' && contains(github.event.pull_request.requested_reviewers.*.login, 'oneflow-ci-bot'))
steps:
- name: Cancel previous runs of outdated commit
if: github.ref != 'refs/heads/main'
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
build_test:
name: Build oneflow and backend
runs-on: [self-hosted, linux, provision]
needs: [cancel_previous]
if: github.event_name == 'release' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || (github.event.pull_request.draft == false && github.base_ref == 'main' && contains(github.event.pull_request.requested_reviewers.*.login, 'oneflow-ci-bot'))
outputs:
image_tag: ${{ steps.output-step.outputs.image_tag }}
acr_image_tag: ${{ steps.output-step.outputs.acr_image_tag }}
steps:
- name: Fix permissions
run: |
docker run --rm -v $PWD:/p -w /p busybox chmod -R o+w .
- uses: actions/checkout@v2
- name: Clone oneflow
run: |
git clone https://github.com/Oneflow-Inc/oneflow --depth=1 --branch for_serving_test
- name: Set environment variables
run: |
set -x
extra_docker_args=""
manylinux_cache_dir=${{ env.MANYLINUX_CACHE_DIR }}
container_name=serving-build-run-id-${{ github.run_id }}-${{ github.run_number }}-test
extra_docker_args+=" --runtime=nvidia"
extra_docker_args+=" --detach"
extra_docker_args+=" --name ${container_name}"
extra_docker_args+=" --shm-size=8g --rm -w $PWD -v $PWD:$PWD"
extra_docker_args+=" -v $manylinux_cache_dir:$manylinux_cache_dir"
extra_docker_args+=" --network=host"
extra_docker_args+=" -e HTTPS_PROXY -e HTTP_PROXY"
extra_docker_args+=" --env TRITON_VERSION=${{ env.TRITON_VERSION }}"
extra_docker_args+=" --env ONEFLOW_CI_SRC_DIR=$PWD/oneflow"
extra_docker_args+=" --env ONEFLOW_CI_BUILD_DIR=$manylinux_cache_dir/build"
extra_docker_args+=" --env ONEFLOW_CI_BUILD_SCRIPT=$PWD/ci/build/build-gcc7.sh"
extra_docker_args+=" --env WHEELHOUSE_DIR=$manylinux_cache_dir/wheelhouse"
extra_docker_args+=" --env ONEFLOW_CI_CMAKE_INIT_CACHE=$PWD/cmake/ci/oneflow-cuda.cmake"
extra_docker_args+=" --env ONEFLOW_CI_PYTHON_EXE=python3"
echo "extra_docker_args=${extra_docker_args}" >> $GITHUB_ENV
echo "container_name=${container_name}" >> $GITHUB_ENV
echo "image_tag=registry.cn-beijing.aliyuncs.com/oneflow/triton-devel:latest" >> $GITHUB_ENV
- name: Build oneflow and oneflow backend for triton
run: |
docker run --rm -v $PWD:/p -w /p busybox chmod -R o+w .
docker run --rm -v ${{ env.MANYLINUX_CACHE_DIR }}:/p -w /p busybox chmod -R o+w .
docker pull ${{ env.image_tag }}
docker container rm -f ${{ env.container_name }} || true
docker run $extra_docker_args ${{ env.image_tag }} sleep 3600
docker exec ${{ env.container_name }} python3 -m pip install -r ci/build/requirement.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
docker exec -w $PWD ${{ env.container_name }} /bin/bash ci/build/oneflow.sh
docker exec -w $PWD ${{ env.container_name }} /bin/bash ci/build/backend.sh
- name: Prepare for test
run: |
set -x
manylinux_cache_dir=${{ env.MANYLINUX_CACHE_DIR }}
docker exec -w $PWD/test/common ${{ env.container_name }} bash -c "source $manylinux_cache_dir/build/ci_source.sh && python3 export_model.py"
- name: Remove container
run: |
docker container rm -f ${{ env.container_name }}
- name: Set environment variables
run: |
set -x
extra_docker_args=""
container_name=user-image-run-id-${{ github.run_id }}-${{ github.run_number }}-test
extra_docker_args+=" --runtime=nvidia"
extra_docker_args+=" --detach"
extra_docker_args+=" --name ${container_name}"
extra_docker_args+=" --shm-size=8g --rm -w $PWD -v $PWD:$PWD"
echo "extra_docker_args=${extra_docker_args}" >> $GITHUB_ENV
echo "container_name=${container_name}" >> $GITHUB_ENV
echo "image_tag=${{ env.SERVING_IMAGE }}" >> $GITHUB_ENV
echo "triton_version=${{ env.TRITON_VERSION }}" >> $GITHUB_ENV
- name: Export docker image name
run: |
set -x
if [[ "${{ github.event_name }}" == "release" ]]
then
echo "image_tag=${{ env.SERVING_IMAGE }}:${{ github.ref_name }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]
then
echo "image_tag=${{ env.SERVING_IMAGE }}:${{ github.event.inputs.tag }}" >> $GITHUB_ENV
elif [[ "${{ github.event_name }}" == "schedule" ]]
then
echo "image_tag=${{ env.SERVING_IMAGE }}:nightly" >> $GITHUB_ENV
else
echo "image_tag=${{ env.SERVING_IMAGE }}:run-id-${{ github.run_id }}" >> $GITHUB_ENV
fi
- name: Export ACR docker image name
run: |
echo "acr_image_tag=${{ env.REGISTRY }}/${{ env.NAMESPACE }}/${{ env.image_tag }}" >> $GITHUB_ENV
- name: Make user docker image
run: |
echo ${{ env.image_tag }}
mkdir -p context
cp ci/build/oneflow_serving_triton_entrypoint.sh context/
cp ci/build/oneflow-serving.py context/oneflow-serving
cp -r ${{ env.MANYLINUX_CACHE_DIR }}/build/liboneflow_cpp/ context/
cp build/libtriton_oneflow.so context/
docker build -f docker/Dockerfile context/ --build-arg TRITON_CONTAINER_VERSION=${{ env.triton_version }} -t ${{ env.image_tag }}
- name: Test
run: |
docker container rm -f ${{ env.container_name }} || true
docker run $extra_docker_args ${{ env.image_tag }} sleep 3600
docker exec -w $(pwd) ${{ env.container_name }} pip3 install -r ./ci/test/requirement.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
docker exec -w $(pwd) ${{ env.container_name }} bash ./ci/test/run_tests.sh
# - name: Login to ACR with the AccessKey pair
# uses: aliyun/acr-login@v1
# with:
# login-server: https://registry.${{ env.REGION_ID }}.aliyuncs.com
# username: "${{ secrets.ACR_USERNAME }}"
# password: "${{ secrets.ACR_PASSWORD }}"
# - name: Docker push to ACR
# if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
# run: |
# docker tag ${{ env.image_tag }} ${{ env.acr_image_tag }}
# docker push ${{ env.acr_image_tag }}
- name: Remove container
run: docker container rm -f ${{ env.container_name }}
- name: Remove image
run: |
set -x
[ -z "${{ env.image_tag }}" ] && exit 0
if [[ "$(docker images -q ${{ env.image_tag }} 2> /dev/null)" != "" ]]; then
docker rmi ${{ env.image_tag }}
fi
[ -z "${{ env.acr_image_tag }}" ] && exit 0
if [[ "$(docker images -q ${{ env.acr_image_tag }} 2> /dev/null)" != "" ]]; then
docker rmi ${{ env.acr_image_tag }}
fi
- name: Output environment variables
id: output-step
run: |
echo "::set-output name=image_tag::${{ env.image_tag }}"
echo "::set-output name=acr_image_tag::${{ env.acr_image_tag }}"
# docker_push:
# name: Push to docker hub
# runs-on: ubuntu-latest
# needs: [build_test]
# if: github.event_name == 'release'|| github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'
# steps:
# - name: Set environment variables
# run: |
# echo "image_tag=oneflowinc/${{ needs.build_test.outputs.image_tag }}" >> $GITHUB_ENV
# echo "acr_image_tag=${{ needs.build_test.outputs.acr_image_tag }}" >> $GITHUB_ENV
# - name: Output environment variables
# run: |
# echo ${{ env.acr_image_tag }}
# echo ${{ env.image_tag }}
# - name: Login to ACR with the AccessKey pair
# uses: aliyun/acr-login@v1
# with:
# login-server: https://registry.${{ env.REGION_ID }}.aliyuncs.com
# username: "${{ secrets.ACR_USERNAME }}"
# password: "${{ secrets.ACR_PASSWORD }}"
# - name: Login to docker hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Pull, tag and push
# run: |
# docker pull ${{ env.acr_image_tag }}
# docker tag ${{ env.acr_image_tag }} ${{ env.image_tag }}
# docker push ${{ env.image_tag }}
# - name: Pull, tag and push
# run: |
# docker pull ${{ env.acr_image_tag }}
# docker tag ${{ env.acr_image_tag }} ${{ env.image_tag }}
# docker push ${{ env.image_tag }}
# - name: Push latest
# if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
# run: |
# docker tag ${{ env.acr_image_tag }} oneflowinc/${{ env.SERVING_IMAGE }}:latest
# docker push oneflowinc/${{ env.SERVING_IMAGE }}:latest