Repository navigation
ci(jira-poll): add a full-size batch check for the GitHub hand-off #9917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
527843f
e0d3663
c060643
f2c408c
a8cfc1c
95d4ad7
c999cae
71112a5
5d27b04
6635f32
ea42aab
a85a142
34f1a18
fa9fcb0
094cc3b
afeda2c
048b710
00f8edb
2d83300
a772539
01d47ae
ede31d1
0d65b81
5847e8c
870f3e7
c17b58a
60dbfaa
07a34db
73eac9c
f84ccd8
ce247e9
2fa4335
5814593
d94f734
bf9f4b2
abd309f
ca2a217
f32dd09
3607b26
c5bc2b0
ff8b695
ed3327b
d073774
16452f2
331b388
6d55115
acbb149
10aa206
4efe05c
f762837
28eb759
62758e2
dfaec9d
1d5efef
e531a50
f96a418
fbcf082
0a619f0
cd9d329
c696b96
04b0aad
dc645d8
d6c90b6
6d040b0
abef7cc
cfd8196
875ac79
423d60c
9905ace
577e263
b6933a0
d4b4fc2
b2d6362
473a3b3
bf616ac
1216ae9
bf8aafc
191c0d7
ee0693e
a81de2a
b56a622
3dbd497
e08d9c0
f0b27ce
632838e
01a6293
b3b6024
194ca1f
94672e4
29f4acc
1fb717e
2340925
df8e164
10d59c7
4950714
c0d2d4c
e52b104
d226986
f9a7ed2
9f04b42
b5e4b01
22151d0
6aaaab7
dc4240d
c9e1aa3
820d2b8
61aa0df
277a2c8
92c5078
3fbbdfc
ae9e9de
1569617
8827fae
48c7b23
4f0e8d7
57ef4f1
c177c77
dae1b92
3252a73
09ca7f9
df6db02
f30318d
07582e1
8ff4790
dff9273
50cdf0a
d80f8ba
2030ac4
299e2f0
eebfb8c
9c8477a
ad87462
46adaeb
9c87e7e
96699c2
473e176
eb0498f
59289b6
352b540
c389854
9a79d9a
42af816
5b3e07e
5c39ad6
08f5134
d77c60f
b66e01c
6df1f09
5140bb0
96805f5
aca40b6
3d9df68
6023b1a
bf69ebd
955fd10
8d4ed37
a10ec16
2ec3341
1c73a81
50a8999
20982f4
42a15a0
e1bf398
5ffdb8e
f821b61
c964f48
e247b90
ead3b82
77b2215
bbac702
4263bda
73f09ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| #!/usr/bin/env bash | ||
| # jira-poll-record-digest-test.sh — digest and workflow-contract tests for the | ||
| # Jira poll batch check. | ||
| # | ||
| # The batch check is only evidence while its stand-in workflows hand the | ||
| # batch over the way the real ones do. The contract cases below fail when the | ||
| # real hand-off changes and the stand-ins do not follow. | ||
| # | ||
| # Run from the repo root: | ||
| # bash .github/scripts/jira-poll-record-digest-test.sh | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| SCRIPT="${SCRIPT_DIR}/jira-poll-record-digest.sh" | ||
| WORKFLOWS="${SCRIPT_DIR}/../workflows" | ||
| TEMPLATE="${SCRIPT_DIR}/../../internal/scaffold/fullsend-repo/templates/jira-poll-per-repo.yaml" | ||
|
|
||
| fail() { echo "FAIL: $*" >&2; exit 1; } | ||
| contains() { grep -Fq -- "$2" "$1" || fail "${1} does not contain ${2}"; } | ||
| digest() { printf '%s' "$1" | "${SCRIPT}"; } | ||
|
|
||
| # The digest is of the content, not of how the JSON is written. | ||
| want="$(digest '{"agent":"triage","event_payload":{"body":"a<b 語","n":7}}')" | ||
| [[ "${want}" =~ ^[0-9a-f]{64}$ ]] || fail "digest is not a SHA-256: ${want}" | ||
|
|
||
| reordered="$(digest '{ | ||
| "event_payload": { | ||
| "n": 7, | ||
| "body": "a<b 語" | ||
| }, | ||
| "agent": "triage" | ||
| }')" | ||
| [[ "${reordered}" == "${want}" ]] || fail "key order and whitespace changed the digest" | ||
|
|
||
| escaped="$(digest '{"agent":"triage","event_payload":{"body":"a<b 語","n":7}}')" | ||
| [[ "${escaped}" == "${want}" ]] || fail "escaping a character changed the digest" | ||
|
|
||
| changed="$(digest '{"agent":"triage","event_payload":{"body":"a<b 語","n":8}}')" | ||
| [[ "${changed}" != "${want}" ]] || fail "a changed value kept the digest" | ||
|
|
||
| truncated="$(digest '{"agent":"triage","event_payload":{"body":"a<b ","n":7}}')" | ||
| [[ "${truncated}" != "${want}" ]] || fail "a shortened string kept the digest" | ||
|
|
||
| if digest '{"agent":' >/dev/null 2>&1; then | ||
| fail "input that is not JSON produced a digest" | ||
| fi | ||
|
|
||
| # The poll stand-in builds the matrix output in the real workflow's matrix | ||
| # job, which differs only in taking its runner and timeout from inputs. | ||
| matrix_job() { awk '/^ matrix:$/ { on = 1 } on && !/^ (runs-on|timeout-minutes): /' "$1"; } | ||
| real_job="$(matrix_job "${WORKFLOWS}/reusable-poll-jira.yml")" | ||
| [[ -n "${real_job}" ]] || fail "reusable-poll-jira.yml has no matrix job" | ||
| [[ "$(matrix_job "${WORKFLOWS}/jira-poll-batch-check-poll.yml")" == "${real_job}" ]] || | ||
| fail "the matrix job of jira-poll-batch-check-poll.yml differs from reusable-poll-jira.yml" | ||
|
|
||
| # Both return that job's output, and feed the job from the poll job's | ||
| # artifact under the same name. | ||
| for workflow in reusable-poll-jira.yml jira-poll-batch-check-poll.yml; do | ||
| contains "${WORKFLOWS}/${workflow}" "value: \${{ jobs.matrix.outputs.matrix || '{\"include\":[]}' }}" | ||
| contains "${WORKFLOWS}/${workflow}" 'dispatch_count: ${{ steps.check.outputs.count }}' | ||
| contains "${WORKFLOWS}/${workflow}" 'name: fullsend-jira-dispatches-${{ steps.check.outputs.artifact_suffix }}' | ||
| done | ||
|
|
||
| # The caller hands the matrix on under the managed caller's condition. | ||
| # A file without the line gives an empty condition, so the checks below | ||
| # report it; under pipefail a bare grep miss would end the script first. | ||
| condition() { grep -F 'fromJSON(needs.poll.outputs.matrix)' "$1" | sed 's/^[[:space:]]*//' || true; } | ||
| real_condition="$(condition "${TEMPLATE}")" | ||
| [[ -n "${real_condition}" ]] || fail "jira-poll-per-repo.yaml has no dispatch condition" | ||
| [[ "$(condition "${WORKFLOWS}/jira-poll-batch-check.yml")" == "${real_condition}" ]] || | ||
| fail "the dispatch condition of jira-poll-batch-check.yml differs from jira-poll-per-repo.yaml" | ||
| for caller in "${TEMPLATE}" "${WORKFLOWS}/jira-poll-batch-check.yml"; do | ||
| contains "${caller}" 'matrix: ${{ needs.poll.outputs.matrix }}' | ||
| done | ||
|
|
||
| # The real dispatch workflow still takes the matrix as a string input and | ||
| # makes one job of each record, which the dispatch stand-in copies. | ||
| contains "${WORKFLOWS}/reusable-dispatch.yml" 'matrix: ${{ fromJSON(inputs.matrix != '"''"' && inputs.matrix || ' | ||
| contains "${WORKFLOWS}/reusable-dispatch.yml" 'EVENT_PAYLOAD: ${{ toJSON(matrix.event_payload) }}' | ||
| contains "${WORKFLOWS}/jira-poll-batch-check-dispatch.yml" 'matrix: ${{ fromJSON(inputs.matrix) }}' | ||
| contains "${WORKFLOWS}/jira-poll-batch-check-dispatch.yml" 'RECORD: ${{ toJSON(matrix) }}' | ||
|
|
||
| echo "jira poll record digest and workflow-contract tests passed" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/usr/bin/env bash | ||
| # jira-poll-record-digest.sh — Print the SHA-256 of one dispatch record | ||
| # | ||
| # Reads a JSON value on stdin and hashes its canonical form: keys sorted, no | ||
| # insignificant whitespace, strings written the way jq writes them. The Jira | ||
| # poll batch check (.github/workflows/jira-poll-batch-check.yml) hashes each | ||
| # record when it builds the batch and again in the matrix job that receives | ||
| # it. GitHub parses and re-serializes the record on the way, so the bytes | ||
| # differ, and the two digests agree only when the content is the same. | ||
| # | ||
| # Usage: jira-poll-record-digest.sh < record.json | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| jq -cSj . | sha256sum | awk '{print $1}' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # Dispatch side of the Jira poll batch check (jira-poll-batch-check.yml). | ||
| # | ||
| # Stands in for the harness-run job of reusable-dispatch.yml. It takes the | ||
| # matrix as a string input and turns it into one job per record with | ||
| # fromJSON(inputs.matrix), as that job does. Each job hashes the record it | ||
| # received and looks the digest up among the digests of the batch, where the | ||
| # real job would run an agent. | ||
| name: Jira poll batch check (dispatch) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| matrix: | ||
| description: Dispatch matrix, as reusable-dispatch.yml takes it. | ||
| type: string | ||
| required: true | ||
| digests: | ||
| description: JSON array with the digest of every record of the batch. | ||
| type: string | ||
| required: true | ||
|
|
||
| jobs: | ||
| record: | ||
| name: Record ${{ strategy.job-index }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: ${{ fromJSON(inputs.matrix) }} | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout the digest script | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
| sparse-checkout: | | ||
| .github/scripts/jira-poll-record-digest.sh | ||
| sparse-checkout-cone-mode: false | ||
|
|
||
| - name: Compare the record with the batch | ||
| env: | ||
| RECORD: ${{ toJSON(matrix) }} | ||
| DIGESTS: ${{ inputs.digests }} | ||
| INDEX: ${{ strategy.job-index }} | ||
| run: | | ||
| set -euo pipefail | ||
| digest=$(printf '%s' "${RECORD}" | .github/scripts/jira-poll-record-digest.sh) | ||
| if ! jq -e --arg digest "${digest}" 'index($digest) != null' <<<"${DIGESTS}" > /dev/null; then | ||
| echo "::error::record ${INDEX} (${digest}) is not a record of the batch" | ||
| exit 1 | ||
| fi | ||
| echo "Record ${INDEX} arrived unchanged (${digest})." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| # Poll side of the Jira poll batch check (jira-poll-batch-check.yml). | ||
| # | ||
| # Stands in for reusable-poll-jira.yml. The matrix job is that workflow's | ||
| # matrix job word for word, and the matrix is returned the same way: a step | ||
| # output, then that job's only output, then this workflow's output. What | ||
| # differs is the poll job, which builds dispatches.json with the real driver | ||
| # reading a fake Jira (hack/prove-jira-poll-batch) and saves it under the | ||
| # artifact name the real poll job uses. | ||
| # | ||
| # The record count, the digests and the size are outputs of the poll job, not | ||
| # of the matrix job, so they still arrive when GitHub rejects the matrix. | ||
| name: Jira poll batch check (poll) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| case: | ||
| description: Batch to build (a case of hack/prove-jira-poll-batch). | ||
| type: string | ||
| required: true | ||
| outputs: | ||
| matrix: | ||
| description: Dispatch matrix, returned as reusable-poll-jira.yml returns it. | ||
| value: ${{ jobs.matrix.outputs.matrix || '{"include":[]}' }} | ||
| count: | ||
| description: Number of records in the batch. | ||
| value: ${{ jobs.poll.outputs.dispatch_count }} | ||
| digests: | ||
| description: JSON array with the digest of every record (jira-poll-record-digest.sh). | ||
| value: ${{ jobs.poll.outputs.digests }} | ||
| bytes: | ||
| description: Size of the matrix in bytes of UTF-8. GitHub counts each one as two. | ||
| value: ${{ jobs.poll.outputs.bytes }} | ||
|
|
||
| jobs: | ||
| poll: | ||
| name: Poll a fake Jira | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 15 | ||
| permissions: | ||
| contents: read | ||
| outputs: | ||
| dispatch_count: ${{ steps.check.outputs.count }} | ||
| artifact_suffix: ${{ steps.check.outputs.artifact_suffix }} | ||
| digests: ${{ steps.check.outputs.digests }} | ||
| bytes: ${{ steps.check.outputs.bytes }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Run one poll cycle against a fake Jira | ||
| env: | ||
| CASE: ${{ inputs.case }} | ||
| TARGET_REPO: ${{ github.repository }} | ||
| run: go run ./hack/prove-jira-poll-batch -case "${CASE}" -target-repo "${TARGET_REPO}" -out dispatches.json | ||
|
|
||
| - name: Check dispatches | ||
| id: check | ||
| run: | | ||
| set -euo pipefail | ||
| matrix=$(jq -c '{include: .}' dispatches.json) | ||
| digests=$(jq -c '.[]' dispatches.json | while IFS= read -r record; do | ||
| printf '%s' "${record}" | .github/scripts/jira-poll-record-digest.sh | ||
| done | jq -Rcs 'split("\n") | map(select(. != ""))') | ||
| { | ||
| echo "artifact_suffix=$(openssl rand -hex 8)" | ||
| echo "count=$(jq length dispatches.json)" | ||
| echo "digests=${digests}" | ||
| echo "bytes=$(printf '%s' "${matrix}" | wc -c)" | ||
| } >> "${GITHUB_OUTPUT}" | ||
|
|
||
| - name: Save dispatches | ||
| uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 | ||
| with: | ||
| name: fullsend-jira-dispatches-${{ steps.check.outputs.artifact_suffix }} | ||
| path: dispatches.json | ||
| if-no-files-found: error | ||
| retention-days: 1 | ||
|
|
||
| matrix: | ||
| name: Build dispatch matrix | ||
| needs: poll | ||
| # "!= '0'", not "> 0": an empty (dropped) count still runs this job. | ||
| if: ${{ needs.poll.outputs.dispatch_count != '0' }} | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 15 | ||
| permissions: {} | ||
| outputs: | ||
| matrix: ${{ steps.matrix.outputs.matrix }} | ||
| steps: | ||
| # If both tries fail, "Re-run failed jobs" reads the artifact again | ||
| # while it is kept (1 day). "Re-run all jobs" would poll again and find | ||
| # nothing. | ||
| - name: Read dispatches | ||
| id: read | ||
| continue-on-error: true | ||
| uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 | ||
| with: | ||
| name: fullsend-jira-dispatches-${{ needs.poll.outputs.artifact_suffix }} | ||
|
|
||
| - name: Read dispatches (second try) | ||
| if: ${{ steps.read.outcome == 'failure' }} | ||
| uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 | ||
| with: | ||
| name: fullsend-jira-dispatches-${{ needs.poll.outputs.artifact_suffix }} | ||
|
|
||
| - name: Build dispatch matrix | ||
| id: matrix | ||
| run: | | ||
| set -euo pipefail | ||
| jq -e 'type == "array" and length > 0' dispatches.json > /dev/null | ||
| MATRIX=$(jq -c '{include: .}' dispatches.json) | ||
| DELIM="MATRIX_$(openssl rand -hex 8)" | ||
| { | ||
| echo "matrix<<${DELIM}" | ||
| printf '%s\n' "${MATRIX}" | ||
| echo "${DELIM}" | ||
| } >> "${GITHUB_OUTPUT}" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| # Full-size batch check for the Jira poll hand-off on GitHub (ADR 0085). | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] scope-bundling The diff against base feat/jirapoll-skip-idle has 39 files; most come from the stacked PRs below this one (#9758 through #9898), which the PR body names. Only the batch-check workflows, digest scripts, hack driver, docs section and Makefile line are this PR's own work. Suggested fix: Once the PRs below it have merged, rebase so the diff holds only this PR's changes; keep it in draft until then. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] scope-bundling The diff carries the batch-check workflows and proof harness together with the stacked Jira poller driver, config and docs changes (39 files). All of it serves the same ADR 0085 work, so this stays low; it should shrink as the stacked PRs below this one land. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] scope-bundling The PR bundles the standalone batch-check workflow, scripts and generator with the stacked Jira poller changes carried from the base branch. The PR body states it is stacked. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved by the review agent: this is an older copy of a finding that a newer review thread also carries: #9917 (comment) The finding is still open. Follow up in the newer thread. Resolving this duplicate. Unresolve it if you disagree. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [low] scope-bundling The diff bundles the batch-check workflows, digest scripts and generator with the Jira poller changes from the stacked, unmerged draft PRs below it. Same-domain bundling; stacking is disclosed. Suggested fix: Once the PRs below merge, rebase so the diff covers only the batch-check workflows, scripts and generator. |
||
| # | ||
| # The managed poll workflow passes a cycle's whole batch from the poll job to | ||
| # the dispatch job as one job output, and runs each record as one job of a | ||
| # matrix. GitHub limits a job's outputs to 1 MB and a matrix to 256 jobs, and | ||
| # a batch over either limit is lost whole. The jira-poll driver therefore | ||
| # keeps a cycle to at most 250 records and 768 KB. This workflow shows, on | ||
| # GitHub, that a batch at those limits arrives whole. | ||
| # | ||
| # It has the shape of the managed caller | ||
| # (internal/scaffold/fullsend-repo/templates/jira-poll-per-repo.yaml): a poll | ||
| # job that returns a matrix through a reusable workflow's output, and a | ||
| # dispatch job, under the same condition, that hands the matrix to a second | ||
| # reusable workflow as an input. Two things differ. The batch comes from the | ||
| # real driver reading a fake Jira (hack/prove-jira-poll-batch) instead of | ||
| # from a Jira site, and each record's job compares the record it received | ||
| # with the one the batch held instead of running an agent. | ||
| # | ||
| # Run it once per case when a change touches the limits, the record format or | ||
| # the hand-off. See "Jira poll batch check" in | ||
| # docs/guides/dev/testing-workflows.md. | ||
| name: Jira poll batch check | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| case: | ||
| description: Batch to send through the hand-off | ||
| type: choice | ||
| required: true | ||
| options: | ||
| - records | ||
| - size | ||
| - wide | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| poll: | ||
| permissions: | ||
| contents: read | ||
| uses: ./.github/workflows/jira-poll-batch-check-poll.yml | ||
| with: | ||
| case: ${{ inputs.case }} | ||
|
|
||
| dispatch: | ||
| needs: poll | ||
| if: ${{ needs.poll.outputs.matrix != '' && fromJSON(needs.poll.outputs.matrix).include[0] != null }} | ||
| permissions: | ||
| contents: read | ||
| uses: ./.github/workflows/jira-poll-batch-check-dispatch.yml | ||
| with: | ||
| matrix: ${{ needs.poll.outputs.matrix }} | ||
| digests: ${{ needs.poll.outputs.digests }} | ||
|
|
||
| verify: | ||
| name: Verify the batch arrived whole | ||
| needs: [poll, dispatch] | ||
| if: ${{ always() }} | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| actions: read | ||
| steps: | ||
| - name: Count the records that reached their own job | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| CASE: ${{ inputs.case }} | ||
| EXPECTED: ${{ needs.poll.outputs.count }} | ||
| BYTES: ${{ needs.poll.outputs.bytes }} | ||
| DISPATCH_RESULT: ${{ needs.dispatch.result }} | ||
| run: | | ||
| set -euo pipefail | ||
| echo "Case ${CASE}: ${EXPECTED} records in ${BYTES} bytes of UTF-8, which GitHub counts as $((2 * BYTES)) of the 1048576 a job's outputs may hold." | ||
| if [[ -z "${EXPECTED}" || "${EXPECTED}" -eq 0 ]]; then | ||
| echo "::error::the batch holds no records" | ||
| exit 1 | ||
| fi | ||
| if [[ "${DISPATCH_RESULT}" != "success" ]]; then | ||
| echo "::error::the dispatch job ended as '${DISPATCH_RESULT}': the batch did not arrive whole" | ||
| exit 1 | ||
| fi | ||
| arrived=$(gh api --paginate "repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/jobs?per_page=100" \ | ||
| --jq '.jobs[] | select(.name | contains("/ Record ")) | select(.conclusion == "success") | .name' | wc -l) | ||
| if [[ "${arrived}" -ne "${EXPECTED}" ]]; then | ||
| echo "::error::${arrived} records reached their own job unchanged, want ${EXPECTED}" | ||
| exit 1 | ||
| fi | ||
| echo "All ${EXPECTED} records reached their own job unchanged." | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[low] test-inadequate
Each matrix job only checks that its record digest appears somewhere in the batch digest list, not that it matches the digest expected at strategy.job-index; a batch [A, B] arriving as [A, A] would pass both the per-job check and the final count check.
Suggested fix: Compare the received digest with DIGESTS[INDEX], or check in the final job that the received digests are a permutation of the expected list.