Files
qwen-code/.github/scripts/codeql-failure-issue.sh
T
易良andQwen-Coder 57f88a93e5 fix(ci): reuse open workflow failure issues (#15256)
* fix(ci): reuse open workflow failure issues

* fix(ci): single-quote the concurrency queue value

yamllint's quoted-strings rule (quote-type: single, required: true) rejects
the bare `max` scalar, which is what failed the Lint & Static lane at
.github/workflows/main-ci-failure-issue.yml:342:14.

The value is unchanged after parsing: `queue: max` and `queue: 'max'` both
yield the string "max", so the workflow semantics and the parsed-document
assertions in scripts/tests/main-ci-failure-issue-workflow.test.js are
unaffected.

Co-authored-by: Qwen-Coder <[email protected]>
Patrol-Run: qwen-pr-closeout/jmvjvf9h5qa

* fix(ci): publish the tracking issue before the cosmetic label edit

A non-zero exit from the decorative `--remove-label` edit aborted the
writer step under the `set -euo pipefail` this branch adds, losing both
the recurrence comment and `issue_url`. report_pr is `always()`-gated and
reads `issue_url` unconditionally, so it posted the merged PR's failure
summary with the [Tracking issue] link silently omitted. Restore the
ordering the deleted comment documented: url and comment first, then the
retirement.

Also drop the `issues: read` grant the analyze job no longer uses now
that the plan step is gone, and pin the paginated lookup's page merge,
which no fixture exercised because every one fed a single JSON document.

Co-authored-by: Qwen-Coder <[email protected]>
Patrol-Run: qwen-pr-closeout/jmvk8a84dqp

* fix(ci): preserve provenance and lifecycle of failure aggregates

---------

Co-authored-by: Qwen-Coder <[email protected]>
2026-10-23 13:33:49 +08:00

63 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# File (or comment on) one issue when the nightly CodeQL scan does not finish.
#
# The body below is the 'File or update the CodeQL failure issue' step of the
# report_failure job in .github/workflows/codeql.yml.
#
# The scan is schedule-only and never a required check, so nothing turns red
# when it dies: the old shared 30-minute cap cancelled 57 of 59 nightlies and
# the Security tab silently stopped updating for weeks (#13249).
# main-ci-failure-issue.yml aggregates watched workflow failures, but does not
# watch CodeQL and only fires on `failure`; a `timeout-minutes` overrun reports
# `cancelled`, which this reporter also covers.
set -euo pipefail
# Name the legs that did not finish, so the issue says which language lost its
# coverage. A failed read degrades to "see the run" instead of killing the
# report — `x=$(false)` aborts under `set -e`, hence the `||`.
legs=''
legs="$(
gh api "repos/${REPO}/actions/runs/${RUN_ID}/jobs" --jq '
[ .jobs[]
| select(.name | startswith("CodeQL ("))
| select(.conclusion == "failure" or .conclusion == "cancelled" or .conclusion == "timed_out")
| "\(.name): \(.conclusion)" ] | join(", ")
'
)" || legs=''
marker_html='<!-- codeql-nightly-failure -->'
body_file="${RUNNER_TEMP}/codeql-failure.md"
# The backticks in these formats are literal markdown, not command
# substitution, so shellcheck's SC2016 expansion warning is disabled.
# shellcheck disable=SC2016
{
printf '%s\n\n' "${marker_html}"
printf 'The nightly [`CodeQL`](%s) scan did not finish, so the Security tab is not being updated.\n\n' "${RUN_URL}"
printf -- '- Legs: %s\n' "${legs:-see the run; the job conclusions could not be read}"
printf -- '- Run: %s\n\n' "${RUN_URL}"
printf 'A `cancelled` leg usually means it overran its `timeout-minutes` in `.github/workflows/codeql.yml`: compare the `Perform CodeQL Analysis` duration with the cap, then raise the cap or re-run through `workflow_dispatch`.\n'
} > "${body_file}"
# Dedup by an exact body marker — see find-marked-issue.sh. A lookup failure
# degrades to a possible duplicate rather than silence.
existing="$(
MARKER_HTML="${marker_html}" \
bash "$(dirname "${BASH_SOURCE[0]}")/find-marked-issue.sh"
)" || existing=''
# One comment per failed night is the history the operator wants, and it
# notifies subscribers that the scan died again.
if [[ -n "${existing}" ]]; then
gh issue comment "${existing}" --repo "${REPO}" --body-file "${body_file}"
echo "Recorded this failure on issue #${existing}."
exit 0
fi
gh issue create \
--repo "${REPO}" \
--title 'Nightly CodeQL scan did not finish' \
--body-file "${body_file}" \
--label 'type/bug' \
--label "${DEDUP_LABEL}"