Spaces:
Running
Running
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 | |
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/ | |