Skip to content

Commit ea152fe

Browse files
committed
post-test-status in workflow dispatch
1 parent f62492e commit ea152fe

2 files changed

Lines changed: 72 additions & 24 deletions

File tree

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Post Test Status
2+
3+
# This workflow runs in the base repo context (with write permissions)
4+
# even for fork PRs, allowing us to post commit statuses.
5+
#
6+
# Add any status posting for skipped jobs here to avoid "Resource not
7+
# accessible by integration" errors when PRs come from forks.
8+
9+
on:
10+
workflow_run:
11+
workflows: ["Dash Testing"]
12+
types:
13+
- completed
14+
15+
jobs:
16+
post-skipped-statuses:
17+
name: Post Statuses for Skipped Jobs
18+
runs-on: ubuntu-latest
19+
if: github.event.workflow_run.event == 'pull_request'
20+
permissions:
21+
statuses: write
22+
actions: read
23+
steps:
24+
- name: Post statuses for skipped jobs
25+
uses: actions/github-script@v7
26+
with:
27+
script: |
28+
const { owner, repo } = context.repo;
29+
const runId = context.payload.workflow_run.id;
30+
const headSha = context.payload.workflow_run.head_sha;
31+
32+
// Define jobs that need a success status posted when skipped
33+
// Format: { jobName: 'GitHub Job Name', statusContext: 'status/context-name', description: 'Description' }
34+
const skippedStatusJobs = [
35+
{
36+
jobName: 'Dash Table Visual Tests',
37+
statusContext: 'percy/dash-table-test',
38+
description: 'Skipped — no dash-table changes'
39+
}
40+
// Add more jobs here as needed:
41+
// {
42+
// jobName: 'Job Name',
43+
// statusContext: 'context/name',
44+
// description: 'Skipped — reason'
45+
// }
46+
];
47+
48+
// Get all jobs for the workflow run
49+
const { data: { jobs } } = await github.rest.actions.listJobsForWorkflowRun({
50+
owner,
51+
repo,
52+
run_id: runId,
53+
});
54+
55+
// Post status for each skipped job
56+
for (const { jobName, statusContext, description } of skippedStatusJobs) {
57+
const job = jobs.find(j => j.name === jobName);
58+
59+
if (job && job.conclusion === 'skipped') {
60+
await github.rest.repos.createCommitStatus({
61+
owner,
62+
repo,
63+
sha: headSha,
64+
state: 'success',
65+
context: statusContext,
66+
description: description,
67+
});
68+
console.log(`Posted skipped status for ${statusContext}`);
69+
} else {
70+
console.log(`Job "${jobName}" status: ${job?.conclusion ?? 'not found'} - no status posted`);
71+
}
72+
}

.github/workflows/testing.yml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -918,30 +918,6 @@ jobs:
918918
if: env.PERCY_TOKEN == ''
919919
run: echo "::notice::Skipping Percy finalize (no token available - likely a fork PR)"
920920

921-
report-table-percy-skipped:
922-
name: Report Percy Table Skipped
923-
needs: table-visual-test
924-
runs-on: ubuntu-latest
925-
if: |
926-
always() &&
927-
github.event_name == 'pull_request' &&
928-
needs.table-visual-test.result == 'skipped'
929-
permissions:
930-
statuses: write
931-
steps:
932-
- name: Post success status for percy/dash-table-test
933-
uses: actions/github-script@v7
934-
with:
935-
script: |
936-
await github.rest.repos.createCommitStatus({
937-
owner: context.repo.owner,
938-
repo: context.repo.repo,
939-
sha: context.payload.pull_request.head.sha,
940-
state: 'success',
941-
context: 'percy/dash-table-test',
942-
description: 'Skipped — no dash-table changes',
943-
});
944-
945921
test-report:
946922
name: Consolidated Test Report
947923
needs: [lint-unit, test-main, dcc-test, html-test, table-server, background-callbacks, test-typing]

0 commit comments

Comments
 (0)