Copilot commented on code in PR #6837:
URL: https://github.com/apache/texera/pull/6837#discussion_r3641173683
##########
.github/workflows/codecov-upload.yml:
##########
@@ -58,80 +55,66 @@ on:
permissions:
contents: read
- actions: read # list + download artifacts from the source run
+ actions: read # download-artifact needs this to read artifacts from another
run
jobs:
- discover:
- # Which codecov-<flag> artifacts did the source run actually build? A
label-gated
- # PR only stages some of them, so we list what exists and upload exactly
those —
- # rather than a hardcoded flag set that throws "artifact not found" for
the rest.
- # Skip only a cancelled/skipped upstream; still run on failure so partial
coverage
- # is reported (mirrors the build's always()/!cancelled() staging).
+ upload:
+ # Skip only a cancelled/skipped upstream; still run on failure so partial
+ # coverage is reported (mirrors the build's always()/!cancelled() staging).
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion != 'cancelled' &&
github.event.workflow_run.conclusion != 'skipped')
runs-on: ubuntu-latest
- outputs:
- flags: ${{ steps.list.outputs.flags }}
- steps:
- - name: List codecov-* artifacts in the source run
- id: list
- uses: actions/github-script@v9
- env:
- # Passed via env (not interpolated into the script body) so a
- # workflow_dispatch-supplied run_id can't inject into the JS.
- SOURCE_RUN_ID: ${{ github.event.workflow_run.id || inputs.run_id }}
- with:
- script: |
- const runId = Number(process.env.SOURCE_RUN_ID);
- if (!Number.isInteger(runId) || runId <= 0) {
- core.setFailed(`Invalid source run id:
'${process.env.SOURCE_RUN_ID}' (expected a positive integer)`);
- return;
- }
- const arts = await
github.paginate(github.rest.actions.listWorkflowRunArtifacts, {
- owner: context.repo.owner, repo: context.repo.repo, run_id:
runId, per_page: 100,
- });
- const flags = [...new Set(
- arts.map(a => a.name)
- .filter(n => n.startsWith('codecov-'))
- .map(n => n.slice('codecov-'.length))
- )].sort();
- core.info(`Source run ${runId} staged codecov flags:
${flags.join(', ') || '(none)'}`);
- core.setOutput('flags', JSON.stringify(flags));
-
- upload:
- needs: discover
- # Nothing to do when the source produced no codecov-* artifacts (also
avoids an
- # empty matrix, which is an error).
- if: ${{ needs.discover.outputs.flags != '' && needs.discover.outputs.flags
!= '[]' }}
- runs-on: ubuntu-latest
- # Job-level so the group can key on matrix.flag: one upload pass per
source run +
- # flag, and a re-run of the source supersedes the previous attempt.
+ # Job-level so the group can key on matrix.flag: one upload pass per source
+ # run + flag, and a re-run of the source supersedes the previous attempt.
concurrency:
group: codecov-upload-${{ github.event.workflow_run.id || inputs.run_id
}}-${{ matrix.flag }}
cancel-in-progress: false
strategy:
fail-fast: false
matrix:
- # `|| '[]'` guards matrix evaluation if the output is ever an empty
string
- # (discover skipped/failed); the job `if` above still skips the empty
case.
- flag: ${{ fromJSON(needs.discover.outputs.flags || '[]') }}
+ # flag = artifact suffix (codecov-<flag>); coverage=false for the
+ # test-results-only flag (amber-integration has no coverage report).
+ #
+ # KEEP IN SYNC with the coverage-producing jobs in build.yml: one row
per
+ # codecov-<flag> artifact staged there — frontend, amber,
amber-integration,
+ # pyamber, agent-service, and every service in build.yml's `platform`
matrix.
+ # A flag staged in build.yml but missing here is downloaded by nothing
and
+ # its coverage is silently dropped (the reverse — a row here with no
artifact
+ # — is safe: the download continue-on-errors and the leg skips).
+ include:
+ - { flag: frontend, coverage: true }
+ - { flag: amber, coverage: true }
+ - { flag: amber-integration, coverage: false }
+ - { flag: pyamber, coverage: true }
+ - { flag: agent-service, coverage: true }
+ - { flag: config-service, coverage: true }
+ - { flag: access-control-service, coverage: true }
+ - { flag: file-service, coverage: true }
+ - { flag: computing-unit-managing-service, coverage: true }
+ - { flag: workflow-compiling-service, coverage: true }
+ - { flag: notebook-migration-service, coverage: true }
steps:
- - name: Download staged coverage for ${{ matrix.flag }}
- # No continue-on-error: discover confirmed this artifact exists, so a
download
- # failure here is a real problem that must fail the leg and trip
notify-failure
- # (the old design swallowed the failure and went green with no signal).
- # Layout: stage-codecov.sh roots the artifact at cc/ (coverage/,
results/, and
- # the pr-number/commit-sha/branch txt files), so downloading to path:
cc
- # restores cc/coverage/**, cc/results/**, and cc/pr-number.txt.
+ - name: Resolve source run id
+ id: src
+ shell: bash
+ run: echo "run_id=${{ github.event.workflow_run.id || inputs.run_id
}}" >> "$GITHUB_OUTPUT"
Review Comment:
`workflow_dispatch` input `run_id` is written to `$GITHUB_OUTPUT` without
validation/sanitization. If a non-numeric (or newline-containing) value is
provided, the workflow can go green while doing nothing (download fails but is
continue-on-error), and `$GITHUB_OUTPUT` is also susceptible to
output-injection via newlines. Validate that `run_id` is a positive integer
before exporting it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]