Skip to content

Refactor: CharacterButton.vueをリファクタ #5835

Refactor: CharacterButton.vueをリファクタ

Refactor: CharacterButton.vueをリファクタ #5835

Workflow file for this run

name: Test
on:
push:
pull_request:
branches:
- "**"
workflow_dispatch:
env:
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:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-environment
- run: npm run electron:build_pnever
# unit テスト
unit-test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-environment
- run: npm run test:unit
# e2e テスト
e2e-test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
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: Setup
run: |
# playwright
npx playwright install
# run.exe
chmod +x ${{ steps.download-engine.outputs.run_path }}
# .env
sed -i -e 's|"074fc39e-678b-4c13-8916-ffca8d505d1d"|"208cf94d-43d2-4cf5-abc0-9783cac36d29"|' .env.test
sed -i -e 's|"../voicevox_engine/run.exe"|"${{ steps.download-engine.outputs.run_path }}"|' .env.test
# GitHub Actions 環境だとたまに50021が封じられていることがあるので、ランダムなポートを使うようにする
PORT=$(node -r net -e "server=net.createServer();server.listen(0,()=>{console.log(server.address().port);server.close()})")
sed -i -e 's|"host": "http://127.0.0.1:50021"|"host": "http://127.0.0.1:'$PORT'"|' .env.test
sed -i -e 's|"executionArgs": \[\],|"executionArgs": ["--port='$PORT'"],|' .env.test
cp .env.test .env
- name: Check if commit message includes [update snapshots]
id: check-whether-to-update-snapshots
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const commits = ${{ toJson(github.event.commits) }};
if (!commits) {
// pull_request などでコミットがない場合はスキップ
core.setOutput("shouldUpdateSnapshots", false);
process.exit(0);
}
const shouldUpdateSnapshots = commits.some((commit) =>
commit.message.toLowerCase().includes("[update snapshots]")
);
core.setOutput("shouldUpdateSnapshots", shouldUpdateSnapshots);
console.log(`shouldUpdateSnapshots: ${shouldUpdateSnapshots}`);
- name: Run npm run test:browser-e2e
run: |
if [ -n "${{ runner.debug }}" ]; then
export DEBUG="pw:browser*"
fi
ARGS=""
if [[ ${{ steps.check-whether-to-update-snapshots.outputs.shouldUpdateSnapshots }} == 'true' ]]; then
ARGS="--update-snapshots"
fi
npm run test:browser-e2e -- $ARGS
- name: Run npm run test:electron-e2e
run: |
if [ -n "${{ runner.debug }}" ]; then
export DEBUG="pw:browser*"
fi
if [[ ${{ matrix.os }} == ubuntu-* ]]; then
xvfb-run --auto-servernum npm run test:electron-e2e
else
npm run test:electron-e2e
fi
- name: Upload playwright report to artifact
if: failure()
uses: actions/upload-artifact@v3
with:
name: playwright-report-${{ matrix.os }}
path: playwright-report
- name: Upload updated snapshots to artifact
if: steps.check-whether-to-update-snapshots.outputs.shouldUpdateSnapshots == 'true'
uses: actions/upload-artifact@v4
with:
name: updated-snapshots-${{ matrix.os }}
path: tests/e2e/browser/*-snapshots/*
commit-snapshots:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- e2e-test
steps:
- uses: actions/checkout@v3
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: updated-snapshots-*
path: tests/e2e/browser
merge-multiple: true
- name: Commit updated snapshots
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if [ -n "$(git status --porcelain)" ]; then
git add tests/e2e/browser
git commit -m "(スナップショットを更新)"
git push
else
echo "No changes to commit"
fi
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup environment
uses: ./.github/actions/setup-environment
- name: Disallowed licenses check
run: npm run license:generate -- -o voicevox_licenses.json
- run: npm run typecheck
- run: npm run lint
- run: npm run markdownlint