Skip to content

Commit

Permalink
Update: voicevox/voicevoxに追従 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiroshiba authored Oct 8, 2023
2 parents 13d2d35 + d5ad36c commit 09fc91e
Show file tree
Hide file tree
Showing 131 changed files with 5,313 additions and 2,691 deletions.
4 changes: 2 additions & 2 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DEFAULT_ENGINE_INFOS=`[
VITE_APP_NAME=voicevox
VITE_DEFAULT_ENGINE_INFOS=`[
{
"uuid": "074fc39e-678b-4c13-8916-ffca8d505d1d",
"name": "VOICEVOX Engine",
Expand All @@ -9,4 +10,3 @@ DEFAULT_ENGINE_INFOS=`[
}
]`
VITE_GTM_CONTAINER_ID=GTM-DUMMY
VV_OUTPUT_LOG_UTF8=1
4 changes: 2 additions & 2 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DEFAULT_ENGINE_INFOS=`[
VITE_APP_NAME=voicevox
VITE_DEFAULT_ENGINE_INFOS=`[
{
"uuid": "074fc39e-678b-4c13-8916-ffca8d505d1d",
"name": "VOICEVOX Engine",
Expand All @@ -9,4 +10,3 @@ DEFAULT_ENGINE_INFOS=`[
}
]`
VITE_GTM_CONTAINER_ID=GTM-DUMMY
VV_OUTPUT_LOG_UTF8=1
27 changes: 27 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,33 @@ module.exports = {
},
],
"import/order": "error",
"no-restricted-syntax": [
"warn",
{
selector:
"BinaryExpression[operator='==='][right.type='Literal'][right.value=null]",
message:
"'=== null'ではなく'== null'を使用してください。詳細: https://github.com/VOICEVOX/voicevox/issues/1513",
},
{
selector:
"BinaryExpression[operator='!=='][right.type='Literal'][right.value=null]",
message:
"'!== null'ではなく'!= null'を使用してください。詳細: https://github.com/VOICEVOX/voicevox/issues/1513",
},
{
selector:
"BinaryExpression[operator='==='][right.type='Identifier'][right.name=undefined]",
message:
"'=== undefined'ではなく'== undefined'を使用してください。詳細: https://github.com/VOICEVOX/voicevox/issues/1513",
},
{
selector:
"BinaryExpression[operator='!=='][right.type='Identifier'][right.name=undefined]",
message:
"'!== undefined'ではなく'!= undefined'を使用してください。詳細: https://github.com/VOICEVOX/voicevox/issues/1513",
},
],
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Question
about: 質問 (既存のIssueや一般事例を良く調べてからしてください)
about: 質問既存のIssueや一般事例を良く調べてからしてください
labels: question
---

Expand Down
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"
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
65 changes: 43 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ on:
code_signing:
description: "コード署名する"
type: boolean
default: false
upload_artifact:
description: "デバッグ用に成果物をartifactにアップロードするか"
type: boolean
default: false

env:
VOICEVOX_ENGINE_REPO_URL: "https://github.com/VOICEVOX/voicevox_engine"
VOICEVOX_ENGINE_VERSION: 0.14.5
VOICEVOX_RESOURCE_VERSION: 0.14.3
VOICEVOX_ENGINE_VERSION: 0.14.6
VOICEVOX_RESOURCE_VERSION: 0.14.4
VOICEVOX_EDITOR_VERSION:
|- # releaseタグ名か、workflow_dispatchでのバージョン名か、999.999.999-developが入る
${{ github.event.release.tag_name || github.event.inputs.version || '999.999.999-develop' }}
Expand Down Expand Up @@ -207,17 +208,23 @@ jobs:
- name: Generate public/licenses.json
run: npm run license:generate -- -o public/licenses.json

# build electronでコード署名するには環境変数を指定が必要だけど、
# コード署名しない場合に環境変数を定義するとエラーになるので、動的に環境変数を足す
- name: Define Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
run: |
# 複数行の文字列を環境変数に代入
echo 'CSC_LINK<<EOF' >> $GITHUB_ENV
echo "${{ secrets.CERT_BASE64 }}" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
echo 'CSC_KEY_PASSWORD=${{ secrets.CERT_PASSWORD }}' >> $GITHUB_ENV
bash build/codesign_setup.bash
THUMBPRINT="$(head -n 1 $THUMBPRINT_PATH)"
SIGNTOOL_PATH="$(head -n 1 $SIGNTOOL_PATH_PATH)"
echo "::add-mask::$THUMBPRINT"
echo "WIN_CERTIFICATE_SHA1=$THUMBPRINT" >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=["sha256"]' >> $GITHUB_ENV
echo "SIGNTOOL_PATH=$SIGNTOOL_PATH" >> $GITHUB_ENV
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt
SIGNTOOL_PATH_PATH: /tmp/signtool_path.txt

# Build result will be exported to ${{ matrix.artifact_path }}
- name: Build Electron
Expand All @@ -234,8 +241,12 @@ jobs:
- name: Reset Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
run: |
echo 'CSC_LINK=' >> $GITHUB_ENV
echo 'CSC_KEY_PASSWORD=' >> $GITHUB_ENV
bash build/codesign_cleanup.bash
echo 'WIN_CERTIFICATE_SHA1=' >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=' >> $GITHUB_ENV
echo 'SIGNTOOL_PATH=' >> $GITHUB_ENV
env:
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt

- name: Rename NoEngine Prepackage
run: |
Expand Down Expand Up @@ -360,17 +371,23 @@ jobs:
run: |
rm ${{ matrix.compressed_artifact_name }}-${{ env.VOICEVOX_EDITOR_VERSION }}.zip
# build electronでコード署名するには環境変数を指定が必要だけど、
# コード署名しない場合に環境変数を定義するとエラーになるので、動的に環境変数を足す
- name: Define Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
run: |
# 複数行の文字列を環境変数に代入
echo 'CSC_LINK<<EOF' >> $GITHUB_ENV
echo "${{ secrets.CERT_BASE64 }}" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
echo 'CSC_KEY_PASSWORD=${{ secrets.CERT_PASSWORD }}' >> $GITHUB_ENV
bash build/codesign_setup.bash
THUMBPRINT="$(head -n 1 $THUMBPRINT_PATH)"
SIGNTOOL_PATH="$(head -n 1 $SIGNTOOL_PATH_PATH)"
echo "::add-mask::$THUMBPRINT"
echo "WIN_CERTIFICATE_SHA1=$THUMBPRINT" >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=["sha256"]' >> $GITHUB_ENV
echo "SIGNTOOL_PATH=$SIGNTOOL_PATH" >> $GITHUB_ENV
env:
ESIGNERCKA_USERNAME: ${{ secrets.ESIGNERCKA_USERNAME }}
ESIGNERCKA_PASSWORD: ${{ secrets.ESIGNERCKA_PASSWORD }}
ESIGNERCKA_TOTP_SECRET: ${{ secrets.ESIGNERCKA_TOTP_SECRET }}
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt
SIGNTOOL_PATH_PATH: /tmp/signtool_path.txt

# NOTE: prepackage can be removed before splitting nsis-web archive
- name: Build Electron
Expand All @@ -392,8 +409,12 @@ jobs:
- name: Reset Code Signing Envs
if: startsWith(matrix.os, 'windows-') && github.event.inputs.code_signing == 'true'
run: |
echo 'CSC_LINK=' >> $GITHUB_ENV
echo 'CSC_KEY_PASSWORD=' >> $GITHUB_ENV
bash build/codesign_cleanup.bash
echo 'WIN_CERTIFICATE_SHA1=' >> $GITHUB_ENV
echo 'WIN_SIGNING_HASH_ALGORITHMS=' >> $GITHUB_ENV
echo 'SIGNTOOL_PATH=' >> $GITHUB_ENV
env:
THUMBPRINT_PATH: /tmp/esignercka_thumbprint.txt

- name: Create Linux AppImage split
if: endsWith(matrix.installer_artifact_name, '-appimage')
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/release_latest_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release latest dev build

# mainブランチが更新されるたびに開発版をビルドしてデプロイする。
# バージョン(タグ)は最新リリースのバージョンを`X.Y.Z`としたときの`X.Y+1.0-dev`。

on:
push:
branches:
- main
paths-ignore:
- "docs/**"
- "tests/**"

jobs:
latest-dev-build:
runs-on: ubuntu-latest
if: github.repository_owner == 'VOICEVOX'
steps:
- name: Trigger workflow_dispatch
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const latest_release = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo
});
const split_version = latest_release.data.tag_name.split('.');
const dev_version = `${split_version[0]}.${parseInt(split_version[1]) + 1}.0-dev`;
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'build.yml',
ref: 'main',
inputs: {
version: dev_version,
prerelease: true
}
})
console.log(`Triggered workflow_dispatch for ${dev_version}`);
74 changes: 68 additions & 6 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,23 +35,82 @@ jobs:

- run: npm run test:unit

# 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
- name: Setup
run: |
# playwright
npx playwright install
# run.exe
chmod +x ${{ steps.download-engine.outputs.run_path }}
# .env
cp .env.test .env
sed -i -e 's|"../voicevox_engine/run.exe"|"${{ steps.download-engine.outputs.run_path }}"|' .env
sed -i -e 's|"executionArgs": \[\],|"executionArgs": ["--port=50021"],|' .env
- name: Run npm run test:browser-e2e
run: |
if [ -n "${{ runner.debug }}" ]; then
export DEBUG="pw:browser*"
fi
if [[ ${{ matrix.os }} == ubuntu-* ]]; then
xvfb-run --auto-servernum npm run test:browser-e2e
else
npm run test:browser-e2e
fi
- name: Run npm run test:electron-e2e
run: |
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:electron-e2e
else
npm run test:e2e
npm run test:electron-e2e
fi
- name: Upload playwright report to artifact
if: failure()
uses: actions/upload-artifact@v3
with:
name: playwright-report
path: playwright-report

lint:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ node_modules

/tests/e2e/videos/
/tests/e2e/screenshots/
/test-results/*
/playwright-report/

# local env files
.env.local
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.16.0
FROM node:18.13.0

WORKDIR /opt
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o rustup_install.sh
Expand All @@ -11,4 +11,4 @@ WORKDIR /work
RUN npm ci
EXPOSE 3000

CMD ["/bin/sh"]
CMD ["/bin/sh"]
Loading

0 comments on commit 09fc91e

Please sign in to comment.