-
Notifications
You must be signed in to change notification settings - Fork 206
89 lines (76 loc) · 2.83 KB
/
test-engine-container.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
name: Test Docker Release Build
on:
workflow_call:
inputs:
version:
type: string
required: true
repo_url:
type: string
required: false
workflow_dispatch:
inputs:
version:
type: string
description: "テストしたいタグ名"
required: true
env:
IMAGE_NAME: ${{ vars.DOCKERHUB_USERNAME }}/voicevox_engine
VERSION: |- # version指定時はversionを、それ以外はタグ名を使用
${{ (github.event.inputs || inputs).version }}
defaults:
run:
shell: bash
jobs:
test:
runs-on: [ ubuntu-20.04 ]
strategy:
fail-fast: false
matrix:
tag:
- ""
- cpu
- cpu-ubuntu20.04
- cpu-ubuntu22.04
steps:
- name: <Setup> Check out the repository
uses: actions/checkout@v4
- name: <Setup> Prepare Python Runtime / Python Dependencies
uses: ./.github/actions/prepare_python
with:
requirements-suffix: "-dev"
- name: <Setup> Declare variables
id: docker_vars
run: |
if [ "${{ matrix.tag }}" != "" ]; then
echo "image_tag=${{ env.IMAGE_NAME }}:${{ matrix.tag }}-${{ env.VERSION }}" >> "$GITHUB_OUTPUT"
else
echo "image_tag=${{ env.IMAGE_NAME }}:${{ env.VERSION }}" >> "$GITHUB_OUTPUT"
fi
- name: <Setup> Pull ENGINE application docker image
run: docker pull "${{ steps.docker_vars.outputs.image_tag }}"
- name: <Setup> Run ENGINE application docker container
run: docker run -d -p 50021:50021 "${{ steps.docker_vars.outputs.image_tag }}"
# Docker コンテナが起動してから、レスポンスが返ってくるまで待機する
# リトライは10回まで `/version` にアクセスしてレスポンスのステータスコードをチェック
# - ステータスコードが `200` の場合は正常終了します
# - ステータスコードが `200` 以外の場合は、5秒間スリープしてリトライします
- name: <Setup> Warm up ENGINE server by waiting
run: |
set +e # curlのエラーを無視する
url="http://127.0.0.1:50021/version"
max_attempts=10
sleep_interval=5
for i in $(seq 1 "$max_attempts"); do
status=$(curl -o /dev/null -s -w '%{http_code}\n' "$url")
if [ "$status" -eq 200 ]; then
echo "Container is ready! Response status code: ${status}"
exit 0
else
echo "Attempt ${i}/${max_attempts}: Response status code $status"
sleep "${sleep_interval}"
fi
done
exit 1
- name: <Test> Test ENGINE application docker container
run: python tools/check_release_build.py --skip_run_process --dist_dir dist/