Skip to content

Commit bd7fc16

Browse files
committed
ci: use unified Rstack ecosystem CI
1 parent a117cd5 commit bd7fc16

File tree

2 files changed

+214
-144
lines changed

2 files changed

+214
-144
lines changed
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
name: Ecosystem CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
workflow_dispatch:
8+
inputs:
9+
branch:
10+
description: 'The branch of the Ecosystem CI run'
11+
required: true
12+
default: 'main'
13+
14+
permissions:
15+
# Allow commenting on commits
16+
contents: write
17+
# Allow commenting on issues
18+
issues: write
19+
# Allow commenting on PR
20+
pull-requests: write
21+
22+
jobs:
23+
changes:
24+
runs-on: ubuntu-latest
25+
if: github.repository == 'web-infra-dev/rstest' && github.event_name != 'workflow_dispatch'
26+
outputs:
27+
changed: ${{ steps.changes.outputs.changed }}
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
31+
with:
32+
fetch-depth: 1
33+
34+
- name: Install Pnpm
35+
run: |
36+
npm install -g corepack@latest --force
37+
corepack enable
38+
39+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
40+
id: changes
41+
with:
42+
predicate-quantifier: 'every'
43+
filters: |
44+
changed:
45+
- "!**/*.md"
46+
- "!**/*.mdx"
47+
- "!**/_meta.json"
48+
- "!**/dictionary.txt"
49+
50+
ecosystem_ci_notify:
51+
name: Run Ecosystem CI With Notify
52+
needs: changes
53+
runs-on: ubuntu-latest
54+
if: github.repository == 'web-infra-dev/rstest' && github.event_name != 'workflow_dispatch' && needs.changes.outputs.changed == 'true'
55+
steps:
56+
- name: Run Ecosystem CI with notify
57+
id: eco_ci
58+
continue-on-error: true
59+
uses: convictional/trigger-workflow-and-wait@f69fa9eedd3c62a599220f4d5745230e237904be # v1.6.5
60+
with:
61+
owner: 'rspack-contrib'
62+
repo: 'rstest-ecosystem-ci'
63+
workflow_file_name: 'ecosystem-ci-from-commit.yml'
64+
github_token: ${{ secrets.REPO_RSTEST_ECO_CI_GITHUB_TOKEN }}
65+
ref: 'main'
66+
client_payload: '{"commitSHA":"${{ github.sha }}","updateComment":true,"repo":"web-infra-dev/rstest","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'
67+
68+
- name: Checkout
69+
if: steps.eco_ci.outcome == 'failure'
70+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
71+
with:
72+
fetch-depth: 1
73+
74+
- name: Install Pnpm
75+
run: |
76+
npm install -g corepack@latest --force
77+
corepack enable
78+
79+
- name: Setup Node.js
80+
if: steps.eco_ci.outcome == 'failure'
81+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
82+
with:
83+
node-version: 22
84+
cache: 'pnpm'
85+
86+
- name: Get CI Result
87+
id: eco-ci-result
88+
if: steps.eco_ci.outcome == 'failure'
89+
uses: ./.github/actions/eco-ci-result
90+
with:
91+
workflow-output: ${{ toJson(steps.eco_ci.outputs) }}
92+
93+
- id: create-commit-comment
94+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
95+
if: steps.eco_ci.outcome == 'failure'
96+
name: Create Commit Comment
97+
with:
98+
script: |
99+
await github.rest.repos.createCommitComment({
100+
commit_sha: context.sha,
101+
owner: 'web-infra-dev',
102+
repo: 'rstest',
103+
body: ${{ steps.eco-ci-result.outputs.result }}
104+
})
105+
106+
ecosystem_ci:
107+
name: Run Ecosystem CI
108+
runs-on: ubuntu-latest
109+
if: github.repository == 'web-infra-dev/rstest' && github.event_name == 'workflow_dispatch'
110+
steps:
111+
- id: get-pr-number
112+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
113+
name: Get PR Number
114+
with:
115+
script: |
116+
const { data: prs } = await github.rest.pulls.list({
117+
owner: context.repo.owner,
118+
repo: context.repo.repo,
119+
})
120+
121+
const pr = prs.find(pr => pr.head.ref === context.payload.inputs.branch);
122+
123+
if(pr) {
124+
console.log(`Get PR info: ${pr.url}`)
125+
126+
return {
127+
num: pr.number,
128+
branchName: pr.head.ref,
129+
repo: pr.head.repo.full_name
130+
}
131+
} else {
132+
console.log(`can't find PR for branch: ${context.payload.inputs.branch}`)
133+
}
134+
135+
- id: create-comment
136+
name: Create Comment
137+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
138+
if: steps.get-pr-number.outputs.result
139+
with:
140+
result-encoding: string
141+
script: |
142+
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
143+
const urlLink = `[Open](${url})`
144+
const prData = ${{ steps.get-pr-number.outputs.result }}
145+
146+
const { data: comment } = await github.rest.issues.createComment({
147+
issue_number: prData.num,
148+
owner: 'web-infra-dev',
149+
repo: 'rstest',
150+
body: `⏳ Triggered ecosystem CI: ${urlLink}`
151+
})
152+
return comment.id
153+
154+
- name: Run Ecosystem CI
155+
id: eco_ci
156+
uses: convictional/trigger-workflow-and-wait@f69fa9eedd3c62a599220f4d5745230e237904be # v1.6.5
157+
continue-on-error: true
158+
with:
159+
owner: 'rspack-contrib'
160+
repo: 'rstest-ecosystem-ci'
161+
workflow_file_name: 'ecosystem-ci-selected.yml'
162+
github_token: ${{ secrets.REPO_RSTEST_ECO_CI_GITHUB_TOKEN }}
163+
ref: 'main'
164+
client_payload: '{"ref":"${{ github.event.inputs.branch }}","repo":"web-infra-dev/rstest","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'
165+
166+
- name: Checkout
167+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
168+
with:
169+
fetch-depth: 1
170+
171+
- id: eco-ci-result
172+
uses: ./.github/actions/eco-ci-result
173+
name: Get CI Result
174+
with:
175+
workflow-output: ${{ toJson(steps.eco_ci.outputs) }}
176+
177+
- id: update-comment
178+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
179+
if: steps.get-pr-number.outputs.result
180+
name: Update Comment
181+
with:
182+
script: |
183+
await github.rest.issues.updateComment({
184+
owner: 'web-infra-dev',
185+
repo: 'rstest',
186+
comment_id: ${{ steps.create-comment.outputs.result }},
187+
body: ${{ steps.eco-ci-result.outputs.result }}
188+
})

.github/workflows/ecosystem-ci.yml

Lines changed: 26 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ name: Ecosystem CI
22

33
on:
44
push:
5-
branches: [main]
6-
5+
branches: ['main']
76
workflow_dispatch:
87
inputs:
98
branch:
@@ -12,11 +11,8 @@ on:
1211
default: 'main'
1312

1413
permissions:
15-
# Allow commenting on commits
1614
contents: write
17-
# Allow commenting on issues
1815
issues: write
19-
# Allow commenting on PR
2016
pull-requests: write
2117

2218
jobs:
@@ -27,15 +23,10 @@ jobs:
2723
changed: ${{ steps.changes.outputs.changed }}
2824
steps:
2925
- name: Checkout
30-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
26+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
3127
with:
3228
fetch-depth: 1
3329

34-
- name: Install Pnpm
35-
run: |
36-
npm install -g corepack@latest --force
37-
corepack enable
38-
3930
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
4031
id: changes
4132
with:
@@ -46,143 +37,34 @@ jobs:
4637
- "!**/*.mdx"
4738
- "!**/_meta.json"
4839
- "!**/dictionary.txt"
40+
- "!document/**"
4941
50-
ecosystem_ci_notify:
51-
name: Run Ecosystem CI With Notify
52-
needs: changes
42+
ecosystem_ci_dispatch:
43+
name: Dispatch ecosystem CI
5344
runs-on: ubuntu-latest
54-
if: github.repository == 'web-infra-dev/rstest' && github.event_name != 'workflow_dispatch' && needs.changes.outputs.changed == 'true'
45+
if: github.repository == 'web-infra-dev/rstets' && github.event_name == 'workflow_dispatch'
5546
steps:
56-
- name: Run Ecosystem CI with notify
57-
id: eco_ci
58-
continue-on-error: true
59-
uses: convictional/trigger-workflow-and-wait@f69fa9eedd3c62a599220f4d5745230e237904be # v1.6.5
60-
with:
61-
owner: 'rspack-contrib'
62-
repo: 'rstest-ecosystem-ci'
63-
workflow_file_name: 'ecosystem-ci-from-commit.yml'
64-
github_token: ${{ secrets.REPO_RSTEST_ECO_CI_GITHUB_TOKEN }}
65-
ref: 'main'
66-
client_payload: '{"commitSHA":"${{ github.sha }}","updateComment":true,"repo":"web-infra-dev/rstest","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'
67-
68-
- name: Checkout
69-
if: steps.eco_ci.outcome == 'failure'
70-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
71-
with:
72-
fetch-depth: 1
73-
74-
- name: Install Pnpm
75-
run: |
76-
npm install -g corepack@latest --force
77-
corepack enable
78-
79-
- name: Setup Node.js
80-
if: steps.eco_ci.outcome == 'failure'
81-
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
82-
with:
83-
node-version: 22
84-
cache: 'pnpm'
85-
86-
- name: Get CI Result
87-
id: eco-ci-result
88-
if: steps.eco_ci.outcome == 'failure'
89-
uses: ./.github/actions/eco-ci-result
47+
- name: Trigger Ecosystem CI
48+
uses: rspack-contrib/rstack-ecosystem-ci/.github/actions/ecosystem_ci_dispatch@main
9049
with:
91-
workflow-output: ${{ toJson(steps.eco_ci.outputs) }}
92-
93-
- id: create-commit-comment
94-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
95-
if: steps.eco_ci.outcome == 'failure'
96-
name: Create Commit Comment
97-
with:
98-
script: |
99-
await github.rest.repos.createCommitComment({
100-
commit_sha: context.sha,
101-
owner: 'web-infra-dev',
102-
repo: 'rstest',
103-
body: ${{ steps.eco-ci-result.outputs.result }}
104-
})
105-
106-
ecosystem_ci:
107-
name: Run Ecosystem CI
50+
github-token: ${{ secrets.REPO_RSTEST_ECO_CI_GITHUB_TOKEN_NEXT }}
51+
ecosystem-owner: web-infra-dev
52+
ecosystem-repo: rstets
53+
workflow-file: rstets-ecosystem-ci-selected.yml
54+
client-payload: '{"ref":"${{ github.event.inputs.branch }}","repo":"web-infra-dev/rstets","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'
55+
branch: ${{ github.event.inputs.branch }}
56+
57+
ecosystem_ci_per_commit:
58+
name: Run ecosystem CI per commit
59+
needs: changes
10860
runs-on: ubuntu-latest
109-
if: github.repository == 'web-infra-dev/rstest' && github.event_name == 'workflow_dispatch'
61+
if: github.repository == 'web-infra-dev/rstets' && github.event_name != 'workflow_dispatch' && needs.changes.outputs.changed == 'true'
11062
steps:
111-
- id: get-pr-number
112-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
113-
name: Get PR Number
114-
with:
115-
script: |
116-
const { data: prs } = await github.rest.pulls.list({
117-
owner: context.repo.owner,
118-
repo: context.repo.repo,
119-
})
120-
121-
const pr = prs.find(pr => pr.head.ref === context.payload.inputs.branch);
122-
123-
if(pr) {
124-
console.log(`Get PR info: ${pr.url}`)
125-
126-
return {
127-
num: pr.number,
128-
branchName: pr.head.ref,
129-
repo: pr.head.repo.full_name
130-
}
131-
} else {
132-
console.log(`can't find PR for branch: ${context.payload.inputs.branch}`)
133-
}
134-
135-
- id: create-comment
136-
name: Create Comment
137-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
138-
if: steps.get-pr-number.outputs.result
139-
with:
140-
result-encoding: string
141-
script: |
142-
const url = `${context.serverUrl}//${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`
143-
const urlLink = `[Open](${url})`
144-
const prData = ${{ steps.get-pr-number.outputs.result }}
145-
146-
const { data: comment } = await github.rest.issues.createComment({
147-
issue_number: prData.num,
148-
owner: 'web-infra-dev',
149-
repo: 'rstest',
150-
body: `⏳ Triggered ecosystem CI: ${urlLink}`
151-
})
152-
return comment.id
153-
154-
- name: Run Ecosystem CI
155-
id: eco_ci
156-
uses: convictional/trigger-workflow-and-wait@f69fa9eedd3c62a599220f4d5745230e237904be # v1.6.5
157-
continue-on-error: true
158-
with:
159-
owner: 'rspack-contrib'
160-
repo: 'rstest-ecosystem-ci'
161-
workflow_file_name: 'ecosystem-ci-selected.yml'
162-
github_token: ${{ secrets.REPO_RSTEST_ECO_CI_GITHUB_TOKEN }}
163-
ref: 'main'
164-
client_payload: '{"ref":"${{ github.event.inputs.branch }}","repo":"web-infra-dev/rstest","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'
165-
166-
- name: Checkout
167-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
168-
with:
169-
fetch-depth: 1
170-
171-
- id: eco-ci-result
172-
uses: ./.github/actions/eco-ci-result
173-
name: Get CI Result
174-
with:
175-
workflow-output: ${{ toJson(steps.eco_ci.outputs) }}
176-
177-
- id: update-comment
178-
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
179-
if: steps.get-pr-number.outputs.result
180-
name: Update Comment
63+
- name: Trigger Ecosystem CI
64+
uses: rspack-contrib/rstack-ecosystem-ci/.github/actions/ecosystem_ci_per_commit@main
18165
with:
182-
script: |
183-
await github.rest.issues.updateComment({
184-
owner: 'web-infra-dev',
185-
repo: 'rstest',
186-
comment_id: ${{ steps.create-comment.outputs.result }},
187-
body: ${{ steps.eco-ci-result.outputs.result }}
188-
})
66+
github-token: ${{ secrets.REPO_RSTEST_ECO_CI_GITHUB_TOKEN_NEXT }}
67+
ecosystem-owner: web-infra-dev
68+
ecosystem-repo: rstets
69+
workflow-file: rstets-ecosystem-ci-from-commit.yml
70+
client-payload: '{"commitSHA":"${{ github.sha }}","updateComment":true,"repo":"web-infra-dev/rstets","suite":"-","suiteRefType":"precoded","suiteRef":"precoded"}'

0 commit comments

Comments
 (0)