diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index a15cf0ba..74f36513 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -19,6 +19,10 @@ on: schedule: - cron: '20 5 * * 4' +concurrency: + group: codeql-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: analyze: name: Analyze (${{ matrix.language }}) diff --git a/.github/workflows/test-and-lint.yml b/.github/workflows/test-and-lint.yml index 00b739d7..7c332009 100644 --- a/.github/workflows/test-and-lint.yml +++ b/.github/workflows/test-and-lint.yml @@ -12,50 +12,27 @@ on: permissions: contents: read +concurrency: + group: test-and-lint-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: - test-and-lint: + frontend: + name: Frontend & Workspace Checks runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - # Reclaim disk space on the standard GitHub Actions runner before installing - # dependencies and restoring the Rust cache. Unused pre-installed SDKs - # (.NET, Android, Haskell) take up ~30 GB, leaving less than 15 GB free. - # Without this cleanup, the runner runs out of disk space when linking - # the test binaries and GNU ld aborts with SIGBUS (signal 7 [Bus error]). - - name: Free runner disk space - run: | - sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /usr/local/share/boost - df -h - - - name: Install system dependencies (Tauri / webkit2gtk) - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev - - - name: Setup Node.js - uses: actions/setup-node@v6 - with: - node-version: 22 - - name: Setup pnpm uses: pnpm/action-setup@v5 with: version: 10.26.0 - - name: Install Rust 1.97.0 - uses: dtolnay/rust-toolchain@1.97.0 - with: - components: clippy, rustfmt - - - name: Cache Rust - uses: Swatinem/rust-cache@v2 + - name: Setup Node.js + uses: actions/setup-node@v6 with: - workspaces: asyar-launcher/src-tauri -> target - - - name: Check Rust formatting - run: cargo fmt --check - working-directory: asyar-launcher/src-tauri + node-version: 22 + cache: 'pnpm' - name: Install workspace dependencies run: pnpm install --frozen-lockfile @@ -93,6 +70,56 @@ jobs: asyar-sdk/cli/lib/knownRuntimes.ts \ asyar-sdk/cli/lib/gatedPermissions.ts + test-rust-linux: + name: Rust tests (Linux) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + # Reclaim disk space on the standard GitHub Actions runner before installing + # dependencies and restoring the Rust cache. Unused pre-installed SDKs + # (.NET, Android, Haskell) take up ~30 GB, leaving less than 15 GB free. + # Without this cleanup, the runner runs out of disk space when linking + # the test binaries and GNU ld aborts with SIGBUS (signal 7 [Bus error]). + - name: Free runner disk space + run: | + sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /usr/local/share/boost + df -h + + - name: Install system dependencies (Tauri / webkit2gtk) + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev + + - name: Setup pnpm + uses: pnpm/action-setup@v5 + with: + version: 10.26.0 + + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 22 + cache: 'pnpm' + + - name: Install Rust 1.97.0 + uses: dtolnay/rust-toolchain@1.97.0 + with: + components: clippy, rustfmt + + - name: Cache Rust + uses: Swatinem/rust-cache@v2 + with: + workspaces: asyar-launcher/src-tauri -> target + cache-on-failure: true + + - name: Check Rust formatting + run: cargo fmt --check + working-directory: asyar-launcher/src-tauri + + - name: Install workspace dependencies (for build.rs SDK-version read) + run: pnpm install --frozen-lockfile --ignore-scripts + - name: Run Rust tests run: cargo test --workspace working-directory: asyar-launcher/src-tauri @@ -182,16 +209,17 @@ jobs: # `build.rs` reads node_modules/asyar-sdk/package.json to inject the SDK # version, so the workspace symlink must exist. `--ignore-scripts` skips # the native (keytar) builds the Rust tests don't need, keeping this fast. - - name: Setup Node.js - uses: actions/setup-node@v6 - with: - node-version: 22 - - name: Setup pnpm uses: pnpm/action-setup@v5 with: version: 10.26.0 + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 22 + cache: 'pnpm' + - name: Install workspace dependencies (for build.rs SDK-version read) run: pnpm install --frozen-lockfile --ignore-scripts @@ -276,16 +304,17 @@ jobs: # build.rs reads node_modules/asyar-sdk/package.json to inject the # SDK version, so the workspace symlink must exist. --ignore-scripts # skips native (keytar) builds the Rust tests don't need. - - name: Setup Node.js - uses: actions/setup-node@v6 - with: - node-version: 22 - - name: Setup pnpm uses: pnpm/action-setup@v5 with: version: 10.26.0 + - name: Setup Node.js + uses: actions/setup-node@v6 + with: + node-version: 22 + cache: 'pnpm' + - name: Install workspace dependencies (for build.rs SDK-version read) run: pnpm install --frozen-lockfile --ignore-scripts @@ -312,3 +341,33 @@ jobs: - name: Run Clippy run: cargo clippy --workspace --all-targets -- -D warnings working-directory: asyar-launcher/src-tauri + + # Aggregator gate job required by GitHub branch ruleset (`context: "test-and-lint"`). + # Runs after all parallel jobs finish, ensuring that frontend and all platform Rust + # jobs passed, and blocks merge if any job failed. + test-and-lint: + name: test-and-lint + runs-on: ubuntu-latest + needs: + - frontend + - test-rust-linux + - test-rust-windows + - test-rust-macos + if: always() + steps: + - name: Verify all matrix checks succeeded + run: | + echo "Frontend: ${{ needs.frontend.result }}" + echo "Rust (Linux): ${{ needs.test-rust-linux.result }}" + echo "Rust (Windows): ${{ needs.test-rust-windows.result }}" + echo "Rust (macOS): ${{ needs.test-rust-macos.result }}" + + if [ "${{ needs.frontend.result }}" != "success" ] || \ + [ "${{ needs.test-rust-linux.result }}" != "success" ] || \ + [ "${{ needs.test-rust-windows.result }}" != "success" ] || \ + [ "${{ needs.test-rust-macos.result }}" != "success" ]; then + echo "::error::One or more test matrix jobs failed." + exit 1 + fi + + echo "All checks passed successfully."