Fix SC2015 shellcheck errors in generated "Collect usage artifact files" step - #49845
Conversation
Replace `A && B || C` patterns with `if/then/fi` constructs in the shell script generated by notify_comment.go. ShellCheck SC2015 warns that `A && B || C` is not if-then-else because C may run when A is true but B fails. The strict-mode compile test was failing because of these patterns in the generated lock files. Recompile all 269 workflows to update generated .lock.yml files. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates generated usage-artifact collection shell code to avoid ShellCheck SC2015 warnings.
Changes:
- Replaces
A && B || Cpatterns with explicit conditionals. - Regenerates 269 workflow lock files.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/notify_comment.go |
Updates generated shell commands. |
.github/workflows/*.lock.yml (269 files) |
Propagates updated shell syntax. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 179/270 changed files
- Comments generated: 1
- Review effort level: Balanced
| " if [ -f /tmp/gh-aw/aw_info.json ]; then cp /tmp/gh-aw/aw_info.json /tmp/gh-aw/usage/aw_info.json; fi\n", | ||
| " if [ -f /tmp/gh-aw/aw-info.jsonl ]; then cp /tmp/gh-aw/aw-info.jsonl /tmp/gh-aw/usage/aw-info.jsonl; fi\n", | ||
| " if [ -f /tmp/gh-aw/agent_usage.json ]; then cp /tmp/gh-aw/agent_usage.json /tmp/gh-aw/usage/agent_usage.json; fi\n", | ||
| " if [ -f /tmp/gh-aw/agent_usage.jsonl ]; then cp /tmp/gh-aw/agent_usage.jsonl /tmp/gh-aw/usage/agent_usage.jsonl; fi\n", | ||
| " if [ -f /tmp/gh-aw/detection_usage.jsonl ]; then cp /tmp/gh-aw/detection_usage.jsonl /tmp/gh-aw/usage/detection_usage.jsonl; fi\n", |
|
@copilot Please continue triage on this PR. Remaining visible blockers (newest first):
Failed checks:
Run details: https://github.com/github/gh-aw/actions/runs/30765233636
|
| @@ -1132,21 +1132,21 @@ jobs: | |||
| mkdir -p /tmp/gh-aw/usage/agent /tmp/gh-aw/usage/detection | |||
There was a problem hiding this comment.
@copilot refactor to a shell script in actions/setup/sh instead of inlining
There was a problem hiding this comment.
Done. Extracted the inline shell code into actions/setup/sh/collect_usage_artifact_files.sh and updated the "Collect usage artifact files" step to invoke it via:
run: bash "${RUNNER_TEMP}/gh-aw/actions/collect_usage_artifact_files.sh"Tests in notify_comment_test.go were updated to check the script file content directly for the logic assertions (copy commands, -s checks, priority ordering, node invocation) instead of the inline YAML steps. All 269 workflows were recompiled. Commit: 6bd6900.
- Add || true after cp commands inside if/then/fi blocks in notify_comment.go to preserve best-effort behavior under bash -e - Sync pkg/workflow/js/safe_outputs_tools.json push_to_pull_request_branch tool to match actions/setup/js/safe_outputs_tools.json (adds repo parameter, updates x-safe-outputs-target-requirements, updates desc) Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Done. Two changes in the latest commit:
|
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot Please continue triage on this PR. Remaining visible blockers (newest first):
Run details: https://github.com/github/gh-aw/actions/runs/30767332278
|
|
Thanks for working on this! 🙌 The shell syntax fix in However, there are a couple of things that would strengthen this:
If you'd like help, you can assign this prompt to your agent:
|
|
🎉 This pull request is included in a new release. Release: |
TestPullRequestTargetCheckoutFalseWithImports/strict_modewas failing because strict-mode compilation runs shellcheck on generated YAML, and shellcheck flagged SC2015 onA && B || Cpatterns in the "Collect usage artifact files" step emitted bynotify_comment.go.Changes
pkg/workflow/notify_comment.go: Replace allA && B || Cshell patterns with properif/then/ficonstructs:Covers 14 patterns: the
echo "FOUND/MISSING"diagnostic line inside theforloop, 7[ -f ] && cp || truefile copies, and 6[ -s ] && cp || truetoken-usage copies..github/workflows/*.lock.yml: Recompiled all 269 workflows to propagate the updated shell syntax.