Skip to content

Commit

Permalink
CI (test, build) をいくらか改善する (#50)
Browse files Browse the repository at this point in the history
#49

常にTauriを含めて全体のテストをまわすとビルドが肥大化するようなので、ワークフローを以下の3つに分離した:

- ライブラリ群 (`nusamai-*`) のテスト → ライブラリ部分を変更するPRに対して実行する。
- Tauri app (`app`) のテスト  → tauri 部分を変更するPRに対して実行する。
- Tauri app とそこから参照されるライブラリ、のビルド → 常に実行する。

これでテストの実行はいまよりは高速になる。CIキャッシュも、2GBくらいあったものが → 200MB や 500MB
程度になった。(Actionsのキャッシュはリポジトリあたり上限10GBで、超えると古いものからevictされる)

#49
で挙げている問題をすべて解消できているわけではない。テストが重いコンポーネントは、さらにテストワークフローを分離するか、汎用性高く実装できている箇所を別のリポジトリに切り出すのがいいと思う。
  • Loading branch information
ciscorn authored Dec 8, 2023
1 parent 3f21987 commit 7bf364e
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 17 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build Tauri App

on:
push:
branches:
- main
tags:
- "*"
pull_request:

env:
CARGO_TERM_COLOR: always

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rustup
run: rustup toolchain install stable --profile minimal
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: install dependencies
# if: matrix.platform == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt install -y libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
- name: Make Tauri build destination
run: mkdir -p app/build
- name: Build
run: cargo build --verbose --package app
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [macos-latest, windows-latest]
platform: [macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}

steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test
name: Test Tauri App

on:
push:
Expand All @@ -7,35 +7,35 @@ on:
tags:
- "*"
pull_request:
paths:
- "app/**"

env:
CARGO_TERM_COLOR: always
CARGO_TERM_COLOR: always

permissions:
contents: read

jobs:
bulid_and_test:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rustup
run: rustup update stable
run: rustup toolchain install stable --profile minimal
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: install dependencies
- name: Install dependencies
# if: matrix.platform == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt install -y libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Make Tauri build destination
run: mkdir -p app/build
- name: Build
run: cargo build --verbose --workspace
- name: Test
run: cargo llvm-cov --workspace --lcov --output-path lcov.info --all-features
run: cargo llvm-cov --package app --lcov --output-path lcov.info --all-features
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
Expand Down
43 changes: 43 additions & 0 deletions .github/workflows/test_libs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test Libraries

on:
push:
branches:
- main
tags:
- "*"
pull_request:
paths:
- "nusamai/**"
- "nusamai-*/**"

env:
CARGO_TERM_COLOR: always

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rustup
run: rustup toolchain install stable --profile minimal
- name: Rust Cache
uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt install -y libwebkit2gtk-4.0-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Test
run: cargo llvm-cov --workspace --exclude app --lcov --output-path lcov.info --all-features
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info
fail_ci_if_error: false
2 changes: 0 additions & 2 deletions nusamai-gltf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
encoding_rs = "0.8.33"
serde = { version = "1.0.192", features = ["derive"] }
serde_json = { version = "1.0.108", features = ["float_roundtrip"] }
serde_repr = "0.1.17"

[dev-dependencies]
glob = "0.3.1"
clap = { version = "4.4.6", features = ["derive"] }
elementtree = "1.2.3"
nusamai-geometry = { path = "../nusamai-geometry" }
quick-xml = "0.31.0"
thiserror = "1.0.50"
Expand Down
5 changes: 2 additions & 3 deletions nusamai-plateau/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ edition = "2021"
default = ["serde"]

[dependencies]
quick-xml = "0.31"
quick-xml = "0.31.0"
serde = { version = "1.0.193", features = ["derive"], optional = true }
citygml = { path = "./citygml", features = ["serde"]}
chrono = { version = "0.4.31", features = ["serde"] }
chrono = { version = "0.4.31", features = ["serde"], default-features = false }

[dev-dependencies]
zstd = { version = "0.13.0", features = ["zdict_builder"] }
bincode = { version = "2.0.0-rc", default-features = false, features = ["std", "serde"] }
clap = { version = "4.4", features = ["derive"] }
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
lz4_flex = "0.11.1"
2 changes: 1 addition & 1 deletion nusamai-plateau/citygml/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default = ["serde"]
serde = ["dep:serde", "nusamai-geometry/serde"]

[dependencies]
chrono = "0.4.31"
chrono = { version = "0.4.31", features = ["serde"], default-features = false }
indexmap = "2.1"
macros = { path = "./macros" }
nusamai-geometry = { path = "../../nusamai-geometry", features = ["serde"]}
Expand Down

0 comments on commit 7bf364e

Please sign in to comment.