Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(ci): prefer s3 sccache on windows and keep rust caches warm

t8y21d88de553578
diff --git a/.github/scripts/ci-workflow.test.mjs b/.github/scripts/ci-workflow.test.mjs
index 2e3e0b689c..2bfbec2a95 100644
--- a/.github/scripts/ci-workflow.test.mjs
+++ b/.github/scripts/ci-workflow.test.mjs
@@ -306,7 +306,8 @@ test("local Rust entrypoints and live TDengine tests use nextest", () => {
test("DuckDB Windows builds persist Rust and C++ compiler results", () => {
const content = job("duckdb-windows-driver");
- assert.ok(content.includes('SCCACHE_GHA_ENABLED: "true"'));
+ // S3 is preferred over the quota-limited GHA backend; GHA remains the fallback.
+ assert.ok(content.includes("SCCACHE_GHA_ENABLED: ${{ secrets.SCCACHE_S3_BUCKET == '' && 'true' || 'false' }}"));
assert.ok(content.includes('CC: "sccache cl.exe"'));
assert.ok(content.includes('CXX: "sccache cl.exe"'));
assert.ok(content.includes("0b201ec74fa43914dc39ae48a89fd1d8cb592756"));
@@ -318,7 +319,7 @@ test("Windows compatibility jobs cache Rust compilation without wrapping C or C+
const standard = job("windows-standard-check");
assert.ok(standard.includes("needs.changes.outputs.windows_standard == 'true'"));
assert.ok(standard.includes("RUSTC_WRAPPER: sccache"));
- assert.ok(standard.includes('SCCACHE_GHA_ENABLED: "true"'));
+ assert.ok(standard.includes("SCCACHE_GHA_ENABLED: ${{ secrets.SCCACHE_S3_BUCKET == '' && 'true' || 'false' }}"));
assert.ok(standard.includes("SCCACHE_GHA_VERSION: windows-standard-v1"));
assert.ok(standard.includes("fc920bf0ec8de6ee65d409111f7ec508035751ba"));
assert.ok(standard.includes('version: "v0.16.0"'));
@@ -328,7 +329,7 @@ test("Windows compatibility jobs cache Rust compilation without wrapping C or C+
const win7 = job("windows-win7-bundle");
assert.ok(win7.includes("needs.changes.outputs.windows_win7_bundle == 'true'"));
assert.doesNotMatch(win7, /x86_64-pc-windows-msvc|Setup Rust for standard Windows/);
- for (const setting of ["RUSTC_WRAPPER: sccache", 'SCCACHE_GHA_ENABLED: "true"', "SCCACHE_GHA_VERSION: win7-webview2-1.0.902.49-v1", 'SCCACHE_IDLE_TIMEOUT: "0"', 'CARGO_PROFILE_RELEASE_LTO: "off"', 'CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "8"']) assert.ok(win7.includes(setting));
+ for (const setting of ["RUSTC_WRAPPER: sccache", "SCCACHE_GHA_ENABLED: ${{ secrets.SCCACHE_S3_BUCKET == '' && 'true' || 'false' }}", "SCCACHE_GHA_VERSION: win7-webview2-1.0.902.49-v1", 'SCCACHE_IDLE_TIMEOUT: "0"', 'CARGO_PROFILE_RELEASE_LTO: "off"', 'CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "8"']) assert.ok(win7.includes(setting));
assert.ok(win7.includes("fc920bf0ec8de6ee65d409111f7ec508035751ba"));
assert.ok(win7.includes('version: "v0.16.0"'));
assert.ok(win7.includes("sccache --show-stats"));
diff --git a/.github/workflows/cache-keepalive.yml b/.github/workflows/cache-keepalive.yml
new file mode 100644
index 0000000000..a3355228ee
--- /dev/null
+++ b/.github/workflows/cache-keepalive.yml
@@ -0,0 +1,175 @@
+name: Cache Keepalive
+
+# The shared Linux target caches (rust-test / packages / fmt-clippy, ~2-3 GB
+# each) are only saved from main runs. When the changes filter skips those
+# jobs for a few days, the entries go idle and GitHub's 10 GB LRU quota
+# evicts them, forcing fully cold builds for every PR (including fork PRs
+# that cannot access the S3 sccache backend). This workflow periodically
+# refreshes the main-saved caches on schedule.
+
+on:
+ schedule:
+ # Every Tuesday 01:30 UTC, ahead of typical PR activity hours.
+ - cron: "30 1 * * 2"
+ workflow_dispatch:
+
+permissions:
+ actions: write
+ contents: read
+
+concurrency:
+ group: cache-keepalive
+ cancel-in-progress: false
+
+env:
+ RUSTFLAGS: -C debuginfo=line-tables-only
+
+jobs:
+ rust-test-keepalive:
+ runs-on: ubuntu-24.04
+ timeout-minutes: 60
+ env:
+ # sccache cannot reuse Cargo incremental artifacts, so avoid generating them in CI.
+ CARGO_INCREMENTAL: "0"
+ # Deep async export tests exceed the Rust test harness's default thread stack on Linux.
+ RUST_MIN_STACK: 8388608
+ RUSTC_WRAPPER: sccache
+ # "workspace" matches the full-coverage matrix group used on main pushes.
+ RUST_TEST_GROUP: workspace
+ RUST_FEATURE_MODE: full
+ steps:
+ - uses: actions/checkout@v7
+
+ - name: Install system dependencies
+ run: |
+ sudo timeout --kill-after=30s 10m apt-get \
+ -o Acquire::Retries=3 \
+ -o Acquire::http::Timeout=30 \
+ -o Acquire::https::Timeout=30 \
+ update
+ sudo timeout --kill-after=30s 10m apt-get \
+ -o Acquire::Retries=3 \
+ -o Acquire::http::Timeout=30 \
+ -o Acquire::https::Timeout=30 \
+ install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev libsecret-1-dev
+
+ # Pin mold because runner image updates can change bundled C++ links.
+ # See the ci.yml rust-test note for the pinned upstream build.
+ - name: Install mold linker
+ run: |
+ curl -fsSL https://github.com/rui314/mold/releases/download/v2.42.1/mold-2.42.1-x86_64-linux.tar.gz \
+ | sudo tar -C /usr/local --strip-components=1 -xz
+ mold --version
+
+ - name: Setup Rust
+ uses: dtolnay/[email protected]
+
+ - name: Setup sccache
+ uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
+ with:
+ version: "v0.16.0"
+
+ # Mirrors the ci.yml rust-test configuration: S3 when secrets are
+ # available (they are on schedule runs), otherwise no cross-run caching.
+ - name: Configure sccache
+ shell: bash
+ env:
+ CACHE_BUCKET: ${{ secrets.SCCACHE_S3_BUCKET }}
+ CACHE_ENDPOINT: ${{ secrets.SCCACHE_S3_ENDPOINT }}
+ CACHE_REGION: ${{ secrets.SCCACHE_S3_REGION }}
+ CACHE_KEY_PREFIX: ${{ secrets.SCCACHE_S3_KEY_PREFIX }}
+ CACHE_ACCESS_KEY_ID: ${{ secrets.SCCACHE_S3_ACCESS_KEY_ID }}
+ CACHE_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_S3_SECRET_ACCESS_KEY }}
+ run: |
+ {
+ if [[ -n "$CACHE_BUCKET" ]]; then
+ echo "SCCACHE_BUCKET=${CACHE_BUCKET}"
+ echo "SCCACHE_ENDPOINT=${CACHE_ENDPOINT}"
+ echo "SCCACHE_REGION=${CACHE_REGION}"
+ echo "SCCACHE_S3_KEY_PREFIX=${CACHE_KEY_PREFIX}"
+ echo "SCCACHE_S3_USE_SSL=true"
+ echo "AWS_ACCESS_KEY_ID=${CACHE_ACCESS_KEY_ID}"
+ echo "AWS_SECRET_ACCESS_KEY=${CACHE_SECRET_ACCESS_KEY}"
+ fi
+ # Keep the server alive through post-compile test/lint phases so
+ # "Show sccache stats" reflects the real counters.
+ echo "SCCACHE_IDLE_TIMEOUT=0"
+ # Also cache the C/C++ compilation of -sys crates. These jobs are
+ # native Linux builds, so plain CC/CXX select the target compiler.
+ echo "CC=${SCCACHE_PATH} cc"
+ echo "CXX=${SCCACHE_PATH} c++"
+ } >> "$GITHUB_ENV"
+
+ # Same key recipe as ci.yml rust-test so the restored/saved entry is the
+ # one PR jobs look up. save-if is satisfied: scheduled runs are on main.
+ - name: Rust cache
+ env:
+ RUST_FEATURE_MODE: ""
+ RUST_TEST_GROUP: ""
+ uses: swatinem/rust-cache@v2
+ with:
+ prefix-key: v1-rust-complete
+ workspaces: "./ -> target"
+ shared-key: ci-rust-test-v2-x86_64-unknown-linux-gnu
+ # Test linking dominates this job and sccache cannot cache those crate types.
+ cache-workspace-crates: true
+ cache-on-failure: false
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+
+ - name: Install nextest
+ uses: taiki-e/install-action@a3324fb0eb94b8230ec968c3389c1b7929fc2f3b # v2.68.13
+ with:
+
+ # mold -run wraps the whole process tree (see the ci.yml rust-test note).
+ - name: Nextest
+ run: |-
+ mold -run node .github/scripts/ci-rust.mjs test "$RUST_TEST_GROUP" "$RUST_FEATURE_MODE"
+
+ - name: Rust doc tests
+ run: |-
+ mold -run node .github/scripts/ci-rust.mjs doctest "$RUST_TEST_GROUP" "$RUST_FEATURE_MODE"
+
+ - name: Show sccache stats
+ if: always()
+ continue-on-error: true
+ run: ${SCCACHE_PATH} --show-stats
+
+ prune-sccache-entries:
+ runs-on: ubuntu-24.04
+ timeout-minutes: 15
+ steps:
+ - name: Prune stale sccache GHA cache entries
+ shell: bash
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ set -euo pipefail
+ # The Windows jobs only enable the GHA sccache backend when S3
+ # secrets are absent, but release workflows can still accumulate
+ # thousands of small sccache/* entries that crowd the 10 GB quota.
+ # The GHA backend keys on content hash, so entries nobody touched
+ # for a week can be dropped without losing reachable warm caches.
+ cutoff_days=7
+ cutoff=$(date -u -d "-${cutoff_days} days" +%s)
+ page=1
+ ids=()
+ while :; do
+ resp=$(gh api "repos/${GITHUB_REPOSITORY}/actions/caches?key=sccache&per_page=100&page=${page}")
+ count=$(printf '%s' "$resp" | jq '.actions_caches | length')
+ [[ "$count" -eq 0 ]] && break
+ while read -r id accessed; do
+ [[ "$(date -u -d "$accessed" +%s)" -lt "$cutoff" ]] || continue
+ ids+=("$id")
+ done < <(printf '%s' "$resp" | jq -r '.actions_caches[] | "\(.id) \(.last_accessed_at)"')
+ page=$((page + 1))
+ done
+ # Collect first, delete after: removing entries mid-pagination would
+ # shift later pages and skip candidates.
+ pruned=0
+ for id in "${ids[@]}"; do
+ if gh api -X DELETE "repos/${GITHUB_REPOSITORY}/actions/caches/${id}"; then
+ pruned=$((pruned + 1))
+ fi
+ done
+ echo "Pruned ${pruned} sccache cache entries idle for over ${cutoff_days} days."
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index a2c0384cde..6b76102828 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -308,7 +308,9 @@ jobs:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: -C debuginfo=line-tables-only -C target-feature=+crt-static
RUSTC_WRAPPER: sccache
- SCCACHE_GHA_ENABLED: "true"
+ # Prefer S3 when available; GitHub's 10 GB cache quota evicts the shared
+ # Linux target caches when thousands of GHA sccache entries pile up.
+ SCCACHE_GHA_ENABLED: ${{ secrets.SCCACHE_S3_BUCKET == '' && 'true' || 'false' }}
SCCACHE_GHA_VERSION: windows-standard-v1
steps:
- uses: actions/checkout@v7
@@ -320,6 +322,30 @@ jobs:
with:
version: "v0.16.0"
+ - name: Configure S3 sccache
+ if: env.SCCACHE_GHA_ENABLED != 'true'
+ shell: bash
+ env:
+ CACHE_BUCKET: ${{ secrets.SCCACHE_S3_BUCKET }}
+ CACHE_ENDPOINT: ${{ secrets.SCCACHE_S3_ENDPOINT }}
+ CACHE_REGION: ${{ secrets.SCCACHE_S3_REGION }}
+ CACHE_KEY_PREFIX: ${{ secrets.SCCACHE_S3_KEY_PREFIX }}
+ CACHE_ACCESS_KEY_ID: ${{ secrets.SCCACHE_S3_ACCESS_KEY_ID }}
+ CACHE_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_S3_SECRET_ACCESS_KEY }}
+ run: |
+ {
+ echo "SCCACHE_BUCKET=${CACHE_BUCKET}"
+ echo "SCCACHE_ENDPOINT=${CACHE_ENDPOINT}"
+ echo "SCCACHE_REGION=${CACHE_REGION}"
+ echo "SCCACHE_S3_KEY_PREFIX=${CACHE_KEY_PREFIX}"
+ echo "SCCACHE_S3_USE_SSL=true"
+ echo "AWS_ACCESS_KEY_ID=${CACHE_ACCESS_KEY_ID}"
+ echo "AWS_SECRET_ACCESS_KEY=${CACHE_SECRET_ACCESS_KEY}"
+ # Keep the server alive through post-compile checks so
+ # "Show sccache stats" reflects the real counters.
+ echo "SCCACHE_IDLE_TIMEOUT=0"
+ } >> "$GITHUB_ENV"
+
- name: Check standard Windows dependency path
run: cargo check --locked --package dbx --no-default-features --target x86_64-pc-windows-msvc
@@ -339,7 +365,9 @@ jobs:
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "8"
RUSTFLAGS: -C debuginfo=line-tables-only -C target-feature=+crt-static
RUSTC_WRAPPER: sccache
- SCCACHE_GHA_ENABLED: "true"
+ # Prefer S3 when available; GitHub's 10 GB cache quota evicts the shared
+ # Linux target caches when thousands of GHA sccache entries pile up.
+ SCCACHE_GHA_ENABLED: ${{ secrets.SCCACHE_S3_BUCKET == '' && 'true' || 'false' }}
SCCACHE_GHA_VERSION: win7-webview2-1.0.902.49-v1
SCCACHE_IDLE_TIMEOUT: "0"
# Single source for the job's nightly pin: the toolchain step and the
@@ -372,6 +400,27 @@ jobs:
with:
version: "v0.16.0"
+ - name: Configure S3 sccache
+ if: env.SCCACHE_GHA_ENABLED != 'true'
+ shell: bash
+ env:
+ CACHE_BUCKET: ${{ secrets.SCCACHE_S3_BUCKET }}
+ CACHE_ENDPOINT: ${{ secrets.SCCACHE_S3_ENDPOINT }}
+ CACHE_REGION: ${{ secrets.SCCACHE_S3_REGION }}
+ CACHE_KEY_PREFIX: ${{ secrets.SCCACHE_S3_KEY_PREFIX }}
+ CACHE_ACCESS_KEY_ID: ${{ secrets.SCCACHE_S3_ACCESS_KEY_ID }}
+ CACHE_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_S3_SECRET_ACCESS_KEY }}
+ run: |
+ {
+ echo "SCCACHE_BUCKET=${CACHE_BUCKET}"
+ echo "SCCACHE_ENDPOINT=${CACHE_ENDPOINT}"
+ echo "SCCACHE_REGION=${CACHE_REGION}"
+ echo "SCCACHE_S3_KEY_PREFIX=${CACHE_KEY_PREFIX}"
+ echo "SCCACHE_S3_USE_SSL=true"
+ echo "AWS_ACCESS_KEY_ID=${CACHE_ACCESS_KEY_ID}"
+ echo "AWS_SECRET_ACCESS_KEY=${CACHE_SECRET_ACCESS_KEY}"
+ } >> "$GITHUB_ENV"
+
- name: Restore prebuilt Win7 AWS-LC
id: aws-lc-cache
uses: actions/cache@v4
@@ -728,7 +777,9 @@ jobs:
CARGO_TARGET_DIR: ${{ github.workspace }}/target/duckdb-driver
RUSTFLAGS: -C debuginfo=line-tables-only -C target-feature=+crt-static
RUSTC_WRAPPER: sccache
- SCCACHE_GHA_ENABLED: "true"
+ # Prefer S3 when available; GitHub's 10 GB cache quota evicts the shared
+ # Linux target caches when thousands of GHA sccache entries pile up.
+ SCCACHE_GHA_ENABLED: ${{ secrets.SCCACHE_S3_BUCKET == '' && 'true' || 'false' }}
SCCACHE_GHA_VERSION: duckdb-windows-v1
# libduckdb-sys uses cc-rs for its bundled C++ sources.
CC: "sccache cl.exe"
@@ -755,6 +806,27 @@ jobs:
with:
version: "v0.16.0"
+ - name: Configure S3 sccache
+ if: env.SCCACHE_GHA_ENABLED != 'true'
+ shell: bash
+ env:
+ CACHE_BUCKET: ${{ secrets.SCCACHE_S3_BUCKET }}
+ CACHE_ENDPOINT: ${{ secrets.SCCACHE_S3_ENDPOINT }}
+ CACHE_REGION: ${{ secrets.SCCACHE_S3_REGION }}
+ CACHE_KEY_PREFIX: ${{ secrets.SCCACHE_S3_KEY_PREFIX }}
+ CACHE_ACCESS_KEY_ID: ${{ secrets.SCCACHE_S3_ACCESS_KEY_ID }}
+ CACHE_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_S3_SECRET_ACCESS_KEY }}
+ run: |
+ {
+ echo "SCCACHE_BUCKET=${CACHE_BUCKET}"
+ echo "SCCACHE_ENDPOINT=${CACHE_ENDPOINT}"
+ echo "SCCACHE_REGION=${CACHE_REGION}"
+ echo "SCCACHE_S3_KEY_PREFIX=${CACHE_KEY_PREFIX}"
+ echo "SCCACHE_S3_USE_SSL=true"
+ echo "AWS_ACCESS_KEY_ID=${CACHE_ACCESS_KEY_ID}"
+ echo "AWS_SECRET_ACCESS_KEY=${CACHE_SECRET_ACCESS_KEY}"
+ } >> "$GITHUB_ENV"
+
- name: Build DuckDB Windows driver
shell: pwsh
working-directory: agents/drivers/duckdb
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 0f37b1a927..c3dadfa3d5 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -581,7 +581,7 @@ jobs:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: -C debuginfo=line-tables-only -C target-feature=+crt-static
RUSTC_WRAPPER: sccache
- SCCACHE_GHA_ENABLED: "true"
+ SCCACHE_GHA_ENABLED: ${{ secrets.SCCACHE_S3_BUCKET == '' && 'true' || 'false' }}
SCCACHE_GHA_VERSION: win7-webview2-1.0.902.49-v1
SCCACHE_IDLE_TIMEOUT: "0"
VSIGN_CERT_HASH: ${{ vars.VSIGN_CERT_HASH }}
@@ -612,6 +612,27 @@ jobs:
with:
version: "v0.16.0"
+ - name: Configure S3 sccache
+ if: env.SCCACHE_GHA_ENABLED != 'true'
+ shell: bash
+ env:
+ CACHE_BUCKET: ${{ secrets.SCCACHE_S3_BUCKET }}
+ CACHE_ENDPOINT: ${{ secrets.SCCACHE_S3_ENDPOINT }}
+ CACHE_REGION: ${{ secrets.SCCACHE_S3_REGION }}
+ CACHE_KEY_PREFIX: ${{ secrets.SCCACHE_S3_KEY_PREFIX }}
+ CACHE_ACCESS_KEY_ID: ${{ secrets.SCCACHE_S3_ACCESS_KEY_ID }}
+ CACHE_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_S3_SECRET_ACCESS_KEY }}
+ run: |
+ {
+ echo "SCCACHE_BUCKET=${CACHE_BUCKET}"
+ echo "SCCACHE_ENDPOINT=${CACHE_ENDPOINT}"
+ echo "SCCACHE_REGION=${CACHE_REGION}"
+ echo "SCCACHE_S3_KEY_PREFIX=${CACHE_KEY_PREFIX}"
+ echo "SCCACHE_S3_USE_SSL=true"
+ echo "AWS_ACCESS_KEY_ID=${CACHE_ACCESS_KEY_ID}"
+ echo "AWS_SECRET_ACCESS_KEY=${CACHE_SECRET_ACCESS_KEY}"
+ } >> "$GITHUB_ENV"
+
- name: Prepare Win7-compatible WebView2 loader
shell: pwsh
run: ./.github/scripts/prepare-webview2-win7-loader.ps1