Skip to content

Commit 28dfd58

Browse files
ai: apply changes for #882 (1 review thread)
Addresses: - #3654256027 at .github/workflows/skip-checks-reporter.yml:39 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent ad9ae36 commit 28dfd58

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

.github/workflows/skip-checks-reporter.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,64 @@ jobs:
4242
labels: linux-ubuntu-latest
4343
permissions:
4444
checks: write
45+
contents: read
46+
pull-requests: read
4547
steps:
48+
# The reporter triggers on EVERY pull_request run of "Trigger Integration
49+
# Tests" (opened/synchronize/reopened/labeled/closed), but the
50+
# workflow_run payload does NOT expose the originating sub-action, so we
51+
# cannot filter on it directly. Recover the needed context from the PR
52+
# and post the synthetic success only for the opened/synchronize/reopened
53+
# scope the old inline job covered:
54+
# - skip when the PR is closed (outside the old job's scope), and
55+
# - skip when a real label preview is running for this head (an internal
56+
# PR carrying the integration-test label): trigger-tests-pr dispatches
57+
# the real suite and driver-test posts the real check for the same
58+
# app + name + head_sha, so a premature success placeholder would race
59+
# that check and could mask a real preview failure.
60+
# Fork PRs KEEP the placeholder even when labeled: their label preview
61+
# cannot dispatch (no secret access), so nothing else posts the required
62+
# check for them. This is a read-only lookup (no checkout / no execution
63+
# of PR-controlled content) and does not weaken the SECURITY note above.
64+
- name: Decide whether to post the placeholder
65+
id: gate
66+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
67+
env:
68+
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
69+
with:
70+
script: |
71+
let prs = context.payload.workflow_run.pull_requests || [];
72+
let number = prs.length ? prs[0].number : null;
73+
if (number === null) {
74+
// Fork PRs: workflow_run.pull_requests is empty. Resolve by SHA.
75+
const { data } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
76+
owner: context.repo.owner,
77+
repo: context.repo.repo,
78+
commit_sha: process.env.HEAD_SHA,
79+
});
80+
number = data.length ? data[0].number : null;
81+
}
82+
if (number === null) {
83+
// No PR resolvable (unexpected) — default to posting so the
84+
// required check isn't left unfulfilled.
85+
core.setOutput('post', 'true');
86+
return;
87+
}
88+
const { data: pr } = await github.rest.pulls.get({
89+
owner: context.repo.owner,
90+
repo: context.repo.repo,
91+
pull_number: number,
92+
});
93+
const isFork = pr.head.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`;
94+
const hasLabel = pr.labels.some(l => l.name === 'integration-test');
95+
const isClosed = pr.state === 'closed';
96+
const skip = isClosed || (hasLabel && !isFork);
97+
console.log(`PR #${number} fork=${isFork} label=${hasLabel} closed=${isClosed} -> post=${!skip}`);
98+
core.setOutput('post', (!skip).toString());
99+
46100
- name: Generate GitHub App token (this repo)
47101
id: app-token
102+
if: steps.gate.outputs.post == 'true'
48103
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
49104
with:
50105
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
@@ -53,6 +108,7 @@ jobs:
53108
repositories: databricks-sql-python
54109

55110
- name: Post skipped Python Integration Tests check
111+
if: steps.gate.outputs.post == 'true'
56112
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
57113
env:
58114
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}

0 commit comments

Comments
 (0)