Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test:e2eをlinuxとmacでも動くように #1415

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/actions/download-engine/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: "Download VOICEVOX ENGINE"
description: |
VOICEVOX ENGINEをダウンロードし、指定したディレクトリに展開する。
inputs:
repo:
description: "リポジトリ名。デフォルトはVOICEVOX/voicevox_engine。"
required: false
default: "VOICEVOX/voicevox_engine"
version:
description: "VOICEVOX ENGINEのバージョン。latest(デフォルト)、prerelease-latest、バージョン番号(例:0.14.4)で指定できる。"
required: false
Expand Down Expand Up @@ -37,7 +41,7 @@ runs:
- name: Get version
shell: bash
run: |
curl -s https://api.github.com/repos/voicevox/voicevox_engine/releases \
curl -s https://api.github.com/repos/${{ inputs.repo }}/releases \
-H 'authorization: Bearer ${{ github.token }}' \
-H 'content-type: application/json' > $TEMPDIR/releases.json

Expand All @@ -52,8 +56,8 @@ runs:
shell: bash
run: |
if [ "${{ inputs.target }}" = "" ]; then
OS="${{ runner.os }}"
TARGET="${OS,,}-cpu" # 小文字にする
OS=$(echo "${{ runner.os }}" | tr "[:upper:]" "[:lower:]") # 小文字にする
TARGET="$OS-cpu"
Comment on lines -55 to +60
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MacOSで動かなかったので修正
(デフォルトのBashのバージョンが低いらしい)

else
TARGET="${{ inputs.target }}"
fi
Expand Down Expand Up @@ -93,4 +97,5 @@ runs:
else
echo "run_path=$DEST/run" >> $GITHUB_OUTPUT
fi
cat $TEMPDIR/target.json | jq -r '.tag_name' | sed -e 's_^_version=_' >> $GITHUB_OUTPUT
echo "version=$(jq -r '.tag_name' $TEMPDIR/target.json)" >> $GITHUB_OUTPUT
Comment on lines -96 to +100
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ただのリファクタリング


44 changes: 40 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ on:
workflow_dispatch:

env:
VOICEVOX_ENGINE_VERSION: 0.14.4
VOICEVOX_ENGINE_REPO: "VOICEVOX/voicevox_nemo_engine" # 軽いのでNemoを使う
VOICEVOX_ENGINE_VERSION: "0.14.0"

defaults:
run:
shell: bash

jobs:
# ビルドのテスト
build-test:
runs-on: windows-latest
steps:
Expand All @@ -23,7 +25,8 @@ jobs:
uses: ./.github/actions/setup-environment
- run: npm run electron:build_pnever

test:
# unit テスト
unit-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -32,19 +35,52 @@ jobs:

- run: npm run test:unit

# electron の e2e テスト
e2e-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
voicevox_engine_asset_name: linux-cpu
- os: macos-latest
voicevox_engine_asset_name: macos-x64
- os: windows-latest
voicevox_engine_asset_name: windows-cpu
steps:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-environment

- name: Install xvfb and x11-xserver-utils
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y xvfb x11-xserver-utils # for electron
sudo apt-get install -y libsndfile1 # for engine

- name: Download VOICEVOX ENGINE
id: download-engine
uses: ./.github/actions/download-engine
with:
repo: ${{ env.VOICEVOX_ENGINE_REPO }}
version: ${{ env.VOICEVOX_ENGINE_VERSION }}
dest: ${{ github.workspace }}/voicevox_engine
target: ${{ matrix.voicevox_engine_asset_name }}

- name: Run npm run test:e2e
run: |
chmod +x ${{ steps.download-engine.outputs.run_path }}

cp .env.test .env
sed -i -e 's|"../voicevox_engine/run.exe"|"${{ steps.download-engine.outputs.run_path }}"|' .env

if [ -n "${{ runner.debug }}" ]; then
DEBUG=pw:browser* npm run test:e2e
export DEBUG="pw:browser*"
fi
if [[ ${{ matrix.os }} == ubuntu-* ]]; then
xvfb-run --auto-servernum npm run test:e2e
else
npm run test:e2e
fi
Expand Down