Skip to content

Commit cbd7e60

Browse files
Pigbibicodex
andauthored
fix: publish observed lifecycle after Cloud Run sync (#316)
Co-authored-by: Codex <noreply@openai.com>
1 parent e69554c commit cbd7e60

2 files changed

Lines changed: 40 additions & 1 deletion

File tree

‎.github/workflows/runtime-target-lifecycle.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: Runtime Target Lifecycle
22

33
on:
44
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["Deploy Cloud Run"]
7+
types: [completed]
58
schedule:
69
- cron: "37 * * * *"
710

@@ -164,11 +167,16 @@ jobs:
164167
165168
- name: Publish lifecycle to the unified control plane
166169
if: ${{ steps.lifecycle_ingress.outputs.enabled == 'true' }}
167-
uses: QuantStrategyLab/QuantRuntimeSettings/actions/publish-runtime-target-lifecycle@1eb72e4be2c20f991be5e10153ae046ba0fde496
170+
uses: QuantStrategyLab/QuantRuntimeSettings/actions/publish-runtime-target-lifecycle@c2e46314fd749fd40f4d5fbdbaedadc8b7b27dff
168171
with:
169172
source-id: firstrade.primary
170173
target-id: firstrade.primary
171174
platform: firstrade
175+
observe-gcp: 'true'
176+
gcp-project: ${{ env.GCP_PROJECT_ID }}
177+
cloud-run-region: ${{ env.CLOUD_RUN_REGION }}
178+
cloud-run-service: ${{ env.CLOUD_RUN_SERVICE }}
179+
scheduler-location: ${{ env.RUNTIME_HEARTBEAT_SCHEDULER_LOCATION }}
172180
configured-state: ${{ steps.target_state.outputs.configured_state }}
173181
execution-mode: ${{ steps.target_state.outputs.execution_mode }}
174182
runtime-guard: ${{ steps.runtime_guard.outputs.status }}

‎tests/test_runtime_monitor_workflows.py‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,34 @@ def test_runtime_guard_callers_use_locked_uv_runtime_before_authentication() ->
9494
"google-github-actions/auth@v3"
9595
)
9696
assert setup_python_lines == [f" uses: {setup_python}"]
97+
98+
99+
def test_lifecycle_observes_completed_sync_regardless_of_conclusion() -> None:
100+
workflow = (ROOT / ".github/workflows/runtime-target-lifecycle.yml").read_text()
101+
sync = (ROOT / ".github/workflows/sync-cloud-run-env.yml").read_text()
102+
sync_name = sync.splitlines()[0].removeprefix("name: ")
103+
104+
assert f'workflows: ["{sync_name}"]' in workflow
105+
assert "types: [completed]" in workflow
106+
assert "github.event.workflow_run.conclusion" not in workflow
107+
assert "github.event.workflow_run.head_sha" not in workflow
108+
109+
110+
def test_lifecycle_publishes_read_only_observation_for_exact_service() -> None:
111+
workflow = (ROOT / ".github/workflows/runtime-target-lifecycle.yml").read_text()
112+
publisher = workflow.split("- name: Publish lifecycle to the unified control plane", 1)[1]
113+
publisher = publisher.split("\n - name:", 1)[0]
114+
115+
for line in (
116+
"observe-gcp: 'true'",
117+
"gcp-project: ${{ env.GCP_PROJECT_ID }}",
118+
"cloud-run-region: ${{ env.CLOUD_RUN_REGION }}",
119+
"cloud-run-service: ${{ env.CLOUD_RUN_SERVICE }}",
120+
"scheduler-location: ${{ env.RUNTIME_HEARTBEAT_SCHEDULER_LOCATION }}",
121+
):
122+
assert line in publisher
123+
assert "CLOUD_RUN_SERVICE: ${{ secrets.CLOUD_RUN_SERVICE }}" in workflow
124+
assert "RUNTIME_HEARTBEAT_SCHEDULER_LOCATION: ${{ vars.RUNTIME_HEARTBEAT_SCHEDULER_LOCATION || vars.CLOUD_RUN_REGION || 'us-central1' }}" in workflow
125+
assert "CLOUD_RUN_SERVICES" not in publisher
126+
assert "gcloud scheduler jobs update" not in workflow
127+
assert "gcloud run deploy" not in workflow

0 commit comments

Comments
 (0)