Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

ci(engine): make ccache effective on GitHub-hosted runners and report it

Akarshan Biswasc3dff169c0d2
diff --git a/.github/actions/setup-engine-toolchain/action.yml b/.github/actions/setup-engine-toolchain/action.yml
index afa5630c4..71c6ebeb6 100644
--- a/.github/actions/setup-engine-toolchain/action.yml
+++ b/.github/actions/setup-engine-toolchain/action.yml
@@ -27,9 +27,8 @@ runs:
shell: bash
run: echo "JAN_ENGINE_VARIANT=${{ inputs.variant }}" >> "$GITHUB_ENV"
- # The cache lives outside the workspace, which is re-cloned per run. Nothing
- # is saved or restored through actions/cache: the runner's disk persists, so
- # a hit costs no upload and survives across workflows.
+ # Outside the workspace, which is re-cloned per run. NOHASHDIR because cmake
+ # runs under cargo's hashed OUT_DIR, which would otherwise key every object.
- name: Point ccache at the runner's persistent cache
shell: bash
run: |
@@ -39,6 +38,34 @@ runs:
echo "CCACHE_DIR=${HOME}/.ccache" >> "$GITHUB_ENV"
fi
echo "CCACHE_MAXSIZE=${{ inputs.ccache-max }}" >> "$GITHUB_ENV"
+ echo "CCACHE_NOHASHDIR=1" >> "$GITHUB_ENV"
+
+ # GitHub-hosted images have no ccache and no persistent disk.
+ - name: Install ccache
+ if: runner.environment == 'github-hosted'
+ shell: bash
+ run: |
+ if command -v ccache >/dev/null 2>&1; then
+ echo "engine toolchain: ccache already on the image"
+ exit 0
+ fi
+ case "$RUNNER_OS" in
+ Linux) sudo apt-get update && sudo apt-get install -y ccache ;;
+ macOS) brew install ccache ;;
+ Windows) choco install ccache -y --no-progress ;;
+ esac
+
+ # build.rs holds the llama.cpp pin and cmake flags; the sha suffix makes
+ # every run save, since actions/cache writes only on an exact-key miss.
+ - name: Restore the ccache directory
+ if: runner.environment == 'github-hosted'
+ uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
+ with:
+ path: ${{ env.CCACHE_DIR }}
+ key: ccache-${{ runner.os }}-${{ inputs.variant }}-${{ hashFiles('src-tauri/plugins/tauri-plugin-llamacpp/build.rs') }}-${{ github.sha }}
+ restore-keys: |
+ ccache-${{ runner.os }}-${{ inputs.variant }}-${{ hashFiles('src-tauri/plugins/tauri-plugin-llamacpp/build.rs') }}-
+ ccache-${{ runner.os }}-${{ inputs.variant }}-
# No GitHub-hosted image ships a Vulkan shader compiler, and the desktop
# templates default to the vulkan variant on one. Guarded on glslc rather
@@ -105,6 +132,9 @@ runs:
# Asserts the image, not the steps above: a mis-provisioned runner fails
# here in seconds instead of five minutes into `make build`.
+ # Stats zeroed so the post-build report covers this build only.
- name: Verify the toolchain
shell: bash
- run: make check-engine-toolchain
+ run: |
+ if command -v ccache >/dev/null 2>&1; then ccache -z; fi
+ make check-engine-toolchain
diff --git a/.github/workflows/engine-build.yml b/.github/workflows/engine-build.yml
index 89f41999f..067fac2df 100644
--- a/.github/workflows/engine-build.yml
+++ b/.github/workflows/engine-build.yml
@@ -140,6 +140,12 @@ jobs:
- name: Compile the engine-gated test suites
run: make check-engine-tests
+ - name: Report ccache statistics
+ if: success() || failure()
+ shell: bash
+ run: |
+ if command -v ccache >/dev/null 2>&1; then ccache -s; else echo "ccache not available"; fi
+
# --version proves the worker starts and resolves libggml through the
# rpath; --list-devices additionally exercises the shim and the pinned
# llama.cpp assert. Device enumeration is best-effort because a headless
diff --git a/.github/workflows/template-tauri-build-linux-x64.yml b/.github/workflows/template-tauri-build-linux-x64.yml
index 4cb4fc809..862fa08fe 100644
--- a/.github/workflows/template-tauri-build-linux-x64.yml
+++ b/.github/workflows/template-tauri-build-linux-x64.yml
@@ -225,6 +225,13 @@ jobs:
AUTO_UPDATER_DISABLED: ${{ inputs.disable_updater && 'true' || 'false' }}
JAN_SIGNING_KEY: ${{ secrets.JAN_SIGNING_KEY }}
TAURI_TRAY: libappindicator3
+
+ - name: Report ccache statistics
+ if: success() || failure()
+ shell: bash
+ run: |
+ if command -v ccache >/dev/null 2>&1; then ccache -s; else echo "ccache not available"; fi
+
# Publish app
# tauri reports a linuxdeploy failure as `failed to run linuxdeploy` and
diff --git a/.github/workflows/template-tauri-build-macos.yml b/.github/workflows/template-tauri-build-macos.yml
index a5437a180..3080ffe45 100644
--- a/.github/workflows/template-tauri-build-macos.yml
+++ b/.github/workflows/template-tauri-build-macos.yml
@@ -222,6 +222,12 @@ jobs:
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
JAN_SIGNING_KEY: ${{ secrets.JAN_SIGNING_KEY }}
+ - name: Report ccache statistics
+ if: success() || failure()
+ shell: bash
+ run: |
+ if command -v ccache >/dev/null 2>&1; then ccache -s; else echo "ccache not available"; fi
+
# The engine build is fifteen minutes of cmake whose output cargo only
# surfaces as a tail. When it fails, the whole log is the artifact worth
# having.
diff --git a/.github/workflows/template-tauri-build-windows-x64.yml b/.github/workflows/template-tauri-build-windows-x64.yml
index 17c8fc011..c70e61a55 100644
--- a/.github/workflows/template-tauri-build-windows-x64.yml
+++ b/.github/workflows/template-tauri-build-windows-x64.yml
@@ -276,6 +276,12 @@ jobs:
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
JAN_SIGNING_KEY: ${{ secrets.JAN_SIGNING_KEY }}
+ - name: Report ccache statistics
+ if: success() || failure()
+ shell: bash
+ run: |
+ if command -v ccache >/dev/null 2>&1; then ccache -s; else echo "ccache not available"; fi
+
# The engine build is fifteen minutes of cmake whose output cargo only
# surfaces as a tail. When it fails, the whole log is the artifact worth
# having.