Skip to content

Commit

Permalink
ShellCheckとactionlintを導入 (VOICEVOX#341)
Browse files Browse the repository at this point in the history
* ShellCheckに準拠する

* Pyflakesに準拠する

* dead code部分をコメントアウトする

* Actionsを設定

* `name`を修正

* コメントを追加

* actionlintに`-color`を付ける

* Update build_util/codesign.bash

Co-authored-by: qwerty2501 <[email protected]>

* `=~ Linux`で判定するようにする

Co-authored-by: qwerty2501 <[email protected]>
  • Loading branch information
qryxip and qwerty2501 authored Dec 8, 2022
1 parent ad6fdae commit cb771e5
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ jobs:
ORT_USE_CUDA: ${{ matrix.use_cuda }}
- name: Set ASSET_NAME env var
shell: bash
run: echo "ASSET_NAME=voicevox_core-${{ matrix.artifact_name }}-${{ env.VERSION }}" >> $GITHUB_ENV
run: echo "ASSET_NAME=voicevox_core-${{ matrix.artifact_name }}-${{ env.VERSION }}" >> "$GITHUB_ENV"
- name: Organize artifact
shell: bash
run: |
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/download_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ jobs:
runs-on: ${{ matrix.os }}
name: ${{ matrix.name }}-${{ matrix.os }}
env:
EXPECTED_VOICEVOX_CORE_VERSION: ${{ matrix.expected_version || 'latest' }}
EXPECTED_VOICEVOX_CORE_VERSION: latest
# See https://github.com/VOICEVOX/voicevox_core/issues/310
#EXPECTED_VOICEVOX_CORE_VERSION: ${{ matrix.expected_version || 'latest' }}
steps:
- uses: actions/checkout@v3
- name: Execute download command
Expand All @@ -244,7 +246,7 @@ jobs:
if: ${{ env.EXPECTED_VOICEVOX_CORE_VERSION == 'latest' }}
shell: bash
run: |
echo "EXPECTED_VOICEVOX_CORE_VERSION=$(curl -sSfI "https://github.com/VOICEVOX/voicevox_core/releases/latest"| grep "location:" | sed -e "s%location: https://github.com/VOICEVOX/voicevox_core/releases/tag/%%" | sed 's/\r//g')" >> $GITHUB_ENV
echo "EXPECTED_VOICEVOX_CORE_VERSION=$(curl -sSfI "https://github.com/VOICEVOX/voicevox_core/releases/latest"| grep "location:" | sed -e "s%location: https://github.com/VOICEVOX/voicevox_core/releases/tag/%%" | sed 's/\r//g')" >> "$GITHUB_ENV"
- name: Check downloaded version
shell: bash
run: |
Expand All @@ -253,18 +255,20 @@ jobs:
- name: Check downloaded files
shell: bash
run: |
items=($(echo -e "${{ matrix.check_items }}" | xargs))
mapfile -t items < <(echo -n '${{ matrix.check_items }}')
for item in "${items[@]}"
do
echo "check exists ${{ matrix.download_dir }}/${item}..."
# shellcheck disable=SC2086
[ -e "${{ matrix.download_dir }}"/${item} ]
done
- name: Check should not exists files
shell: bash
run: |
items=($(echo -e "${{ matrix.check_not_exists_items }}" | xargs))
mapfile -t items < <(echo -n '${{ matrix.check_not_exists_items }}')
for item in "${items[@]}"
do
echo "check should not exists ${{ matrix.download_dir }}/${item}..."
# shellcheck disable=SC2086
[ ! -e "${{ matrix.download_dir }}"/${item} ]
done
39 changes: 38 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,41 @@ on:
- "**/*"
pull_request:
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
rust-lint:
runs-on: windows-latest
steps:
Expand Down Expand Up @@ -156,7 +191,9 @@ jobs:
cp -v target/debug/build/onnxruntime-sys-*/out/onnxruntime_*/onnxruntime-*/lib/libonnxruntime.*.dylib . || true
- name: '`maturin develop`でインストールした`voicevox_core_python_api`を実行'
shell: python
run: import voicevox_core
run: |
import voicevox_core
print(voicevox_core)
env:
CARGO_TERM_COLOR: always
2 changes: 1 addition & 1 deletion .github/workflows/update_rust_toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
run: |
rust_version=$(rustup run stable rustc --version | sed -r "s/.*([0-9]+\.[0-9]+\.[0-9]+[^ ]*).*/\1/")
echo "$rust_version" > ./rust-toolchain
echo "RUST_VERSION=$rust_version" >> $GITHUB_ENV
echo "RUST_VERSION=$rust_version" >> "$GITHUB_ENV"
- name: create_pr
id: update-rust-toolchain
uses: peter-evans/create-pull-request@v4
Expand Down
4 changes: 3 additions & 1 deletion build_util/codesign.bash
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# !!! コードサイニング証明書を取り扱うので取り扱い注意 !!!

set -eu
Expand Down Expand Up @@ -36,7 +37,8 @@ function is_signed() {
}

# 署名されていなければ署名
ls $target_file_glob | while read target_file; do
# shellcheck disable=SC2012,SC2086
ls $target_file_glob | while read -r target_file; do
if is_signed "$target_file"; then
echo "署名済み: $target_file"
else
Expand Down
4 changes: 2 additions & 2 deletions scripts/downloads/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ voicevox_additional_libraries_url(){
latest_version(){
base_url=$1
get_latest_url="$base_url/releases/tag"
echo -En $(curl -sSfI "$base_url/releases/latest"| grep "location:" | sed -e "s%location: $get_latest_url/%%" | sed 's/\r//g')
echo -En "$(curl -sSfI "$base_url/releases/latest"| grep "location:" | sed -e "s%location: $get_latest_url/%%" | sed 's/\r//g')"
}

latest_voicevox_core_version(){
Expand All @@ -62,7 +62,7 @@ latest_voicevox_additional_libraries_version(){
target_os(){
if [ "$(uname)" == 'Darwin' ]; then
echo "osx"
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
elif [[ "$(uname)" =~ Linux ]]; then
echo "linux"
else
echo "$(uname)はサポートされていない環境です" >&2
Expand Down

0 comments on commit cb771e5

Please sign in to comment.