From cb248001631307928e9761cb9a2a5ad7f2289698 Mon Sep 17 00:00:00 2001 From: wyhaya Date: Wed, 21 Aug 2024 10:42:40 +0800 Subject: [PATCH] Add GitHub Action --- .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++++++++++++++++ tauri-v2/src/lib.rs | 4 +-- 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2e61ff9 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: Build + +on: [push, pull_request] + +jobs: + build: + name: ${{ matrix.job.target }} + runs-on: ${{ matrix.job.os }} + strategy: + matrix: + job: + - target: x86_64-unknown-linux-gnu + os: ubuntu-latest + - target: aarch64-apple-darwin + os: macos-latest + - target: x86_64-pc-windows-msvc + os: windows-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + tauri-v1/target/ + tauri-v2/target/ + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Setup Rust + run: | + rustup update + rustup target add ${{ matrix.job.target }} + + - name: Install Linux dependencies + if: runner.os == 'Linux' + run: | + sudo apt update + sudo apt install libwebkit2gtk-4.0-dev build-essential curl wget file libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev -y + sudo apt install libwebkit2gtk-4.1-dev libxdo-dev -y + + - name: Cargo fmt + run: | + cd tauri-v1 && cargo fmt --all -- --check && cd .. + cd tauri-v2 && cargo fmt --all -- --check && cd .. + + - name: Cargo build v1 + run: | + cd tauri-v1 && cargo build --target ${{ matrix.job.target }} && cd .. + + - name: Cargo build v2 + run: | + cd tauri-v2 && cargo build --target ${{ matrix.job.target }} && cd .. diff --git a/tauri-v2/src/lib.rs b/tauri-v2/src/lib.rs index adfc53b..4cfbe5e 100644 --- a/tauri-v2/src/lib.rs +++ b/tauri-v2/src/lib.rs @@ -87,9 +87,7 @@ impl ToString for Theme { #[cfg(target_os = "windows")] fn saved_theme_value_from_config(config: &Config) -> Theme { if let Some(dir) = dirs_next::config_dir() { - let p = dir - .join(&config.identifier) - .join(CONFIG_FILENAME); + let p = dir.join(&config.identifier).join(CONFIG_FILENAME); return fs::read_to_string(p) .map(Theme::from) .unwrap_or(Theme::Auto);