|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +name: SDK Proto Sync |
| 5 | + |
| 6 | +on: |
| 7 | + schedule: |
| 8 | + - cron: "0 6 * * *" |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +env: |
| 12 | + MISE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 13 | + |
| 14 | +permissions: |
| 15 | + actions: read |
| 16 | + contents: read |
| 17 | + packages: read |
| 18 | + issues: write |
| 19 | + |
| 20 | +concurrency: |
| 21 | + group: sdk-proto-sync |
| 22 | + cancel-in-progress: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + sdk_sync_check: |
| 26 | + name: Sync Check |
| 27 | + runs-on: linux-amd64-cpu8 |
| 28 | + container: |
| 29 | + image: ghcr.io/nvidia/openshell/ci:latest |
| 30 | + credentials: |
| 31 | + username: ${{ github.actor }} |
| 32 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + outputs: |
| 34 | + go_drift_report: ${{ steps.go_drift.outputs.report }} |
| 35 | + go_has_drift: ${{ steps.go_drift.outputs.has_drift }} |
| 36 | + go_build_report: ${{ steps.go_build.outputs.report }} |
| 37 | + go_build_failed: ${{ steps.go_build.outputs.build_failed || 'false' }} |
| 38 | + ts_drift_report: ${{ steps.ts_drift.outputs.report }} |
| 39 | + ts_has_drift: ${{ steps.ts_drift.outputs.has_drift }} |
| 40 | + ts_build_report: ${{ steps.ts_build.outputs.report }} |
| 41 | + ts_build_failed: ${{ steps.ts_build.outputs.build_failed || 'false' }} |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 44 | + |
| 45 | + - name: Install tools |
| 46 | + run: mise install --locked |
| 47 | + |
| 48 | + - name: Check Go proto drift |
| 49 | + id: go_drift |
| 50 | + run: | |
| 51 | + REPORT=$(mise run go:proto:drift 2>"$RUNNER_TEMP/go_drift_stderr.log") || true |
| 52 | + if echo "$REPORT" | jq -e '.synced' >/dev/null 2>&1; then |
| 53 | + SYNCED=$(echo "$REPORT" | jq -r '.synced') |
| 54 | + { |
| 55 | + echo "report<<REPORT_EOF" |
| 56 | + echo "$REPORT" |
| 57 | + echo "REPORT_EOF" |
| 58 | + } >> "$GITHUB_OUTPUT" |
| 59 | + [ "$SYNCED" = "true" ] && echo "has_drift=false" >> "$GITHUB_OUTPUT" || echo "has_drift=true" >> "$GITHUB_OUTPUT" |
| 60 | + else |
| 61 | + echo "::error::Go proto drift check failed" |
| 62 | + echo "stderr: $(cat "$RUNNER_TEMP/go_drift_stderr.log")" |
| 63 | + echo "report={}" >> "$GITHUB_OUTPUT" |
| 64 | + echo "has_drift=error" >> "$GITHUB_OUTPUT" |
| 65 | + fi |
| 66 | +
|
| 67 | + - name: Go build check |
| 68 | + id: go_build |
| 69 | + if: steps.go_drift.outputs.has_drift == 'true' |
| 70 | + run: | |
| 71 | + REPORT=$(mise run go:proto:build-check 2>"$RUNNER_TEMP/go_build_stderr.log") && BUILD_OK=true || BUILD_OK=false |
| 72 | + if echo "$REPORT" | jq -e '.sdk' >/dev/null 2>&1; then |
| 73 | + { echo "report<<REPORT_EOF"; echo "$REPORT"; echo "REPORT_EOF"; } >> "$GITHUB_OUTPUT" |
| 74 | + else |
| 75 | + echo "stderr: $(cat "$RUNNER_TEMP/go_build_stderr.log")" |
| 76 | + echo "report={}" >> "$GITHUB_OUTPUT" |
| 77 | + fi |
| 78 | + [ "$BUILD_OK" = "true" ] && echo "build_failed=false" >> "$GITHUB_OUTPUT" || echo "build_failed=true" >> "$GITHUB_OUTPUT" |
| 79 | +
|
| 80 | + - name: Check TypeScript proto drift |
| 81 | + id: ts_drift |
| 82 | + run: | |
| 83 | + REPORT=$(mise run sdk:ts:proto:drift 2>"$RUNNER_TEMP/ts_drift_stderr.log") || true |
| 84 | + if echo "$REPORT" | jq -e '.synced' >/dev/null 2>&1; then |
| 85 | + SYNCED=$(echo "$REPORT" | jq -r '.synced') |
| 86 | + { |
| 87 | + echo "report<<REPORT_EOF" |
| 88 | + echo "$REPORT" |
| 89 | + echo "REPORT_EOF" |
| 90 | + } >> "$GITHUB_OUTPUT" |
| 91 | + [ "$SYNCED" = "true" ] && echo "has_drift=false" >> "$GITHUB_OUTPUT" || echo "has_drift=true" >> "$GITHUB_OUTPUT" |
| 92 | + else |
| 93 | + echo "::error::TypeScript proto drift check failed" |
| 94 | + echo "stderr: $(cat "$RUNNER_TEMP/ts_drift_stderr.log")" |
| 95 | + echo "report={}" >> "$GITHUB_OUTPUT" |
| 96 | + echo "has_drift=error" >> "$GITHUB_OUTPUT" |
| 97 | + fi |
| 98 | +
|
| 99 | + - name: TypeScript build check |
| 100 | + id: ts_build |
| 101 | + if: steps.ts_drift.outputs.has_drift == 'true' |
| 102 | + run: | |
| 103 | + REPORT=$(mise run sdk:ts:proto:build-check 2>"$RUNNER_TEMP/ts_build_stderr.log") && BUILD_OK=true || BUILD_OK=false |
| 104 | + if echo "$REPORT" | jq -e '.sdk' >/dev/null 2>&1; then |
| 105 | + { echo "report<<REPORT_EOF"; echo "$REPORT"; echo "REPORT_EOF"; } >> "$GITHUB_OUTPUT" |
| 106 | + else |
| 107 | + echo "stderr: $(cat "$RUNNER_TEMP/ts_build_stderr.log")" |
| 108 | + echo "report={}" >> "$GITHUB_OUTPUT" |
| 109 | + fi |
| 110 | + [ "$BUILD_OK" = "true" ] && echo "build_failed=false" >> "$GITHUB_OUTPUT" || echo "build_failed=true" >> "$GITHUB_OUTPUT" |
| 111 | +
|
| 112 | + issue_management: |
| 113 | + name: Manage Drift Issue (${{ matrix.sdk.name }}) |
| 114 | + needs: sdk_sync_check |
| 115 | + if: always() && needs.sdk_sync_check.result == 'success' |
| 116 | + runs-on: linux-amd64-cpu8 |
| 117 | + container: |
| 118 | + image: ghcr.io/nvidia/openshell/ci:latest |
| 119 | + credentials: |
| 120 | + username: ${{ github.actor }} |
| 121 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 122 | + strategy: |
| 123 | + fail-fast: false |
| 124 | + matrix: |
| 125 | + sdk: |
| 126 | + - name: go |
| 127 | + label: "sdk:go:sync" |
| 128 | + has_drift: ${{ needs.sdk_sync_check.outputs.go_has_drift }} |
| 129 | + build_failed: ${{ needs.sdk_sync_check.outputs.go_build_failed }} |
| 130 | + drift_report: ${{ needs.sdk_sync_check.outputs.go_drift_report }} |
| 131 | + build_report: ${{ needs.sdk_sync_check.outputs.go_build_report }} |
| 132 | + - name: typescript |
| 133 | + label: "sdk:typescript:sync" |
| 134 | + has_drift: ${{ needs.sdk_sync_check.outputs.ts_has_drift }} |
| 135 | + build_failed: ${{ needs.sdk_sync_check.outputs.ts_build_failed }} |
| 136 | + drift_report: ${{ needs.sdk_sync_check.outputs.ts_drift_report }} |
| 137 | + build_report: ${{ needs.sdk_sync_check.outputs.ts_build_report }} |
| 138 | + steps: |
| 139 | + - name: Warn on drift detection error |
| 140 | + if: matrix.sdk.has_drift == 'error' |
| 141 | + run: | |
| 142 | + echo "::error::Drift detection failed for ${{ matrix.sdk.name }} SDK — check the sdk_sync_check job logs" |
| 143 | + exit 1 |
| 144 | +
|
| 145 | + - if: matrix.sdk.has_drift == 'true' && matrix.sdk.build_failed == 'true' |
| 146 | + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 147 | + |
| 148 | + - name: Install tools |
| 149 | + if: matrix.sdk.has_drift == 'true' && matrix.sdk.build_failed == 'true' |
| 150 | + run: mise install --locked |
| 151 | + |
| 152 | + - name: Create or update drift issue |
| 153 | + if: matrix.sdk.has_drift == 'true' && matrix.sdk.build_failed == 'true' |
| 154 | + env: |
| 155 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 156 | + DRIFT_REPORT: ${{ matrix.sdk.drift_report }} |
| 157 | + BUILD_REPORT: ${{ matrix.sdk.build_report }} |
| 158 | + run: | |
| 159 | + RESULT=$(uv run python tasks/scripts/sdk_sync.py manage-issue \ |
| 160 | + --drift-report "${DRIFT_REPORT:-{}}" \ |
| 161 | + --build-report "${BUILD_REPORT:-{}}" \ |
| 162 | + --sdk "${{ matrix.sdk.name }}" \ |
| 163 | + --repo "$GITHUB_REPOSITORY" \ |
| 164 | + --label "${{ matrix.sdk.label }}") |
| 165 | + echo "$RESULT" | jq . |
| 166 | + ACTION=$(echo "$RESULT" | jq -r '.action // "unknown"') |
| 167 | + if [ "$ACTION" = "error" ] || [ "$ACTION" = "unknown" ]; then |
| 168 | + echo "::error::Issue management for ${{ matrix.sdk.name }} failed: $ACTION" |
| 169 | + exit 1 |
| 170 | + fi |
| 171 | +
|
| 172 | + - name: Close resolved drift issue |
| 173 | + if: matrix.sdk.has_drift == 'false' || (matrix.sdk.has_drift == 'true' && matrix.sdk.build_failed == 'false') |
| 174 | + env: |
| 175 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 176 | + run: | |
| 177 | + ISSUE=$(gh issue list --repo "$GITHUB_REPOSITORY" --label "${{ matrix.sdk.label }}" --state open --json number --jq '.[0].number') |
| 178 | + if [ -n "$ISSUE" ]; then |
| 179 | + gh issue close "$ISSUE" --repo "$GITHUB_REPOSITORY" --comment "SDK builds and tests pass after proto regeneration. Closing automatically." |
| 180 | + echo "Closed issue #$ISSUE" |
| 181 | + fi |
0 commit comments