The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Reuse runner gcloud and narrow desktop release checkouts (#640)
Deea7ceddbf6cff
diff --git a/.github/actions/setup-gcloud/action.yml b/.github/actions/setup-gcloud/action.ymlnew file mode 100644index 000000000..384277c94--- /dev/null+++ b/.github/actions/setup-gcloud/action.yml@@ -0,0 +1,16 @@+name: Set up Google Cloud CLI+description: Reuse a working runner installation, then configure the job's federated credentials+runs:+ using: composite+ steps:+ - name: Check the runner's Google Cloud CLI+ id: installed+ shell: bash+ env:+ ACTION_PATH: ${{ github.action_path }}+ run: python3 "$ACTION_PATH/check-installed.py"+ # skip_install only bypasses the download. The upstream action still configures+ # credentials from the preceding google-github-actions/auth step.+ - uses: google-github-actions/setup-gcloud@v2+ with:+ skip_install: ${{ steps.installed.outputs.reusable }}diff --git a/.github/actions/setup-gcloud/check-installed.py b/.github/actions/setup-gcloud/check-installed.pynew file mode 100644index 000000000..becc76267--- /dev/null+++ b/.github/actions/setup-gcloud/check-installed.py@@ -0,0 +1,42 @@+#!/usr/bin/env python3+"""Bound the optional runner SDK probe; unknown installations use normal setup."""+import json+import os+from pathlib import Path+import re+import subprocess++# Conservative floor: the Ubuntu runner SDK exercised by our real GCS publication+# contract. Older installations take the existing latest-version install path.+MIN_VERSION = (586, 0, 0)+PROBE_TIMEOUT_SECONDS = 5+++def installed_version():+ try:+ result = subprocess.run(+ ["gcloud", "version", "--format=json"],+ check=True, capture_output=True, text=True, timeout=PROBE_TIMEOUT_SECONDS,+ )+ data = json.loads(result.stdout)+ except (OSError, subprocess.SubprocessError, ValueError):+ return None+ version = data.get("Google Cloud SDK") if isinstance(data, dict) else None+ if not isinstance(version, str) or not re.fullmatch(r"[0-9]{1,4}\.[0-9]{1,4}\.[0-9]{1,4}", version):+ return None+ return version if tuple(map(int, version.split("."))) >= MIN_VERSION else None+++def main():+ version = installed_version()+ with Path(os.environ["GITHUB_OUTPUT"]).open("a") as output:+ output.write(f"reusable={'true' if version else 'false'}\n")+ # Never forward raw SDK stdout/stderr into logs or Actions output commands.+ if version:+ print(f"Reusing Google Cloud CLI {version}")+ else:+ print("Installing Google Cloud CLI: no working runner installation at or above 586.0.0")+++if __name__ == "__main__":+ main()diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.ymlindex 5d4cb4a2a..d2a532e27 100644--- a/.github/workflows/release-desktop.yml+++ b/.github/workflows/release-desktop.yml@@ -117,6 +117,12 @@ jobs:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v7+ with:+ sparse-checkout: |+ /.github/actions/setup-gcloud/+ /scripts/publish-desktop-manifest.py+ /scripts/verify-desktop-release.py+ sparse-checkout-cone-mode: false# GCP auth, WITHOUT a long-lived key — the same pattern release.yml and production-be-build.yaml# already run. A service-account JSON key is a bearer credential with no expiry: it is only as# safe as every place it has ever been copied to. Workload Identity Federation replaces it with@@ -136,7 +142,7 @@ jobs:with:workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}- - uses: google-github-actions/setup-gcloud@v2+ - uses: ./.github/actions/setup-gcloud- name: Reject a version already published or supersededenv:VERSION: ${{ needs.version.outputs.version }}@@ -325,12 +331,18 @@ jobs:VERSION: ${{ needs.version.outputs.version }}steps:- uses: actions/checkout@v7+ with:+ sparse-checkout: |+ /.github/actions/setup-gcloud/+ /scripts/publish-desktop-manifest.py+ /scripts/verify-desktop-release.py+ sparse-checkout-cone-mode: false- name: Authenticate to GCP (workload identity federation)uses: google-github-actions/auth@v2with:workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}- - uses: google-github-actions/setup-gcloud@v2+ - uses: ./.github/actions/setup-gcloud- name: Merge every platform's key into the manifest in one writerun: |@@ -450,12 +462,16 @@ jobs:if: ${{ always() && needs.version.result == 'success' }}runs-on: ubuntu-lateststeps:+ - uses: actions/checkout@v7+ with:+ sparse-checkout: /.github/actions/setup-gcloud/+ sparse-checkout-cone-mode: false- name: Authenticate to GCP (workload identity federation)uses: google-github-actions/auth@v2with:workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}- - uses: google-github-actions/setup-gcloud@v2+ - uses: ./.github/actions/setup-gcloud- name: Remove the scratch manifestsenv:SCRATCH_PREFIX: ${{ needs.version.outputs.scratch_prefix }}@@ -469,10 +485,20 @@ jobs:timeout-minutes: 10steps:- uses: actions/checkout@v7+ with:+ sparse-checkout: |+ /.github/actions/setup-gcloud/+ /scripts/publish-desktop-manifest.py+ /scripts/verify-desktop-release.py+ /scripts/check-desktop-publication-gcs.py+ /scripts/tests/desktop_publication_fixture.py+ /desktop/scripts/upload-desktop.sh+ /desktop/scripts/upload-desktop-linux.sh+ sparse-checkout-cone-mode: false- uses: google-github-actions/auth@v2with:workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}- - uses: google-github-actions/setup-gcloud@v2+ - uses: ./.github/actions/setup-gcloud- name: Exercise publication against a disposable GCS prefixrun: python3 scripts/check-desktop-publication-gcs.py "$GCS_BUCKET"diff --git a/scripts/tests/test_gcloud_setup.py b/scripts/tests/test_gcloud_setup.pynew file mode 100644index 000000000..1cefd177f--- /dev/null+++ b/scripts/tests/test_gcloud_setup.py@@ -0,0 +1,75 @@+"""A missing or unhealthy runner SDK must retain the normal installation path."""+from contextlib import redirect_stdout+import importlib.util+import io+import json+import os+from pathlib import Path+import subprocess+import tempfile+from types import SimpleNamespace+import unittest+from unittest.mock import patch++ROOT = Path(__file__).resolve().parents[2]+spec = importlib.util.spec_from_file_location(+ "gcloud_setup", ROOT / ".github/actions/setup-gcloud/check-installed.py",+)+setup = importlib.util.module_from_spec(spec)+spec.loader.exec_module(setup)+++class GcloudSetupTests(unittest.TestCase):+ def probe(self, value):+ with patch.object(setup.subprocess, "run", return_value=SimpleNamespace(stdout=json.dumps(value))):+ return setup.installed_version()++ def test_validated_floor_and_newer_versions_are_reused(self):+ for version in ("586.0.0", "586.1.2", "600.0.0"):+ with self.subTest(version=version):+ self.assertEqual(self.probe({"Google Cloud SDK": version}), version)++ def test_older_and_unrecognized_versions_require_installation(self):+ for version in ("585.99.99", "85.0.0", None, 586, "latest", "586.0.0-beta", "586.0.0\nreusable=true"):+ with self.subTest(version=version):+ self.assertIsNone(self.probe({"Google Cloud SDK": version}))+ for value in ({}, [], None, "586.0.0"):+ with self.subTest(value=value):+ self.assertIsNone(self.probe(value))++ def test_malformed_json_requires_installation(self):+ with patch.object(setup.subprocess, "run", return_value=SimpleNamespace(stdout="not JSON")):+ self.assertIsNone(setup.installed_version())++ def test_missing_broken_and_slow_installations_fall_back(self):+ for error in (+ FileNotFoundError(), PermissionError(),+ subprocess.CalledProcessError(1, ["gcloud"], stderr="private diagnostic"),+ subprocess.TimeoutExpired(["gcloud"], 5, stderr="private diagnostic"),+ UnicodeDecodeError("utf-8", b"\xff", 0, 1, "invalid encoding"),+ ):+ with self.subTest(error=type(error).__name__), patch.object(setup.subprocess, "run", side_effect=error):+ self.assertIsNone(setup.installed_version())++ def test_probe_is_bounded_and_captures_diagnostics(self):+ with patch.object(setup.subprocess, "run", return_value=SimpleNamespace(stdout="{}")) as run:+ setup.installed_version()+ run.assert_called_once_with(+ ["gcloud", "version", "--format=json"],+ check=True, capture_output=True, text=True, timeout=5,+ )++ def test_action_output_is_boolean_and_preserves_other_outputs(self):+ for version, expected in (("586.0.0", "true"), (None, "false")):+ with self.subTest(version=version), tempfile.TemporaryDirectory() as directory:+ output = Path(directory) / "output"+ output.write_text("earlier=value\n")+ with patch.dict(os.environ, GITHUB_OUTPUT=str(output)), \+ patch.object(setup, "installed_version", return_value=version), \+ redirect_stdout(io.StringIO()):+ setup.main()+ self.assertEqual(output.read_text(), f"earlier=value\nreusable={expected}\n")+++if __name__ == "__main__":+ unittest.main()