Skip to repository content145 lines · 5.1 KB · text
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T00:29:58.728Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
setup-sccache
1#!/usr/bin/env bash
2
3set -euo pipefail
4
5SCCACHE_VERSION="v0.16.0"
6# Use absolute path to avoid issues with working directory changes between steps
7SCCACHE_DIR="$(pwd)/target/sccache"
8
9install_sccache() {
10 mkdir -p "$SCCACHE_DIR"
11
12 local expected_version="sccache ${SCCACHE_VERSION#v}"
13 local installed_version=""
14 if [[ -x "${SCCACHE_DIR}/sccache" ]]; then
15 if ! installed_version="$("${SCCACHE_DIR}/sccache" --version 2>/dev/null)"; then
16 echo "Cached sccache binary is invalid; reinstalling"
17 installed_version=""
18 fi
19 fi
20
21 if [[ "${installed_version}" == "${expected_version}" ]]; then
22 echo "sccache already cached: ${installed_version}"
23 else
24 if [[ -n "${installed_version}" ]]; then
25 echo "Stopping cached ${installed_version} server before upgrading..."
26 if ! "${SCCACHE_DIR}/sccache" --stop-server &>/dev/null; then
27 echo "No running sccache server to stop"
28 fi
29 fi
30
31 echo "Installing sccache ${SCCACHE_VERSION} from GitHub releases..."
32
33 local os arch archive basename
34 os="$(uname -s)"
35 arch="$(uname -m)"
36
37 case "${os}-${arch}" in
38 Darwin-arm64)
39 archive="sccache-${SCCACHE_VERSION}-aarch64-apple-darwin.tar.gz"
40 ;;
41 Darwin-x86_64)
42 archive="sccache-${SCCACHE_VERSION}-x86_64-apple-darwin.tar.gz"
43 ;;
44 Linux-x86_64)
45 archive="sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz"
46 ;;
47 Linux-aarch64)
48 archive="sccache-${SCCACHE_VERSION}-aarch64-unknown-linux-musl.tar.gz"
49 ;;
50 *)
51 echo "Unsupported platform: ${os}-${arch}"
52 exit 1
53 ;;
54 esac
55
56 basename="${archive%.tar.gz}"
57 curl -fsSL "https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/${archive}" | tar xz
58 mv "${basename}/sccache" "${SCCACHE_DIR}/"
59 rm -rf "${basename}"
60 echo "Installed sccache: $("${SCCACHE_DIR}/sccache" --version)"
61 fi
62
63 # Verify the binary works before adding to path
64 if ! "${SCCACHE_DIR}/sccache" --version &>/dev/null; then
65 echo "ERROR: sccache binary at ${SCCACHE_DIR}/sccache is not executable or corrupted"
66 rm -f "${SCCACHE_DIR}/sccache"
67 exit 1
68 fi
69
70 if [[ -n "${GITHUB_PATH:-}" ]]; then
71 echo "${SCCACHE_DIR}" >> "$GITHUB_PATH"
72 fi
73 export PATH="${SCCACHE_DIR}:${PATH}"
74}
75
76configure_sccache() {
77 if [[ -z "${R2_ACCOUNT_ID:-}" ]]; then
78 echo "R2_ACCOUNT_ID not set, skipping sccache configuration"
79 return
80 fi
81
82 echo "Configuring sccache with Cloudflare R2..."
83
84 local bucket="${SCCACHE_BUCKET:-sccache-zed}"
85 local key_prefix="${SCCACHE_KEY_PREFIX:-sccache/}"
86 local base_dir="${GITHUB_WORKSPACE:-$(pwd)}"
87
88 # Use the absolute path to sccache binary for RUSTC_WRAPPER to avoid
89 # any PATH race conditions between GITHUB_PATH and GITHUB_ENV
90 local sccache_bin="${SCCACHE_DIR}/sccache"
91
92 # Set in current process
93 export SCCACHE_ENDPOINT="https://${R2_ACCOUNT_ID}.r2.cloudflarestorage.com"
94 export SCCACHE_BUCKET="${bucket}"
95 export SCCACHE_REGION="auto"
96 export SCCACHE_S3_KEY_PREFIX="${key_prefix}"
97 export SCCACHE_BASEDIRS="${base_dir}"
98 export AWS_ACCESS_KEY_ID="${R2_ACCESS_KEY_ID}"
99 export AWS_SECRET_ACCESS_KEY="${R2_SECRET_ACCESS_KEY}"
100 export RUSTC_WRAPPER="${sccache_bin}"
101
102 # Also write to GITHUB_ENV for subsequent steps
103 if [[ -n "${GITHUB_ENV:-}" ]]; then
104 {
105 echo "SCCACHE_ENDPOINT=${SCCACHE_ENDPOINT}"
106 echo "SCCACHE_BUCKET=${SCCACHE_BUCKET}"
107 echo "SCCACHE_REGION=${SCCACHE_REGION}"
108 echo "SCCACHE_S3_KEY_PREFIX=${SCCACHE_S3_KEY_PREFIX}"
109 echo "SCCACHE_BASEDIRS=${SCCACHE_BASEDIRS}"
110 echo "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}"
111 echo "AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}"
112 echo "RUSTC_WRAPPER=${RUSTC_WRAPPER}"
113 } >> "$GITHUB_ENV"
114 fi
115
116 echo "✓ sccache configured with Cloudflare R2 (bucket: ${bucket})"
117}
118
119show_config() {
120 echo "=== sccache configuration ==="
121 echo "sccache version: $(sccache --version)"
122 echo "RUSTC_WRAPPER: ${RUSTC_WRAPPER:-<not set>}"
123 echo "SCCACHE_BUCKET: ${SCCACHE_BUCKET:-<not set>}"
124 echo "SCCACHE_ENDPOINT: ${SCCACHE_ENDPOINT:-<not set>}"
125 echo "SCCACHE_REGION: ${SCCACHE_REGION:-<not set>}"
126 echo "SCCACHE_S3_KEY_PREFIX: ${SCCACHE_S3_KEY_PREFIX:-<not set>}"
127 echo "SCCACHE_BASEDIRS: ${SCCACHE_BASEDIRS:-<not set>}"
128 if [[ -n "${AWS_ACCESS_KEY_ID:-}" ]]; then
129 echo "AWS_ACCESS_KEY_ID: <set, length=${#AWS_ACCESS_KEY_ID}>"
130 else
131 echo "AWS_ACCESS_KEY_ID: <not set>"
132 fi
133 if [[ -n "${AWS_SECRET_ACCESS_KEY:-}" ]]; then
134 echo "AWS_SECRET_ACCESS_KEY: <set>"
135 else
136 echo "AWS_SECRET_ACCESS_KEY: <not set>"
137 fi
138 echo "=== sccache stats ==="
139 sccache --show-stats || true
140}
141
142install_sccache
143configure_sccache
144show_config
145