Skip to content

Commit b11df8a

Browse files
committed
fix(workflows): unblock PR checks on large diffs + private go modules
1 parent 0301ad2 commit b11df8a

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

.github/scripts/ai-review.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,21 @@ else
9595
diff_content=$(cat "$DIFF_FILE")
9696
fi
9797

98-
user_message=$(printf '%s\n\n---\n\nPR diff to review:\n\n```diff\n%s\n```\n' \
99-
"$prompt_body" "$diff_content")
100-
101-
request_body=$(jq -n \
98+
# Write the user message to a temp file. Passing it through --arg would hit
99+
# the system ARG_MAX limit on PRs with large diffs ("Argument list too long").
100+
user_message_file=$(mktemp)
101+
printf '%s\n\n---\n\nPR diff to review:\n\n```diff\n%s\n```\n' \
102+
"$prompt_body" "$diff_content" > "$user_message_file"
103+
104+
request_body_file=$(mktemp)
105+
jq -n \
102106
--arg model "$MODEL" \
103-
--arg content "$user_message" \
107+
--rawfile content "$user_message_file" \
104108
'{
105109
model: $model,
106110
messages: [{role: "user", content: $content}],
107111
temperature: 0.2
108-
}')
112+
}' > "$request_body_file"
109113

110114
# --- Call the API ------------------------------------------------------------
111115

@@ -115,7 +119,7 @@ http_status=$(curl -sS -o "$response_file" -w '%{http_code}' \
115119
-H "Content-Type: application/json" \
116120
-H "api-key: ${THREATWINDS_API_KEY}" \
117121
-H "api-secret: ${THREATWINDS_API_SECRET}" \
118-
--data "$request_body" || echo "000")
122+
--data-binary "@${request_body_file}" || echo "000")
119123

120124
if [[ "$http_status" != "200" ]]; then
121125
echo "ThreatWinds API HTTP $http_status"

.github/workflows/_pr-reusable-go-deps.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
required: false
88
type: string
99
default: '1.23'
10+
secrets:
11+
API_SECRET:
12+
required: false
13+
description: "PAT with read access to private utmstack/* Go modules. Without it, `go list -u -m -json all` fails on projects that import private repos."
1014

1115
jobs:
1216
deps:
@@ -19,6 +23,23 @@ jobs:
1923
with:
2024
go-version: ${{ inputs.go_version }}
2125

26+
# Some projects in this monorepo (e.g. ./installer) depend on private
27+
# utmstack/* modules. `go list -u -m -json all` tries to clone those
28+
# over HTTPS and fails without auth — same pattern the deploy pipelines
29+
# already use for `go build`.
30+
- name: Configure git for private Go modules
31+
if: ${{ env.HAS_API_SECRET == 'true' }}
32+
env:
33+
HAS_API_SECRET: ${{ secrets.API_SECRET != '' }}
34+
API_SECRET: ${{ secrets.API_SECRET }}
35+
run: |
36+
git config --global url."https://${API_SECRET}:x-oauth-basic@github.com/".insteadOf "https://github.com/"
37+
{
38+
echo "GOPRIVATE=github.com/utmstack"
39+
echo "GONOPROXY=github.com/utmstack"
40+
echo "GONOSUMDB=github.com/utmstack"
41+
} >> "$GITHUB_ENV"
42+
2243
- name: Run go-deps.sh --check --discover
2344
id: run
2445
run: |

.github/workflows/pr-checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
go_deps:
2222
name: Go deps
2323
uses: ./.github/workflows/_pr-reusable-go-deps.yml
24+
secrets:
25+
API_SECRET: ${{ secrets.API_SECRET }}
2426

2527
ai_review:
2628
name: AI review

0 commit comments

Comments
 (0)