fix: portable runtime layout #567
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check Rust | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| rust: | |
| name: rustfmt + clippy + check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6.0.2 | |
| - name: Detect Tauri crate | |
| id: detect-tauri | |
| run: | | |
| set -euo pipefail | |
| if [ -d src-tauri ] && [ -f src-tauri/Cargo.toml ] && [ -f src-tauri/Cargo.lock ]; then | |
| echo "has_tauri=true" >> "${GITHUB_OUTPUT}" | |
| echo "Detected src-tauri crate." | |
| else | |
| echo "has_tauri=false" >> "${GITHUB_OUTPUT}" | |
| echo "src-tauri/Cargo.toml or Cargo.lock missing; skip Rust checks." | |
| fi | |
| - name: Setup Rust | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| components: rustfmt, clippy | |
| - name: Install Linux dependencies | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| libwebkit2gtk-4.1-dev \ | |
| libgtk-3-dev \ | |
| libayatana-appindicator3-dev \ | |
| librsvg2-dev \ | |
| patchelf | |
| - name: Determine Rust toolchain hash | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| id: rust-version | |
| run: | | |
| set -euo pipefail | |
| echo "rustc_hash=$(rustc -Vv | sha256sum | cut -d' ' -f1)" >> "${GITHUB_OUTPUT}" | |
| - name: Cache Cargo registry, git, and target | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| uses: actions/cache@v5.0.3 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| src-tauri/target | |
| key: ${{ runner.os }}-cargo-${{ steps.rust-version.outputs.rustc_hash }}-${{ hashFiles('src-tauri/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-${{ steps.rust-version.outputs.rustc_hash }}- | |
| - name: Ensure Tauri resource placeholders | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p resources/webui resources/backend | |
| if [ ! -f resources/webui/index.html ]; then | |
| printf '%s\n' '<!doctype html><title>AstrBot Placeholder</title>' > resources/webui/index.html | |
| fi | |
| if [ ! -f resources/backend/runtime-manifest.json ]; then | |
| printf '%s\n' '{"mode":"ci-placeholder","python":"python/bin/python3","entrypoint":"launch_backend.py","app":"app"}' > resources/backend/runtime-manifest.json | |
| fi | |
| - name: rustfmt | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| run: cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check | |
| - name: clippy | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| run: cargo clippy --manifest-path src-tauri/Cargo.toml --locked --all-targets -- -D warnings | |
| - name: cargo check | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| run: cargo check --manifest-path src-tauri/Cargo.toml --locked | |
| - name: cargo test | |
| if: steps.detect-tauri.outputs.has_tauri == 'true' | |
| run: cargo test --manifest-path src-tauri/Cargo.toml --locked -- --nocapture | |
| - name: Skip notice | |
| if: steps.detect-tauri.outputs.has_tauri != 'true' | |
| run: echo "Rust checks skipped because src-tauri crate files are missing." |