Skip to content

Commit ce5a2be

Browse files
committed
fix(ci): address SDK sync review feedback
Signed-off-by: Ignas Baranauskas <ibaranau@redhat.com>
1 parent 58b59c6 commit ce5a2be

9 files changed

Lines changed: 432 additions & 91 deletions

File tree

‎.github/workflows/sdk-proto-check.yml‎

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,25 @@ jobs:
4141

4242
- id: config
4343
name: Load SDK configuration
44-
run: echo "matrix=$(jq -c '.include' tasks/sdk-sync-config.json)" >> "$GITHUB_OUTPUT"
44+
run: |
45+
MATRIX=$(jq -e -c '
46+
if (.include | type == "array" and length > 0 and all(.[];
47+
type == "object" and
48+
(.name | type == "string") and
49+
(.display_name | type == "string") and
50+
(.bindings_committed | type == "boolean") and
51+
(.no_file_tracking_hint == null or (.no_file_tracking_hint | type == "string")) and
52+
(.generated_bindings_status | type == "string") and
53+
(.label | type == "string") and
54+
(.drift_task | type == "string") and
55+
(.build_check_task | type == "string") and
56+
(.proto_task | type == "string") and
57+
(.build_task | type == "string") and
58+
(.test_task | type == "string") and
59+
(.source_dirs | type == "array" and all(.[]; type == "string"))
60+
)) then .include else error("invalid SDK sync configuration") end
61+
' tasks/sdk-sync-config.json)
62+
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
4563
4664
sdk_proto_drift:
4765
name: Proto Drift (${{ matrix.sdk.name }})
@@ -50,6 +68,7 @@ jobs:
5068
runs-on: linux-amd64-cpu8
5169
timeout-minutes: 15
5270
container:
71+
# Keep this workflow reproducible; update the digest deliberately when the CI image changes.
5372
image: ghcr.io/nvidia/openshell/ci:5b9daab9351b1e053f9a5e0ce4c899f5d3f674b0
5473
credentials:
5574
username: ${{ github.actor }}
@@ -66,22 +85,34 @@ jobs:
6685

6786
- name: Check proto drift
6887
id: drift
88+
env:
89+
DRIFT_TASK: ${{ matrix.sdk.drift_task }}
6990
run: |
70-
REPORT=$(mise run ${{ matrix.sdk.drift_task }} 2>"$RUNNER_TEMP/drift_stderr.log") || true
91+
DRIFT_STATUS=0
92+
REPORT=$(mise run "$DRIFT_TASK" 2>"$RUNNER_TEMP/drift_stderr.log") || DRIFT_STATUS=$?
7193
72-
if echo "$REPORT" | jq -e 'has("synced") and (.synced | type == "boolean")' >/dev/null 2>&1; then
94+
if echo "$REPORT" | jq -e 'type == "object" and has("synced") and (.synced | type == "boolean") and (has("error") | not)' >/dev/null 2>&1; then
7395
SYNCED=$(echo "$REPORT" | jq -r '.synced')
74-
DELIMITER="REPORT_EOF_$(openssl rand -hex 16)"
75-
{
76-
echo "report<<$DELIMITER"
77-
echo "$REPORT"
78-
echo "$DELIMITER"
79-
} >> "$GITHUB_OUTPUT"
80-
echo "synced=$SYNCED" >> "$GITHUB_OUTPUT"
96+
if { [ "$DRIFT_STATUS" -eq 0 ] && [ "$SYNCED" = "true" ]; } || \
97+
{ [ "$DRIFT_STATUS" -eq 1 ] && [ "$SYNCED" = "false" ]; }; then
98+
DELIMITER="REPORT_EOF_$(openssl rand -hex 16)"
99+
{
100+
echo "report<<$DELIMITER"
101+
echo "$REPORT"
102+
echo "$DELIMITER"
103+
} >> "$GITHUB_OUTPUT"
104+
echo "synced=$SYNCED" >> "$GITHUB_OUTPUT"
105+
else
106+
echo "::warning::Proto drift check failed: exit status $DRIFT_STATUS disagrees with report"
107+
echo "stderr: $(cat "$RUNNER_TEMP/drift_stderr.log")"
108+
echo "synced=error" >> "$GITHUB_OUTPUT"
109+
exit 1
110+
fi
81111
else
82112
echo "::warning::Proto drift check failed: unable to parse report"
83113
echo "stderr: $(cat "$RUNNER_TEMP/drift_stderr.log")"
84114
echo "synced=error" >> "$GITHUB_OUTPUT"
115+
exit 1
85116
fi
86117
87118
- name: Annotate drift warning

‎.github/workflows/sdk-sync-dashboard.yml‎

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
name: SDK Proto Sync
4+
name: SDK Sync Dashboard
55

66
on:
77
schedule:
@@ -30,14 +30,33 @@ jobs:
3030
steps:
3131
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3232
- id: config
33-
run: echo "matrix=$(jq -c '.include' tasks/sdk-sync-config.json)" >> "$GITHUB_OUTPUT"
33+
run: |
34+
MATRIX=$(jq -e -c '
35+
if (.include | type == "array" and length > 0 and all(.[];
36+
type == "object" and
37+
(.name | type == "string") and
38+
(.display_name | type == "string") and
39+
(.bindings_committed | type == "boolean") and
40+
(.no_file_tracking_hint == null or (.no_file_tracking_hint | type == "string")) and
41+
(.generated_bindings_status | type == "string") and
42+
(.label | type == "string") and
43+
(.drift_task | type == "string") and
44+
(.build_check_task | type == "string") and
45+
(.proto_task | type == "string") and
46+
(.build_task | type == "string") and
47+
(.test_task | type == "string") and
48+
(.source_dirs | type == "array" and all(.[]; type == "string"))
49+
)) then .include else error("invalid SDK sync configuration") end
50+
' tasks/sdk-sync-config.json)
51+
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
3452
3553
sdk_sync_check:
3654
name: Sync Check (${{ matrix.sdk.name }})
3755
needs: load_config
3856
runs-on: linux-amd64-cpu8
3957
timeout-minutes: 30
4058
container:
59+
# Keep this workflow reproducible; update the digest deliberately when the CI image changes.
4160
image: ghcr.io/nvidia/openshell/ci:5b9daab9351b1e053f9a5e0ce4c899f5d3f674b0
4261
credentials:
4362
username: ${{ github.actor }}
@@ -57,12 +76,20 @@ jobs:
5776
BUILD_CHECK_TASK: ${{ matrix.sdk.build_check_task }}
5877
run: |
5978
mkdir -p report
60-
mise run "$DRIFT_TASK" > report/drift.json 2> report/drift.stderr || true
79+
DRIFT_STATUS=0
80+
mise run "$DRIFT_TASK" > report/drift.json 2> report/drift.stderr || DRIFT_STATUS=$?
6181
if ! jq -e 'type == "object" and has("synced") and (.synced | type == "boolean") and (has("error") | not)' report/drift.json >/dev/null 2>&1; then
6282
jq -n --arg sdk "$SDK_NAME" '{sdk:$sdk, has_drift:"error", build_failed:"false"}' > report/status.json
6383
exit 0
6484
fi
6585
SYNCED=$(jq -r '.synced' report/drift.json)
86+
if { [ "$DRIFT_STATUS" -eq 0 ] && [ "$SYNCED" = "true" ]; } || \
87+
{ [ "$DRIFT_STATUS" -eq 1 ] && [ "$SYNCED" = "false" ]; }; then
88+
:
89+
else
90+
jq -n --arg sdk "$SDK_NAME" '{sdk:$sdk, has_drift:"error", build_failed:"false"}' > report/status.json
91+
exit 0
92+
fi
6693
if [ "$SYNCED" = "true" ]; then
6794
jq -n --arg sdk "$SDK_NAME" '{sdk:$sdk, has_drift:"false", build_failed:"false"}' > report/status.json
6895
exit 0
@@ -86,14 +113,15 @@ jobs:
86113
issue_management:
87114
name: Manage Drift Issue (${{ matrix.sdk.name }})
88115
needs: [load_config, sdk_sync_check]
89-
if: always() && needs.load_config.result == 'success' && needs.sdk_sync_check.result == 'success'
116+
if: always() && needs.load_config.result == 'success'
90117
runs-on: linux-amd64-cpu8
91118
timeout-minutes: 5
92119
permissions:
93120
contents: read
94121
issues: write
95122
packages: read
96123
container:
124+
# Keep this workflow reproducible; update the digest deliberately when the CI image changes.
97125
image: ghcr.io/nvidia/openshell/ci:5b9daab9351b1e053f9a5e0ce4c899f5d3f674b0
98126
credentials:
99127
username: ${{ github.actor }}
@@ -115,8 +143,10 @@ jobs:
115143
echo "build_failed=$(jq -r '.build_failed' report/status.json)" >> "$GITHUB_OUTPUT"
116144
- name: Warn on drift detection error
117145
if: steps.status.outputs.has_drift == 'error'
146+
env:
147+
SDK_NAME: ${{ matrix.sdk.name }}
118148
run: |
119-
echo "::error::Drift detection failed for ${{ matrix.sdk.name }} SDK"
149+
echo "::error::Drift detection failed for $SDK_NAME SDK"
120150
cat report/drift.stderr
121151
exit 1
122152
- name: Install tools
@@ -126,14 +156,16 @@ jobs:
126156
if: steps.status.outputs.has_drift == 'true'
127157
env:
128158
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159+
SDK_NAME: ${{ matrix.sdk.name }}
160+
SDK_LABEL: ${{ matrix.sdk.label }}
129161
run: |
130162
set +e
131163
RESULT=$(uv run python tasks/scripts/sdk_sync.py manage-issue \
132164
--drift-report "$(cat report/drift.json)" \
133165
--build-report "$(cat report/build.json)" \
134-
--sdk "${{ matrix.sdk.name }}" \
166+
--sdk "$SDK_NAME" \
135167
--repo "$GITHUB_REPOSITORY" \
136-
--label "${{ matrix.sdk.label }}")
168+
--label "$SDK_LABEL")
137169
STATUS=$?
138170
set -e
139171
if ! printf '%s\n' "$RESULT" | jq .; then
@@ -147,16 +179,23 @@ jobs:
147179
ACTION=unknown
148180
fi
149181
if [ "$ACTION" != "created" ] && [ "$ACTION" != "updated" ]; then
150-
echo "::error::Issue management for ${{ matrix.sdk.name }} failed: $ACTION"
182+
echo "::error::Issue management for $SDK_NAME failed: $ACTION"
151183
exit 1
152184
fi
153185
- name: Close resolved drift issue
154186
if: steps.status.outputs.has_drift == 'false'
155187
env:
156188
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
189+
SDK_LABEL: ${{ matrix.sdk.label }}
157190
run: |
158-
ISSUE=$(gh issue list --repo "$GITHUB_REPOSITORY" --label "${{ matrix.sdk.label }}" --state open --json number --jq '.[0].number')
159-
if [ -n "$ISSUE" ]; then
191+
ISSUES=$(gh issue list --repo "$GITHUB_REPOSITORY" --label "$SDK_LABEL" --state open --limit 101 --json number --jq '.[].number')
192+
ISSUE_COUNT=$(printf '%s\n' "$ISSUES" | sed '/^$/d' | wc -l | tr -d ' ')
193+
if [ "$ISSUE_COUNT" -ge 101 ]; then
194+
echo "::error::Issue list for $SDK_LABEL reached the 101-result limit; refusing to close issues"
195+
exit 1
196+
fi
197+
while IFS= read -r ISSUE; do
198+
[ -z "$ISSUE" ] && continue
160199
gh issue close "$ISSUE" --repo "$GITHUB_REPOSITORY" --comment "The SDK proto drift check passed. Closing automatically."
161200
echo "Closed issue #$ISSUE"
162-
fi
201+
done <<< "$ISSUES"

‎tasks/go.toml‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,8 @@ BUF_TEMPLATE="$SDK_ROOT/buf.gen.yaml"
134134
if command -v cygpath &>/dev/null; then
135135
WORK_DIR=$(mktemp -d)
136136
trap 'rm -rf "$WORK_DIR"' EXIT
137-
GO_PLUGIN=$(cygpath -m "$(command -v protoc-gen-go)")
138-
GRPC_PLUGIN=$(cygpath -m "$(command -v protoc-gen-go-grpc)")
139-
GO_PLUGIN=${GO_PLUGIN//&/\\&}
140-
GRPC_PLUGIN=${GRPC_PLUGIN//&/\\&}
141-
sed \
142-
-e "s|local: protoc-gen-go$|local: $GO_PLUGIN|" \
143-
-e "s|local: protoc-gen-go-grpc$|local: $GRPC_PLUGIN|" \
144-
"$SDK_ROOT/buf.gen.yaml" > "$WORK_DIR/buf.gen.yaml"
145-
BUF_TEMPLATE="$WORK_DIR/buf.gen.yaml"
137+
source "$REPO_ROOT/tasks/scripts/prepare_go_buf_template.sh"
138+
BUF_TEMPLATE=$(prepare_go_buf_template "$SDK_ROOT" "$WORK_DIR")
146139
fi
147140
148141
# Clean previous output before regeneration

‎tasks/scripts/go_proto_check.sh‎

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,14 @@ emit_error() {
2424
fi
2525
}
2626

27-
TOOLS=(buf protoc-gen-go protoc-gen-go-grpc)
28-
if [ "$OUTPUT_FORMAT" = "json" ]; then
29-
TOOLS+=(jq)
27+
if [ "$OUTPUT_FORMAT" = "json" ] && ! command -v jq &>/dev/null; then
28+
echo '{"sdk":"go","synced":false,"files":[],"summary":"jq not found","error":"jq not found"}'
29+
exit 1
3030
fi
31+
TOOLS=(buf protoc-gen-go protoc-gen-go-grpc)
3132
for tool in "${TOOLS[@]}"; do
3233
if ! command -v "$tool" &>/dev/null; then
33-
if [ "$OUTPUT_FORMAT" = "json" ] && [ "$tool" = "jq" ]; then
34-
echo '{"sdk":"go","synced":false,"files":[],"summary":"jq not found","error":"jq not found"}'
35-
else
36-
emit_error "$tool not found. Run 'mise install' to install it."
37-
fi
34+
emit_error "$tool not found. Run 'mise install' to install it."
3835
exit 1
3936
fi
4037
done
@@ -49,22 +46,8 @@ RESULTS_FILE=$(mktemp)
4946
GENERATION_LOG=$(mktemp)
5047
trap 'rm -rf "$WORK_DIR"; rm -f "$RESULTS_FILE" "$GENERATION_LOG"' EXIT
5148

52-
BUF_OUTPUT_DIR="$WORK_DIR"
53-
if command -v cygpath &>/dev/null; then
54-
BUF_OUTPUT_DIR=$(cygpath -m "$WORK_DIR")
55-
fi
56-
sed "s|out: sdk/go|out: $BUF_OUTPUT_DIR|" buf.gen.yaml >"$WORK_DIR/buf.gen.yaml"
57-
if command -v cygpath &>/dev/null; then
58-
GO_PLUGIN=$(cygpath -m "$(command -v protoc-gen-go)")
59-
GRPC_PLUGIN=$(cygpath -m "$(command -v protoc-gen-go-grpc)")
60-
GO_PLUGIN=${GO_PLUGIN//&/\\&}
61-
GRPC_PLUGIN=${GRPC_PLUGIN//&/\\&}
62-
sed \
63-
-e "s|local: protoc-gen-go$|local: $GO_PLUGIN|" \
64-
-e "s|local: protoc-gen-go-grpc$|local: $GRPC_PLUGIN|" \
65-
"$WORK_DIR/buf.gen.yaml" >"$WORK_DIR/buf.gen.windows.yaml"
66-
mv "$WORK_DIR/buf.gen.windows.yaml" "$WORK_DIR/buf.gen.yaml"
67-
fi
49+
source "$REPO_ROOT/tasks/scripts/prepare_go_buf_template.sh"
50+
prepare_go_buf_template "$SDK_ROOT" "$WORK_DIR" >/dev/null
6851
CHECK_TEMPLATE="$WORK_DIR/buf.gen.yaml"
6952
if ! (cd "$REPO_ROOT" && buf generate --template "$CHECK_TEMPLATE") >"$GENERATION_LOG" 2>&1; then
7053
if [ "$OUTPUT_FORMAT" = "text" ]; then
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
prepare_go_buf_template() {
7+
local sdk_root=$1
8+
local work_dir=$2
9+
local output_dir=$work_dir
10+
local template=$work_dir/buf.gen.yaml
11+
12+
if command -v cygpath &>/dev/null; then
13+
output_dir=$(cygpath -m "$work_dir")
14+
fi
15+
local sed_output_dir=${output_dir//&/\\&}
16+
sed "s|out: sdk/go|out: $sed_output_dir|" "$sdk_root/buf.gen.yaml" >"$template"
17+
18+
if command -v cygpath &>/dev/null; then
19+
local go_plugin grpc_plugin
20+
go_plugin=$(cygpath -m "$(command -v protoc-gen-go)")
21+
grpc_plugin=$(cygpath -m "$(command -v protoc-gen-go-grpc)")
22+
go_plugin=${go_plugin//&/\\&}
23+
grpc_plugin=${grpc_plugin//&/\\&}
24+
sed \
25+
-e "s|local: protoc-gen-go$|local: $go_plugin|" \
26+
-e "s|local: protoc-gen-go-grpc$|local: $grpc_plugin|" \
27+
"$template" >"$work_dir/buf.gen.windows.yaml"
28+
mv "$work_dir/buf.gen.windows.yaml" "$template"
29+
fi
30+
31+
printf '%s\n' "$template"
32+
}

0 commit comments

Comments
 (0)