Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions .github/actions/prepare-macos-dependency-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Prepare verified macOS dependency caches
description: Restore, validate, and safely fall back from repository-scoped macOS dependency caches.

inputs:
swiftpm:
description: Restore and resolve SwiftPM dependency repositories.
required: false
default: "false"
cargo:
description: Restore Cargo crate archives.
required: false
default: "false"
jdtls:
description: Restore JDTLS and Lombok downloads.
required: false
default: "false"
restore-only:
description: Restore caches without saving them at the end of the job.
required: false
default: "false"

runs:
using: composite
steps:
- name: Configure isolated dependency caches
shell: zsh {0}
run: |
mkdir -p "$GITHUB_WORKSPACE/.artifacts"
{
echo "CARGO_HOME=$GITHUB_WORKSPACE/.artifacts/cargo-home"
echo "LITHE_SWIFTPM_CACHE_PATH=$GITHUB_WORKSPACE/.artifacts/swiftpm-cache"
} >> "$GITHUB_ENV"

- name: Restore SwiftPM repositories
id: swiftpm_cache
if: inputs.swiftpm == 'true' && inputs.restore-only != 'true'
continue-on-error: true
uses: actions/cache@v6
with:
path: |
.artifacts/swiftpm-cache/repositories
.artifacts/swiftpm-cache/.lithe-integrity.json
key: macos-swiftpm-repositories-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }}
restore-keys: |
macos-swiftpm-repositories-${{ runner.os }}-6.2-

- name: Restore SwiftPM repositories without saving
id: swiftpm_restore
if: inputs.swiftpm == 'true' && inputs.restore-only == 'true'
continue-on-error: true
uses: actions/cache/restore@v6
with:
path: |
.artifacts/swiftpm-cache/repositories
.artifacts/swiftpm-cache/.lithe-integrity.json
key: macos-swiftpm-repositories-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }}
restore-keys: |
macos-swiftpm-repositories-${{ runner.os }}-6.2-

- name: Restore Cargo crate archives
id: cargo_cache
if: inputs.cargo == 'true' && inputs.restore-only != 'true'
continue-on-error: true
uses: actions/cache@v6
with:
path: .artifacts/cargo-home/registry/cache
key: macos-cargo-crates-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: |
macos-cargo-crates-${{ runner.os }}-

- name: Restore Cargo crate archives without saving
id: cargo_restore
if: inputs.cargo == 'true' && inputs.restore-only == 'true'
continue-on-error: true
uses: actions/cache/restore@v6
with:
path: .artifacts/cargo-home/registry/cache
key: macos-cargo-crates-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock') }}
restore-keys: |
macos-cargo-crates-${{ runner.os }}-

- name: Restore JDTLS downloads
id: jdtls_cache
if: inputs.jdtls == 'true' && inputs.restore-only != 'true'
continue-on-error: true
uses: actions/cache@v6
with:
path: .artifacts/jdtls-downloads
key: macos-jdtls-downloads-${{ runner.os }}-${{ hashFiles('third_party/jdtls/manifest.json') }}
restore-keys: |
macos-jdtls-downloads-${{ runner.os }}-

- name: Restore JDTLS downloads without saving
id: jdtls_restore
if: inputs.jdtls == 'true' && inputs.restore-only == 'true'
continue-on-error: true
uses: actions/cache/restore@v6
with:
path: .artifacts/jdtls-downloads
key: macos-jdtls-downloads-${{ runner.os }}-${{ hashFiles('third_party/jdtls/manifest.json') }}
restore-keys: |
macos-jdtls-downloads-${{ runner.os }}-

- name: Validate restored caches or fall back
shell: zsh {0}
env:
RESTORE_ONLY: ${{ inputs.restore-only }}
SWIFTPM_CACHE_OUTCOME: ${{ steps.swiftpm_cache.outcome }}
SWIFTPM_CACHE_HIT: ${{ steps.swiftpm_cache.outputs.cache-hit }}
SWIFTPM_RESTORE_OUTCOME: ${{ steps.swiftpm_restore.outcome }}
SWIFTPM_RESTORE_HIT: ${{ steps.swiftpm_restore.outputs.cache-hit }}
CARGO_CACHE_OUTCOME: ${{ steps.cargo_cache.outcome }}
CARGO_RESTORE_OUTCOME: ${{ steps.cargo_restore.outcome }}
JDTLS_CACHE_OUTCOME: ${{ steps.jdtls_cache.outcome }}
JDTLS_RESTORE_OUTCOME: ${{ steps.jdtls_restore.outcome }}
run: |
swiftpm_outcome="$SWIFTPM_CACHE_OUTCOME"
swiftpm_hit="$SWIFTPM_CACHE_HIT"
cargo_outcome="$CARGO_CACHE_OUTCOME"
jdtls_outcome="$JDTLS_CACHE_OUTCOME"
if [[ "$RESTORE_ONLY" == "true" ]]; then
swiftpm_outcome="$SWIFTPM_RESTORE_OUTCOME"
swiftpm_hit="$SWIFTPM_RESTORE_HIT"
cargo_outcome="$CARGO_RESTORE_OUTCOME"
jdtls_outcome="$JDTLS_RESTORE_OUTCOME"
fi
"$GITHUB_WORKSPACE/scripts/validate-macos-dependency-caches.sh" \
--swiftpm-enabled "${{ inputs.swiftpm }}" \
--swiftpm-outcome "${swiftpm_outcome:-skipped}" \
--swiftpm-hit "${swiftpm_hit:-}" \
--cargo-enabled "${{ inputs.cargo }}" \
--cargo-outcome "${cargo_outcome:-skipped}" \
--jdtls-enabled "${{ inputs.jdtls }}" \
--jdtls-outcome "${jdtls_outcome:-skipped}"

- name: Resolve SwiftPM dependencies with fallback
if: inputs.swiftpm == 'true'
shell: zsh {0}
run: "$GITHUB_WORKSPACE/scripts/prepare-macos-dependencies.sh"
10 changes: 3 additions & 7 deletions .github/workflows/ci-database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,10 @@ jobs:
with:
swift-version: "6.2"

- name: Restore SwiftPM dependencies
uses: actions/cache@v6
- name: Prepare verified SwiftPM cache
uses: ./.github/actions/prepare-macos-dependency-cache
with:
path: |
.build/checkouts
.build/repositories
~/.cache/org.swift.swiftpm
key: swiftpm-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }}
swiftpm: "true"

- name: Run database-focused Swift tests
timeout-minutes: 12
Expand Down
39 changes: 11 additions & 28 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,10 @@ jobs:
with:
swift-version: "6.2"

- name: Restore SwiftPM dependencies
uses: actions/cache@v6
- name: Prepare verified SwiftPM cache
uses: ./.github/actions/prepare-macos-dependency-cache
with:
path: |
.build/checkouts
.build/repositories
~/.cache/org.swift.swiftpm
key: swiftpm-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }}
swiftpm: "true"

- name: Run Swift unit tests
timeout-minutes: 12
Expand Down Expand Up @@ -181,13 +177,11 @@ jobs:
with:
components: rustfmt

- name: Restore Cargo dependencies
uses: actions/cache@v6
- name: Prepare verified dependency caches
uses: ./.github/actions/prepare-macos-dependency-cache
with:
path: |
~/.cargo/git
~/.cargo/registry
key: cargo-dependencies-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock') }}
swiftpm: "true"
cargo: "true"

- name: Run Rust Core tests and verify the Swift bridge
run: ./scripts/verify-rust-core.sh
Expand All @@ -213,22 +207,11 @@ jobs:
with:
targets: aarch64-apple-darwin,x86_64-apple-darwin

- name: Restore SwiftPM dependencies
uses: actions/cache@v6
- name: Prepare verified dependency caches
uses: ./.github/actions/prepare-macos-dependency-cache
with:
path: |
.build/checkouts
.build/repositories
~/.cache/org.swift.swiftpm
key: swiftpm-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }}

- name: Restore Cargo dependencies
uses: actions/cache@v6
with:
path: |
~/.cargo/git
~/.cargo/registry
key: cargo-dependencies-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock') }}
swiftpm: "true"
cargo: "true"

- name: Check packaging scripts and metadata
shell: zsh {0}
Expand Down
10 changes: 3 additions & 7 deletions .github/workflows/ci-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,10 @@ jobs:
with:
swift-version: "6.2"

- name: Restore SwiftPM dependencies
uses: actions/cache@v6
- name: Prepare verified SwiftPM cache
uses: ./.github/actions/prepare-macos-dependency-cache
with:
path: |
.build/checkouts
.build/repositories
~/.cache/org.swift.swiftpm
key: swiftpm-${{ runner.os }}-6.2-${{ hashFiles('Package.resolved') }}
swiftpm: "true"

- name: Run plugin-focused Swift tests
timeout-minutes: 12
Expand Down
108 changes: 101 additions & 7 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
with:
fetch-depth: 0

- name: Test dependency cache verification
shell: bash
run: node scripts/test-verify-download-cache.mjs

- name: Resolve comparison base
id: base
env:
Expand Down Expand Up @@ -102,18 +106,100 @@ jobs:
targets: x86_64-pc-windows-msvc

- name: Set up Bun
id: bun
if: needs.changes.outputs.windows == 'true'
uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.12"
bun-version-file: windows/tauri/package.json

- name: Restore Cargo dependencies
- name: Configure isolated dependency caches
shell: pwsh
run: |
"CARGO_HOME=$(Join-Path $env:GITHUB_WORKSPACE '.artifacts/cargo-home')" >> $env:GITHUB_ENV
# Bun's cache and temp directory must share a Windows volume so
# lifecycle shims such as node-gyp.cmd are added to the correct PATH.
"BUN_INSTALL_CACHE_DIR=$(Join-Path $env:GITHUB_WORKSPACE '.artifacts/bun-cache')" >> $env:GITHUB_ENV
"BUN_TMPDIR=$(Join-Path $env:GITHUB_WORKSPACE '.artifacts/bun-tmp')" >> $env:GITHUB_ENV
# The verified cache rejects links, so omit Bun's junction-only index.
"BUN_FEATURE_FLAG_DISABLE_INSTALL_INDEX=1" >> $env:GITHUB_ENV

- name: Resolve Rust cache identity
id: rust-cache
shell: pwsh
run: |
$commit = rustc -Vv |
Select-String '^commit-hash:' |
ForEach-Object { ($_.Line -split ':', 2)[1].Trim() } |
Select-Object -First 1
if ([string]::IsNullOrWhiteSpace($commit)) {
throw "Could not resolve the Rust compiler commit hash."
}
"commit=$commit" >> $env:GITHUB_OUTPUT

- name: Restore Cargo downloads
id: cargo-download-cache
continue-on-error: true
uses: actions/cache@v6
with:
path: |
~/.cargo/git
~/.cargo/registry
key: cargo-dependencies-${{ runner.os }}-${{ hashFiles('rust/Cargo.lock', 'windows/tauri/src-tauri/Cargo.lock') }}
.artifacts/cargo-home/registry/cache
key: lithe-${{ runner.os }}-${{ runner.arch }}-cargo-downloads-v1-${{ hashFiles('rust/Cargo.lock', 'windows/tauri/src-tauri/Cargo.lock') }}
restore-keys: |
lithe-${{ runner.os }}-${{ runner.arch }}-cargo-downloads-v1-

- name: Restore Cargo build outputs
id: cargo-build-cache
continue-on-error: true
uses: actions/cache@v6
with:
path: |
windows/tauri/src-tauri/target/**/.fingerprint
windows/tauri/src-tauri/target/**/build
windows/tauri/src-tauri/target/**/deps
windows/tauri/src-tauri/target/**/incremental
rust/target/**/.fingerprint
rust/target/**/build
rust/target/**/deps
rust/target/**/incremental
key: lithe-${{ runner.os }}-${{ runner.arch }}-cargo-build-v1-x86_64-pc-windows-msvc-${{ steps.rust-cache.outputs.commit }}-${{ hashFiles('rust/Cargo.lock', 'rust/**/Cargo.toml', 'windows/tauri/src-tauri/Cargo.lock', 'windows/tauri/src-tauri/Cargo.toml', 'windows/tauri/crates/**/Cargo.toml', 'windows/tauri/rust-toolchain.toml') }}
restore-keys: |
lithe-${{ runner.os }}-${{ runner.arch }}-cargo-build-v1-x86_64-pc-windows-msvc-${{ steps.rust-cache.outputs.commit }}-

- name: Restore Bun downloads
if: needs.changes.outputs.windows == 'true'
id: bun-download-cache
continue-on-error: true
uses: actions/cache@v6
with:
path: .artifacts/bun-cache
key: lithe-${{ runner.os }}-${{ runner.arch }}-bun-${{ steps.bun.outputs.bun-version }}-v2-${{ hashFiles('windows/tauri/bun.lock') }}
restore-keys: |
lithe-${{ runner.os }}-${{ runner.arch }}-bun-${{ steps.bun.outputs.bun-version }}-v2-

- name: Restore JDTLS downloads
if: needs.changes.outputs.windows == 'true'
id: jdtls-download-cache
continue-on-error: true
uses: actions/cache@v6
with:
path: .artifacts/jdtls-downloads
key: lithe-${{ runner.os }}-${{ runner.arch }}-jdtls-v1-${{ hashFiles('third_party/jdtls/manifest.json') }}

- name: Validate restored caches or fall back
if: always()
shell: pwsh
run: |
$validation = @{
CargoDownloadsOutcome = "${{ steps.cargo-download-cache.outcome }}"
CargoBuildOutcome = "${{ steps.cargo-build-cache.outcome }}"
CargoBuildHit = "${{ steps.cargo-build-cache.outputs.cache-hit }}"
BunOutcome = "${{ steps.bun-download-cache.outcome }}"
JdtlsOutcome = "${{ steps.jdtls-download-cache.outcome }}"
}
if ("${{ needs.changes.outputs.windows }}" -eq "true") {
$validation.IncludeWindowsAssets = $true
}
./scripts/validate-windows-build-caches.ps1 @validation

- name: Build Windows Tauri application
if: needs.changes.outputs.windows == 'true'
Expand All @@ -128,12 +214,20 @@ jobs:
- name: Test shared Rust Core
if: needs.changes.outputs.rust_core == 'true'
shell: pwsh
run: cargo test --manifest-path rust/Cargo.toml -p lithe-core
run: |
./scripts/invoke-cargo-with-cache-fallback.ps1 `
-TargetDirectory "rust/target" `
-FailureMessage "Shared Rust Core tests failed" `
-CargoArguments @("test", "--manifest-path", "rust/Cargo.toml", "-p", "lithe-core")

- name: Test Windows Rust host
if: needs.changes.outputs.windows_rust == 'true'
shell: pwsh
run: cargo test --manifest-path windows/tauri/src-tauri/Cargo.toml
run: |
./scripts/invoke-cargo-with-cache-fallback.ps1 `
-TargetDirectory "windows/tauri/src-tauri/target" `
-FailureMessage "Windows Rust host tests failed" `
-CargoArguments @("test", "--manifest-path", "windows/tauri/src-tauri/Cargo.toml")

gate:
name: Windows CI gate
Expand Down
Loading
Loading