Skip to content

Commit 8bb6037

Browse files
committed
feat: add Rslib
1 parent 3125e20 commit 8bb6037

18 files changed

Lines changed: 853 additions & 10 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: "Build Rslib"
2+
description: "Checkout, build rslib"
3+
inputs:
4+
repository:
5+
description: "The rslib repository to use"
6+
required: true
7+
default: "web-infra-dev/rslib"
8+
path:
9+
description: "Destination path to the rslib repository"
10+
required: true
11+
default: "workspace/rslib"
12+
ref:
13+
description: "The branch, tag or SHA to checkout"
14+
required: true
15+
default: "main"
16+
node-version:
17+
description: "The version of Node.js to set up"
18+
required: true
19+
default: "22"
20+
outputs:
21+
artifact-name:
22+
description: "The name of the uploaded artifact"
23+
runs:
24+
using: composite
25+
steps:
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 22
29+
- shell: bash
30+
name: Install package manager
31+
run: |
32+
npm install -g corepack@latest --force
33+
echo "Corepack version: $(corepack --version)"
34+
corepack enable
35+
36+
- name: Checkout Rslib repo
37+
uses: actions/checkout@v5
38+
with:
39+
repository: ${{ inputs.repository }}
40+
path: ${{ inputs.path }}
41+
ref: ${{ inputs.ref }}
42+
- name: Build Rslib
43+
shell: bash
44+
run: |
45+
cd ${{ inputs.path }}
46+
pnpm i
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: 'Eco CI Result'
2+
description: 'Fetch ecosystem CI jobs for a run and format a markdown summary'
3+
4+
inputs:
5+
workflow-output:
6+
description: 'JSON stringified output returned by trigger-workflow-and-wait'
7+
required: true
8+
owner:
9+
description: 'GitHub owner of the ecosystem CI repository'
10+
required: false
11+
default: 'rspack-contrib'
12+
repo:
13+
description: 'GitHub repository containing the ecosystem CI workflow'
14+
required: true
15+
job-prefix:
16+
description: 'Job name prefix to include in the summary table'
17+
required: false
18+
default: 'execute-all '
19+
heading:
20+
description: 'Short sentence describing the executed workflow'
21+
required: false
22+
default: 'Ran ecosystem CI'
23+
24+
outputs:
25+
result:
26+
description: 'Formatted markdown summary of the ecosystem CI jobs'
27+
value: ${{ steps.get-result.outputs.result }}
28+
29+
runs:
30+
using: composite
31+
steps:
32+
- id: get-result
33+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
34+
env:
35+
CI_OUTPUT: ${{ inputs.workflow-output }}
36+
OWNER: ${{ inputs.owner }}
37+
REPO: ${{ inputs.repo }}
38+
JOB_PREFIX: ${{ inputs.job-prefix }}
39+
HEADING: ${{ inputs.heading }}
40+
with:
41+
script: |
42+
const owner = process.env.OWNER;
43+
const repo = process.env.REPO;
44+
const jobPrefix = process.env.JOB_PREFIX ?? 'execute-all ';
45+
const heading = process.env.HEADING ?? 'Ran ecosystem CI';
46+
47+
if (!owner || !repo) {
48+
throw new Error('eco-ci-result requires both owner and repo inputs');
49+
}
50+
51+
let runId;
52+
try {
53+
const parsed = JSON.parse(process.env.CI_OUTPUT);
54+
runId = parsed?.workflow_id ?? parsed?.runId ?? parsed?.run_id;
55+
} catch (error) {
56+
throw new Error(`failed to parse workflow output: ${error}`);
57+
}
58+
59+
if (!runId) {
60+
return 'cannot determine workflow run id';
61+
}
62+
63+
const { data: { jobs } = {} } =
64+
await github.rest.actions.listJobsForWorkflowRun({
65+
owner,
66+
repo,
67+
run_id: runId,
68+
});
69+
70+
if (!jobs?.length) {
71+
return 'cannot find CI result';
72+
}
73+
74+
const result = jobs
75+
.filter((job) => job.name?.startsWith(jobPrefix))
76+
.map((job) => {
77+
let suiteName = job.name.substring(jobPrefix.length);
78+
if (suiteName.startsWith('(') && suiteName.endsWith(')')) {
79+
suiteName = suiteName.slice(1, -1);
80+
}
81+
return {
82+
suite: suiteName,
83+
conclusion: job.conclusion,
84+
link: job.html_url,
85+
};
86+
});
87+
88+
const url = `https://github.com/${owner}/${repo}/actions/runs/${runId}`;
89+
const urlLink = `[Open](${url})`;
90+
91+
const conclusionEmoji = {
92+
success: ':white_check_mark:',
93+
failure: ':x:',
94+
cancelled: ':stop_button:',
95+
};
96+
97+
const rows = result
98+
.map(
99+
(r) =>
100+
`| [${r.suite}](${r.link}) | ${conclusionEmoji[r.conclusion] ?? ''} ${r.conclusion} |`,
101+
)
102+
.join('\n');
103+
104+
const body = `
105+
📝 ${heading}: ${urlLink}
106+
107+
| suite | result |
108+
|-------|--------|
109+
${rows}
110+
`;
111+
112+
return body;
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: 'ecosystem_ci_auto_run_commit'
2+
description: 'Trigger downstream ecosystem CI for commits and comment on failures'
3+
4+
inputs:
5+
github-token:
6+
description: 'Token with access to the downstream ecosystem CI repository'
7+
required: true
8+
ecosystem-owner:
9+
description: 'Owner of the downstream ecosystem CI repository'
10+
required: false
11+
default: 'rspack-contrib'
12+
ecosystem-repo:
13+
description: 'Repository containing the downstream workflow'
14+
required: true
15+
workflow-file:
16+
description: 'Workflow file to execute in the downstream repository'
17+
required: true
18+
workflow-ref:
19+
description: 'Ref to use when triggering the downstream workflow'
20+
required: false
21+
default: 'main'
22+
client-payload:
23+
description: 'JSON payload passed to the downstream workflow dispatch'
24+
required: false
25+
default: '{}'
26+
result-heading:
27+
description: 'Heading to use in the formatted summary output'
28+
required: false
29+
default: 'Ran ecosystem CI'
30+
job-name-prefix:
31+
description: 'Job name prefix to match when summarizing downstream jobs'
32+
required: false
33+
default: 'execute-all '
34+
commit-comment-on-failure:
35+
description: 'Set to true to create a commit comment when the downstream workflow fails'
36+
required: false
37+
default: 'true'
38+
commit-sha:
39+
description: 'Commit SHA to comment on when commit-comment-on-failure is enabled; defaults to the current SHA'
40+
required: false
41+
default: ''
42+
fail-on-failure:
43+
description: 'Fail this job when the downstream workflow reports a failure'
44+
required: false
45+
default: 'false'
46+
47+
outputs:
48+
workflow-id:
49+
description: 'ID of the triggered downstream workflow run'
50+
value: ${{ steps.trigger.outputs.workflow_id }}
51+
workflow-url:
52+
description: 'URL of the triggered downstream workflow run'
53+
value: ${{ steps.trigger.outputs.workflow_url }}
54+
conclusion:
55+
description: 'Conclusion reported by the downstream workflow'
56+
value: ${{ steps.trigger.outputs.conclusion }}
57+
summary:
58+
description: 'Formatted markdown summary of downstream job results'
59+
value: ${{ steps.summarize.outputs.result }}
60+
61+
runs:
62+
using: composite
63+
steps:
64+
- id: trigger
65+
name: Trigger downstream workflow
66+
uses: convictional/trigger-workflow-and-wait@f69fa9eedd3c62a599220f4d5745230e237904be # v1.6.5
67+
continue-on-error: true
68+
with:
69+
owner: ${{ inputs.ecosystem-owner }}
70+
repo: ${{ inputs.ecosystem-repo }}
71+
workflow_file_name: ${{ inputs.workflow-file }}
72+
ref: ${{ inputs.workflow-ref }}
73+
github_token: ${{ inputs.github-token }}
74+
client_payload: ${{ inputs.client-payload }}
75+
76+
- id: summarize
77+
if: ${{ always() }}
78+
name: Summarize downstream jobs
79+
uses: ../ecosystem-ci-result
80+
with:
81+
owner: ${{ inputs.ecosystem-owner }}
82+
repo: ${{ inputs.ecosystem-repo }}
83+
job-prefix: ${{ inputs.job-name-prefix }}
84+
heading: ${{ inputs.result-heading }}
85+
workflow-output: ${{ toJson(steps.trigger.outputs) }}
86+
87+
- id: commit-comment
88+
if: ${{ always() && inputs.commit-comment-on-failure == 'true' && steps.trigger.outputs.conclusion == 'failure' }}
89+
name: Create commit comment on failure
90+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
91+
env:
92+
SUMMARY: ${{ steps.summarize.outputs.result }}
93+
COMMIT_SHA: ${{ inputs.commit-sha != '' && inputs.commit-sha || github.sha }}
94+
with:
95+
script: |
96+
const summary = process.env.SUMMARY?.trim();
97+
if (!summary || summary.includes('cannot determine workflow run id')) {
98+
core.warning('Downstream workflow failed but no summary is available to comment');
99+
return;
100+
}
101+
102+
const commitSha = process.env.COMMIT_SHA;
103+
if (!commitSha) {
104+
core.warning('No commit SHA provided for failure comment');
105+
return;
106+
}
107+
108+
await github.rest.repos.createCommitComment({
109+
owner: context.repo.owner,
110+
repo: context.repo.repo,
111+
commit_sha: commitSha,
112+
body: summary,
113+
});
114+
115+
- if: ${{ always() && inputs.fail-on-failure == 'true' && steps.trigger.outputs.conclusion == 'failure' }}
116+
name: Fail when downstream workflow fails
117+
shell: bash
118+
run: |
119+
echo "::error::Downstream ecosystem CI workflow reported a failure"
120+
exit 1

0 commit comments

Comments
 (0)