From 0bde985ea51ef518e4f833d2ac2005357ad8e460 Mon Sep 17 00:00:00 2001 From: y-chan Date: Sun, 15 Jan 2023 17:15:19 +0900 Subject: [PATCH 1/7] decrement workflow runs --- .github/workflows/build_and_deploy.yml | 8 +++++--- .github/workflows/cargo-deny.yml | 4 ++++ .github/workflows/generate_document.yml | 2 ++ .github/workflows/test.yml | 5 ++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 99aa6cc15..ccac62bcd 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -13,10 +13,12 @@ on: types: - published pull_request: + paths: + - '**.rs' + - '**.toml' push: - branches: - - "*" - - "**/*" + branches: + - main env: # releaseタグ名か、workflow_dispatchでのバージョン名か、DEBUGが入る VERSION: ${{ github.event.release.tag_name || github.event.inputs.version || 'DEBUG' }} diff --git a/.github/workflows/cargo-deny.yml b/.github/workflows/cargo-deny.yml index 76c9e412d..5167246e7 100644 --- a/.github/workflows/cargo-deny.yml +++ b/.github/workflows/cargo-deny.yml @@ -1,7 +1,11 @@ name: cargo-deny on: push: + branches: + - main pull_request: + paths: + - '**.toml' jobs: cargo-deny: runs-on: ubuntu-20.04 diff --git a/.github/workflows/generate_document.yml b/.github/workflows/generate_document.yml index ad52529e3..1b58035c1 100644 --- a/.github/workflows/generate_document.yml +++ b/.github/workflows/generate_document.yml @@ -4,6 +4,8 @@ on: branches: - main pull_request: + paths: + - '**.rs' jobs: generate_api_document: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 00bb66041..0a4a07abf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,8 @@ name: test workflow on: push: - branches: - - "*" - - "**/*" + branches: + - main pull_request: jobs: shellcheck: From d21c13236352add85946250edd80a58916bd462f Mon Sep 17 00:00:00 2001 From: Yuto Ashida Date: Mon, 16 Jan 2023 00:00:11 +0900 Subject: [PATCH 2/7] update paths in workflows Co-authored-by: Ryo Yamashita --- .github/workflows/build_and_deploy.yml | 8 ++++++-- .github/workflows/cargo-deny.yml | 4 +++- .github/workflows/generate_document.yml | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index ccac62bcd..dde87ca69 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -14,8 +14,12 @@ on: - published pull_request: paths: - - '**.rs' - - '**.toml' + - build_util/** + - Cargo.* + - crates/voicevox_core** + - model/** + - rust-toolchain + - scripts/downloads/* push: branches: - main diff --git a/.github/workflows/cargo-deny.yml b/.github/workflows/cargo-deny.yml index 5167246e7..5e5f4a45f 100644 --- a/.github/workflows/cargo-deny.yml +++ b/.github/workflows/cargo-deny.yml @@ -5,7 +5,9 @@ on: - main pull_request: paths: - - '**.toml' + - '**/Cargo.*' + - deny.toml + - rust-toolchain jobs: cargo-deny: runs-on: ubuntu-20.04 diff --git a/.github/workflows/generate_document.yml b/.github/workflows/generate_document.yml index 1b58035c1..353d96617 100644 --- a/.github/workflows/generate_document.yml +++ b/.github/workflows/generate_document.yml @@ -5,7 +5,10 @@ on: - main pull_request: paths: - - '**.rs' + - 'Cargo.*' + - crates/voicevox_core** + - docs/** + - rust-toolchain jobs: generate_api_document: runs-on: ubuntu-latest From 2db986f1090e789ccee72e6c8260dca45ec9ae1a Mon Sep 17 00:00:00 2001 From: y-chan Date: Mon, 16 Jan 2023 00:59:48 +0900 Subject: [PATCH 3/7] separate and merge jobs in actions --- .github/workflows/actionlint.yml | 34 +++++ .github/workflows/build_cpp_example.yml | 56 ++++++++ .github/workflows/shellcheck.yml | 20 +++ .github/workflows/test.yml | 162 ++++-------------------- 4 files changed, 135 insertions(+), 137 deletions(-) create mode 100644 .github/workflows/actionlint.yml create mode 100644 .github/workflows/build_cpp_example.yml create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml new file mode 100644 index 000000000..3f33a0fb7 --- /dev/null +++ b/.github/workflows/actionlint.yml @@ -0,0 +1,34 @@ +name: shellcheck +on: + push: + branches: + - main + pull_request: + paths: + - .github/workflows/** + - .github/actions/**/* + +jobs: + actionlint: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + # ShellCheckとPyflakesをインストールしておくと、shell: bashとshell: pythonのコードを検査してくれるようになる + # + # 参考: + # - https://github.com/rhysd/actionlint/blob/main/docs/checks.md#shellcheck-integration-for-run + # - https://github.com/rhysd/actionlint/blob/main/docs/checks.md#pyflakes-integration-for-run + - name: Update ShellCheck + run: | + sudo apt-get update + sudo apt-get install -y shellcheck + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: "3.8" + - name: Install Pyflakes + run: pip install 'pyflakes>3,<4' + - name: actionlint + run: | + bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) + ./actionlint -color diff --git a/.github/workflows/build_cpp_example.yml b/.github/workflows/build_cpp_example.yml new file mode 100644 index 000000000..5bc3e8fc0 --- /dev/null +++ b/.github/workflows/build_cpp_example.yml @@ -0,0 +1,56 @@ +name: test workflow +on: + push: + branches: + - main + pull_request: + paths: + - crates/voicevox_core** + - '!crates/voicevox_core_python_api/**' + - model/** + - example/cpp/unix/** + +jobs: + build-unix-cpp-example: + strategy: + fail-fast: false + matrix: + include: + - os: macos-latest + artifact_name: osx-x64-cpu-cpp-shared + - os: ubuntu-latest + artifact_name: linux-x64-cpu-cpp-shared + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + - name: Set up Rust + uses: ./.github/actions/rust-toolchain-from-file + - name: Install cargo-binstall + uses: taiki-e/install-action@cargo-binstall + - name: Install cbindgen + uses: ./.github/actions/cargo-binstall-cbindgen + - name: build voicevox_core_c_api + run: cargo build -p voicevox_core_c_api -vv + - name: voicevox_core.hを生成 + run: cbindgen --crate voicevox_core_c_api -o ./example/cpp/unix/voicevox_core/voicevox_core.h + - name: 必要なfileをunix用exampleのディレクトリに移動させる + run: | + mkdir -p example/cpp/unix/voicevox_core/ + cp -v target/debug/libvoicevox_core.{so,dylib} example/cpp/unix/voicevox_core/ || true + cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.so.* example/cpp/unix/voicevox_core/ || true + cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.*.dylib example/cpp/unix/voicevox_core/ || true + + - if: startsWith(matrix.os, 'mac') + uses: jwlawson/actions-setup-cmake@v1.13 + - name: Install build dependencies + if: startsWith(matrix.os, 'ubuntu') + shell: bash + run: | + sudo apt-get update + sudo apt-get install -y cmake + - name: Build + shell: bash + run: | + cd example/cpp/unix + cmake -S . -B build + cmake --build build diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 000000000..3dca32007 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,20 @@ +name: shellcheck +on: + push: + branches: + - main + pull_request: + paths: + - '**.sh' + - '**.bash' +jobs: + shellcheck: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Update ShellCheck + run: | + sudo apt-get update + sudo apt-get install -y shellcheck + - name: ShellCheck + run: git ls-files | grep -E '\.(ba)?sh' | xargs shellcheck diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a4a07abf..41aea2136 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,69 +4,12 @@ on: branches: - main pull_request: + paths: + - crates/voicevox_core** + - Cargo.* + - rust-toolchain jobs: - shellcheck: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - name: Update ShellCheck - run: | - sudo apt-get update - sudo apt-get install -y shellcheck - - name: ShellCheck - run: git ls-files | grep -E '\.(ba)?sh' | xargs shellcheck - - actionlint: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - # ShellCheckとPyflakesをインストールしておくと、shell: bashとshell: pythonのコードを検査してくれるようになる - # - # 参考: - # - https://github.com/rhysd/actionlint/blob/main/docs/checks.md#shellcheck-integration-for-run - # - https://github.com/rhysd/actionlint/blob/main/docs/checks.md#pyflakes-integration-for-run - - name: Update ShellCheck - run: | - sudo apt-get update - sudo apt-get install -y shellcheck - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: "3.8" - - name: Install Pyflakes - run: pip install 'pyflakes>3,<4' - - name: actionlint - run: | - bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) - ./actionlint -color - - validate-cargo-lock: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - name: Set up Rust - uses: ./.github/actions/rust-toolchain-from-file - - name: Validate Cargo.lock - run: cargo metadata --locked --format-version 1 > /dev/null - - rust-lint: - runs-on: windows-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Rust - uses: ./.github/actions/rust-toolchain-from-file - with: - components: clippy,rustfmt - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: "3.8" - - uses: Swatinem/rust-cache@v2 - - run: cargo clippy -vv --all-features --features onnxruntime/disable-sys-build-script --tests -- -D clippy::all -D warnings --no-deps - - run: cargo clippy -vv --all-features --features onnxruntime/disable-sys-build-script -- -D clippy::all -D warnings --no-deps - - run: cargo fmt -- --check - - rust-test: + test-lint-build: strategy: fail-fast: false matrix: @@ -94,22 +37,16 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.8" - - name: Set up Rust + - name: Set up Rust (test only) + if: matrix.os != "windows-2022" uses: ./.github/actions/rust-toolchain-from-file - - uses: Swatinem/rust-cache@v2 - with: - # cargoのキャッシュが原因でテストが失敗する場合はバージョン部分をカウントアップすること - key: "v2-cargo-test-cache-${{ matrix.features }}-${{ matrix.os }}" - - name: Run cargo test - shell: bash - run: cargo test -vv --features ,${{ matrix.features }} - - xtask-generate-c-header: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Rust + - name: Set up Rust (test and lint) + if: matrix.os == "windows-2022" uses: ./.github/actions/rust-toolchain-from-file + with: + components: clippy,rustfmt + - name: Validate Cargo.lock + run: cargo metadata --locked --format-version 1 > /dev/null - name: Install cargo-binstall uses: taiki-e/install-action@cargo-binstall - name: Install cbindgen @@ -120,68 +57,19 @@ jobs: run: cargo xtask generate-c-header -o ./voicevox_core_2.h - name: Assert these header files are same run: diff -u --color=always ./voicevox_core_{1,2}.h - - build-unix-cpp-example: - strategy: - fail-fast: false - matrix: - include: - - os: macos-latest - artifact_name: osx-x64-cpu-cpp-shared - - os: ubuntu-latest - artifact_name: linux-x64-cpu-cpp-shared - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - name: Set up Rust - uses: ./.github/actions/rust-toolchain-from-file - - name: Install cargo-binstall - uses: taiki-e/install-action@cargo-binstall - - name: Install cbindgen - uses: ./.github/actions/cargo-binstall-cbindgen - - name: build voicevox_core_c_api - run: cargo build -p voicevox_core_c_api -vv - - name: voicevox_core.hを生成 - run: cbindgen --crate voicevox_core_c_api -o ./example/cpp/unix/voicevox_core/voicevox_core.h - - name: 必要なfileをunix用exampleのディレクトリに移動させる - run: | - mkdir -p example/cpp/unix/voicevox_core/ - cp -v target/debug/libvoicevox_core.{so,dylib} example/cpp/unix/voicevox_core/ || true - cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.so.* example/cpp/unix/voicevox_core/ || true - cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.*.dylib example/cpp/unix/voicevox_core/ || true - - - if: startsWith(matrix.os, 'mac') - uses: jwlawson/actions-setup-cmake@v1.13 - - name: Install build dependencies - if: startsWith(matrix.os, 'ubuntu') - shell: bash - run: | - sudo apt-get update - sudo apt-get install -y cmake - - name: Build - shell: bash - run: | - cd example/cpp/unix - cmake -S . -B build - cmake --build build - - build-python-api: - strategy: - fail-fast: false - matrix: - include: - - os: windows-latest - - os: macos-latest - - os: ubuntu-latest - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - uses: Swatinem/rust-cache@v2 with: - python-version: "3.8" - - name: Set up Rust - uses: ./.github/actions/rust-toolchain-from-file + # cargoのキャッシュが原因でテストが失敗する場合はバージョン部分をカウントアップすること + key: "v2-cargo-test-cache-${{ matrix.features }}-${{ matrix.os }}" + - name: Run cargo test + shell: bash + run: cargo test -vv --features ,${{ matrix.features }} + - run: cargo clippy -vv --all-features --features onnxruntime/disable-sys-build-script --tests -- -D clippy::all -D warnings --no-deps + if: matrix.os == "windows-2022" + - run: cargo clippy -vv --all-features --features onnxruntime/disable-sys-build-script -- -D clippy::all -D warnings --no-deps + if: matrix.os == "windows-2022" + - run: cargo fmt -- --check + if: matrix.os == "windows-2022" - name: venv作成 uses: ./.github/actions/create-venv - shell: bash From 2763afb8ee40df23e6be58d1a0eee6d6d11e5984 Mon Sep 17 00:00:00 2001 From: y-chan Date: Mon, 16 Jan 2023 01:02:27 +0900 Subject: [PATCH 4/7] lint --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 41aea2136..08b0d5e54 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,10 +38,10 @@ jobs: with: python-version: "3.8" - name: Set up Rust (test only) - if: matrix.os != "windows-2022" + if: matrix.os != 'windows-2022' uses: ./.github/actions/rust-toolchain-from-file - name: Set up Rust (test and lint) - if: matrix.os == "windows-2022" + if: matrix.os == 'windows-2022' uses: ./.github/actions/rust-toolchain-from-file with: components: clippy,rustfmt @@ -65,11 +65,11 @@ jobs: shell: bash run: cargo test -vv --features ,${{ matrix.features }} - run: cargo clippy -vv --all-features --features onnxruntime/disable-sys-build-script --tests -- -D clippy::all -D warnings --no-deps - if: matrix.os == "windows-2022" + if: matrix.os == 'windows-2022' - run: cargo clippy -vv --all-features --features onnxruntime/disable-sys-build-script -- -D clippy::all -D warnings --no-deps - if: matrix.os == "windows-2022" + if: matrix.os == 'windows-2022' - run: cargo fmt -- --check - if: matrix.os == "windows-2022" + if: matrix.os == 'windows-2022' - name: venv作成 uses: ./.github/actions/create-venv - shell: bash From 7ebc3507fb01f124d6fbe3ec4b5af0fe3bbc3d59 Mon Sep 17 00:00:00 2001 From: Yuto Ashida Date: Mon, 16 Jan 2023 13:27:00 +0900 Subject: [PATCH 5/7] fix workflow name Co-authored-by: Ryo Yamashita --- .github/workflows/build_cpp_example.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_cpp_example.yml b/.github/workflows/build_cpp_example.yml index 5bc3e8fc0..b1a1509f6 100644 --- a/.github/workflows/build_cpp_example.yml +++ b/.github/workflows/build_cpp_example.yml @@ -1,4 +1,4 @@ -name: test workflow +name: Build C++ example on: push: branches: From e67397f3620e82c3bdbd9cd75596c69cf3bdb82e Mon Sep 17 00:00:00 2001 From: Yuto Ashida Date: Mon, 16 Jan 2023 13:36:03 +0900 Subject: [PATCH 6/7] check all rust crates Co-authored-by: Ryo Yamashita --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08b0d5e54..8d369952d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ on: - main pull_request: paths: - - crates/voicevox_core** + - crates/** - Cargo.* - rust-toolchain jobs: From 36fbcc4c3fd9b6cfc65b2decef7505a7e859d853 Mon Sep 17 00:00:00 2001 From: PickledChair Date: Sun, 21 May 2023 00:15:22 +0900 Subject: [PATCH 7/7] =?UTF-8?q?rust-cache=E3=81=AE=E8=A1=8C=E3=81=8C?= =?UTF-8?q?=E6=8A=9C=E3=81=91=E3=81=A6=E3=81=97=E3=81=BE=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 43508e8d9..01734a1fd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -65,6 +65,7 @@ jobs: python-version: "3.8" - name: Set up Rust uses: ./.github/actions/rust-toolchain-from-file + - uses: Swatinem/rust-cache@v2 with: # cargoのキャッシュが原因でテストが失敗する場合はバージョン部分をカウントアップすること key: "v2-cargo-test-cache-${{ matrix.features }}-${{ matrix.os }}"