forked from VOICEVOX/voicevox_engine
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (85 loc) · 2.82 KB
/
release-test-docker.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
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 }}
jobs:
test:
runs-on: [ ubuntu-20.04 ]
strategy:
fail-fast: false
matrix:
tag:
- ""
- cpu
- cpu-ubuntu20.04
steps:
- uses: actions/checkout@v3
#
# Setup Python Environment
#
- uses: actions/setup-python@v4
with:
python-version: "3.11.3"
cache: pip
- name: Install libsndfile1
run: |
sudo apt-get update
sudo apt-get install libsndfile1
- name: Install requirements
run: |
pip install -r requirements-test.txt
#
# Setup Docker Environment
#
- name: 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: Docker pull
run: docker pull "${{ steps.docker_vars.outputs.image_tag }}"
- name: Docker run
run: docker run -d -p 50021:50021 "${{ steps.docker_vars.outputs.image_tag }}"
# Docker コンテナが起動してから、レスポンスが返ってくるまで待機する
# リトライは10回まで `/version` にアクセスしてレスポンスのステータスコードをチェック
# - ステータスコードが `200` の場合は正常終了します
# - ステータスコードが `200` 以外の場合は、5秒間スリープしてリトライします
- name: Wait for container to start
shell: bash -xv {0}
run: |
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
shell: bash
run: python build_util/check_release_build.py --skip_run_process --dist_dir dist/