Skip to repository content171 lines · 6.4 KB · text
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T01:26:39.377Z 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.ps1
1#Requires -Version 5.1
2$ErrorActionPreference = "Stop"
3
4$SCCACHE_VERSION = "v0.16.0"
5$SCCACHE_DIR = "./target/sccache"
6
7function Install-Sccache {
8 New-Item -ItemType Directory -Path $SCCACHE_DIR -Force | Out-Null
9
10 $sccachePath = Join-Path $SCCACHE_DIR "sccache.exe"
11 $expectedVersion = "sccache $($SCCACHE_VERSION.Substring(1))"
12 $installedVersion = $null
13 if (Test-Path $sccachePath) {
14 try {
15 $installedVersion = & $sccachePath --version
16 }
17 catch {
18 Write-Host "Cached sccache binary is invalid; reinstalling"
19 $installedVersion = $null
20 }
21 }
22
23 if ($installedVersion -eq $expectedVersion) {
24 Write-Host "sccache already cached: $installedVersion"
25 }
26 else {
27 if ($installedVersion) {
28 Write-Host "Stopping cached $installedVersion server before upgrading..."
29 try {
30 & $sccachePath --stop-server *> $null
31 if ($LASTEXITCODE -ne 0) {
32 Write-Host "No running sccache server to stop"
33 }
34 }
35 catch {
36 Write-Host "No running sccache server to stop"
37 }
38 }
39
40 Write-Host "Installing sccache ${SCCACHE_VERSION} from GitHub releases..."
41
42 $arch = if ([Environment]::Is64BitOperatingSystem) { "x86_64" } else { "i686" }
43 $archive = "sccache-${SCCACHE_VERSION}-${arch}-pc-windows-msvc.zip"
44 $basename = "sccache-${SCCACHE_VERSION}-${arch}-pc-windows-msvc"
45 $url = "https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/${archive}"
46
47 $tempDir = Join-Path $env:TEMP "sccache-install"
48 New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
49
50 try {
51 $archivePath = Join-Path $tempDir $archive
52 Invoke-WebRequest -Uri $url -OutFile $archivePath
53 Expand-Archive -Path $archivePath -DestinationPath $tempDir
54
55 $extractedPath = Join-Path $tempDir $basename "sccache.exe"
56 Move-Item -Path $extractedPath -Destination $sccachePath -Force
57
58 Write-Host "Installed sccache: $(& $sccachePath --version)"
59 }
60 finally {
61 Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
62 }
63 }
64
65 $absolutePath = (Resolve-Path $SCCACHE_DIR).Path
66 if ($env:GITHUB_PATH) {
67 $absolutePath | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
68 }
69 $env:PATH = "$absolutePath;$env:PATH"
70
71 # Verify sccache is available in PATH - fail fast if not
72 $sccacheCmd = Get-Command sccache -ErrorAction SilentlyContinue
73 if (-not $sccacheCmd) {
74 Write-Host "::error::sccache was installed but is not found in PATH"
75 Write-Host "PATH: $env:PATH"
76 Write-Host "Expected location: $absolutePath"
77 if (Test-Path (Join-Path $absolutePath "sccache.exe")) {
78 Write-Host "sccache.exe exists at expected location but is not in PATH"
79 Write-Host "Directory contents:"
80 Get-ChildItem $absolutePath | ForEach-Object { Write-Host " $_" }
81 } else {
82 Write-Host "sccache.exe NOT found at expected location"
83 }
84 exit 1
85 }
86}
87
88function Configure-Sccache {
89 if (-not $env:R2_ACCOUNT_ID) {
90 Write-Host "R2_ACCOUNT_ID not set, skipping sccache configuration"
91 return
92 }
93
94 # Verify sccache is available before configuring
95 $sccacheCmd = Get-Command sccache -ErrorAction SilentlyContinue
96 if (-not $sccacheCmd) {
97 Write-Host "::error::sccache not found in PATH, cannot configure RUSTC_WRAPPER"
98 Write-Host "PATH: $env:PATH"
99 exit 1
100 }
101
102 Write-Host "Configuring sccache with Cloudflare R2..."
103
104 $bucket = if ($env:SCCACHE_BUCKET) { $env:SCCACHE_BUCKET } else { "sccache-zed" }
105 $keyPrefix = if ($env:SCCACHE_KEY_PREFIX) { $env:SCCACHE_KEY_PREFIX } else { "sccache/" }
106 $baseDir = if ($env:GITHUB_WORKSPACE) { $env:GITHUB_WORKSPACE } else { (Get-Location).Path }
107
108 # Use the absolute path to sccache binary for RUSTC_WRAPPER to avoid
109 # any PATH race conditions between GITHUB_PATH and GITHUB_ENV
110 $sccacheBin = (Get-Command sccache).Source
111
112 # Set in current process
113 $env:SCCACHE_ENDPOINT = "https://$($env:R2_ACCOUNT_ID).r2.cloudflarestorage.com"
114 $env:SCCACHE_BUCKET = $bucket
115 $env:SCCACHE_REGION = "auto"
116 $env:SCCACHE_S3_KEY_PREFIX = $keyPrefix
117 $env:SCCACHE_BASEDIRS = $baseDir
118 $env:AWS_ACCESS_KEY_ID = $env:R2_ACCESS_KEY_ID
119 $env:AWS_SECRET_ACCESS_KEY = $env:R2_SECRET_ACCESS_KEY
120 $env:RUSTC_WRAPPER = $sccacheBin
121
122 # Also write to GITHUB_ENV for subsequent steps
123 if ($env:GITHUB_ENV) {
124 @(
125 "SCCACHE_ENDPOINT=$($env:SCCACHE_ENDPOINT)"
126 "SCCACHE_BUCKET=$($env:SCCACHE_BUCKET)"
127 "SCCACHE_REGION=$($env:SCCACHE_REGION)"
128 "SCCACHE_S3_KEY_PREFIX=$($env:SCCACHE_S3_KEY_PREFIX)"
129 "SCCACHE_BASEDIRS=$($env:SCCACHE_BASEDIRS)"
130 "AWS_ACCESS_KEY_ID=$($env:AWS_ACCESS_KEY_ID)"
131 "AWS_SECRET_ACCESS_KEY=$($env:AWS_SECRET_ACCESS_KEY)"
132 "RUSTC_WRAPPER=$($env:RUSTC_WRAPPER)"
133 ) | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
134 }
135
136 Write-Host "✓ sccache configured with Cloudflare R2 (bucket: $bucket)"
137}
138
139function Show-Config {
140 Write-Host "=== sccache configuration ==="
141 Write-Host "sccache version: $(sccache --version)"
142 Write-Host "sccache path: $((Get-Command sccache).Source)"
143 Write-Host "RUSTC_WRAPPER: $($env:RUSTC_WRAPPER ?? '<not set>')"
144 Write-Host "SCCACHE_BUCKET: $($env:SCCACHE_BUCKET ?? '<not set>')"
145 Write-Host "SCCACHE_ENDPOINT: $($env:SCCACHE_ENDPOINT ?? '<not set>')"
146 Write-Host "SCCACHE_REGION: $($env:SCCACHE_REGION ?? '<not set>')"
147 Write-Host "SCCACHE_S3_KEY_PREFIX: $($env:SCCACHE_S3_KEY_PREFIX ?? '<not set>')"
148 Write-Host "SCCACHE_BASEDIRS: $($env:SCCACHE_BASEDIRS ?? '<not set>')"
149
150 if ($env:AWS_ACCESS_KEY_ID) {
151 Write-Host "AWS_ACCESS_KEY_ID: <set>"
152 }
153 else {
154 Write-Host "AWS_ACCESS_KEY_ID: <not set>"
155 }
156
157 if ($env:AWS_SECRET_ACCESS_KEY) {
158 Write-Host "AWS_SECRET_ACCESS_KEY: <set>"
159 }
160 else {
161 Write-Host "AWS_SECRET_ACCESS_KEY: <not set>"
162 }
163
164 Write-Host "=== sccache stats ==="
165 sccache --show-stats
166}
167
168Install-Sccache
169Configure-Sccache
170Show-Config
171