Skip to content

Commit 4f9f16d

Browse files
committed
ci: clean up workflows and supporting commands
Signed-off-by: Jacob Howard <[email protected]>
1 parent 170843f commit 4f9f16d

File tree

9 files changed

+38
-468
lines changed

9 files changed

+38
-468
lines changed

.github/workflows/security-review-changes.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ jobs:
183183
--jq '.id'
184184
}
185185
186+
# Helper to create a slug suitable for check names.
187+
slugify() {
188+
echo "$1" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g' | sed -E 's/^-+|-+$//g'
189+
}
190+
186191
# Create checks for updated pins (differential reviews).
187192
if [ "${{ steps.updatedpins.outputs.has_targets }}" = "true" ]; then
188193
while read -r target; do
@@ -191,7 +196,8 @@ jobs:
191196
old_commit=$(echo "$target" | jq -r '.old_commit')
192197
new_commit=$(echo "$target" | jq -r '.new_commit')
193198
194-
check_name="security-review/$agent/pin/$server"
199+
server_slug=$(slugify "$server")
200+
check_name="security-review/$agent/pin/$server_slug"
195201
check_id=$(create_pending_check "$check_name" "$server" "differential")
196202
197203
echo "$check_name|$check_id|$server|$project|$new_commit|$old_commit|differential" >> review-output/check-ids.txt
@@ -205,7 +211,8 @@ jobs:
205211
project=$(echo "$target" | jq -r '.project')
206212
commit=$(echo "$target" | jq -r '.commit')
207213
208-
check_name="security-review/$agent/new/$server"
214+
server_slug=$(slugify "$server")
215+
check_name="security-review/$agent/new/$server_slug"
209216
check_id=$(create_pending_check "$check_name" "$server" "full")
210217
211218
echo "$check_name|$check_id|$server|$project|$commit||full" >> review-output/check-ids.txt
@@ -356,6 +363,7 @@ jobs:
356363
if [ "$review_type" = "differential" ]; then
357364
if [ -z "$base_commit" ] || [ "$base_commit" = "null" ]; then
358365
echo "Skipping $server: missing base commit for differential review." >&2
366+
skip_check "$check_id" "$server" "missing base commit"
359367
return
360368
fi
361369
cmd+=(--base "$base_commit")
@@ -426,7 +434,7 @@ jobs:
426434
"$project" \
427435
"$head_commit" \
428436
"$base_commit" \
429-
"$review_type"
437+
"$review_type" || true
430438
done < review-output/check-ids.txt
431439
432440
- name: Upload security reports

.github/workflows/security-review-manual.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
REVIEW_MODEL_INPUT: ${{ github.event.inputs.model }}
7575
REVIEW_TIMEOUT_INPUT: ${{ github.event.inputs.timeout_secs }}
7676
run: |
77-
set -euo pipefail
77+
set -uo pipefail
7878
agent="${REVIEW_AGENT_INPUT:-}"
7979
if [ -z "$agent" ]; then
8080
agent="claude"
@@ -115,7 +115,9 @@ jobs:
115115
cmd+=(--model "$model")
116116
fi
117117
118-
"${cmd[@]}"
118+
if ! "${cmd[@]}"; then
119+
echo "Security review failed for $server" >&2
120+
fi
119121
done < <(jq -c '.[]' "${{ steps.collect.outputs.targets }}")
120122
121123
- name: Upload security reports

.github/workflows/update-pins.yaml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,20 +132,22 @@ jobs:
132132
git fetch origin main
133133
git reset --hard origin/main
134134
135-
# If a prior PR exists for this server, fetch it and bail out when
136-
# the requested commit is identical (no update required).
135+
# Check if we've hit the new PR limit before doing any work.
136+
branch_exists=false
137137
if git ls-remote --exit-code --heads origin "$branch" >/dev/null 2>&1; then
138+
branch_exists=true
138139
git fetch origin "$branch"
139140
existing_commit=$(git show "origin/${branch}:servers/${server}/server.yaml" 2>/dev/null | awk '/commit:/{print $2}' | tail -n1)
140141
if [ -n "$existing_commit" ] && [ "$existing_commit" = "$new_commit" ]; then
141142
echo "Existing PR for $server already pins ${existing_commit}; skipping."
142143
continue
143144
fi
144-
else
145-
if [ -n "$new_pr_limit" ] && [ "$new_pr_count" -ge "$new_pr_limit" ]; then
146-
echo "New PR quota reached ($new_pr_limit); skipping $server."
147-
continue
148-
fi
145+
fi
146+
147+
# Check PR limit for new branches only.
148+
if [ "$branch_exists" = false ] && [ -n "$new_pr_limit" ] && [ "$new_pr_count" -ge "$new_pr_limit" ]; then
149+
echo "New PR quota reached ($new_pr_limit); skipping $server."
150+
continue
149151
fi
150152
151153
# Apply the patch onto a fresh branch for this server.
@@ -163,20 +165,28 @@ jobs:
163165
# Commit the server YAML change and force-push the automation branch.
164166
git add "servers/${server}/server.yaml"
165167
git commit -m "chore: update pin for ${server}"
166-
git push --force origin "$branch"
168+
if ! git push --force origin "$branch"; then
169+
echo "Failed to push branch for $server, skipping." >&2
170+
continue
171+
fi
167172
168173
# Create or update the PR dedicated to this server.
169174
if gh pr view --head "$branch" >/dev/null 2>&1; then
170-
gh pr edit "$branch" \
175+
if ! gh pr edit "$branch" \
171176
--title "chore: update pin for ${server}" \
172-
--body "Automated commit pin update for ${server}."
177+
--body "Automated commit pin update for ${server}." 2>&1; then
178+
echo "Failed to update PR for $server" >&2
179+
fi
173180
else
174-
gh pr create \
181+
if gh pr create \
175182
--title "chore: update pin for ${server}" \
176183
--body "Automated commit pin update for ${server}." \
177184
--base main \
178-
--head "$branch"
179-
new_pr_count=$((new_pr_count + 1))
185+
--head "$branch" 2>&1; then
186+
new_pr_count=$((new_pr_count + 1))
187+
else
188+
echo "Failed to create PR for $server" >&2
189+
fi
180190
fi
181191
done
182192

cmd/ci/compose_pr_summary.go

Lines changed: 0 additions & 82 deletions
This file was deleted.

cmd/ci/helpers.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,30 +128,6 @@ func runGitCommand(dir string, args ...string) (string, error) {
128128
return string(output), nil
129129
}
130130

131-
// initGitRepository creates or reuses a git repository rooted at dir with origin set.
132-
func initGitRepository(dir, remote string) error {
133-
if err := os.MkdirAll(dir, 0o755); err != nil {
134-
return err
135-
}
136-
if _, err := runGitCommand(dir, "rev-parse", "--is-inside-work-tree"); err == nil {
137-
return nil
138-
}
139-
if _, err := runGitCommand(dir, "init"); err != nil {
140-
return err
141-
}
142-
if _, err := runGitCommand(dir, "remote", "remove", "origin"); err == nil {
143-
// ignore error
144-
}
145-
_, err := runGitCommand(dir, "remote", "add", "origin", remote)
146-
return err
147-
}
148-
149-
// fetchCommit retrieves a single commit from origin into the repository.
150-
func fetchCommit(dir, commit string) error {
151-
_, err := runGitCommand(dir, "fetch", "--depth", "1", "--no-tags", "origin", commit)
152-
return err
153-
}
154-
155131
// splitList normalizes a delimited string into lowercase server names.
156132
func splitList(raw string) []string {
157133
if raw == "" {

cmd/ci/main.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,10 @@ func main() {
1919
switch cmd {
2020
case "collect-updated-pins":
2121
err = runCollectUpdatedPins(args)
22-
case "prepare-updated-pins":
23-
err = runPrepareUpdatedPins(args)
2422
case "collect-new-servers":
2523
err = runCollectNewServers(args)
26-
case "prepare-new-servers":
27-
err = runPrepareNewServers(args)
28-
case "compose-pr-summary":
29-
err = runComposePRSummary(args)
3024
case "collect-full-audit":
3125
err = runCollectFullAudit(args)
32-
case "prepare-full-audit":
33-
err = runPrepareFullAudit(args)
3426
case "update-pins":
3527
err = runUpdatePins(args)
3628
default:

cmd/ci/prepare_full_audit.go

Lines changed: 0 additions & 99 deletions
This file was deleted.

0 commit comments

Comments
 (0)