Skip to content

Commit e523955

Browse files
committed
Replace third-party github action with github script
1 parent 57563c7 commit e523955

1 file changed

Lines changed: 38 additions & 7 deletions

File tree

.github/workflows/ci-unittests.yml

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,45 @@ jobs:
1616
- name: Check file changes
1717
id: changes
1818
if: github.event_name == 'pull_request'
19-
uses: dorny/paths-filter@v3
19+
uses: actions/github-script@v8
2020
with:
21-
filters: |
22-
workflow_or_suite:
23-
- '.github/**'
24-
- 'mx.graalpython/suite.py'
21+
script: |
22+
const pr = context.payload.pull_request;
23+
if (!pr) {
24+
core.setOutput('workflow_or_suite', 'false');
25+
core.setOutput('docs_only', 'false');
26+
return;
27+
}
28+
29+
const changedFiles = await github.paginate(
30+
github.rest.pulls.listFiles,
31+
{
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
pull_number: pr.number,
35+
per_page: 100,
36+
}
37+
);
38+
39+
const hasWorkflowOrSuiteChanges = changedFiles.some(file =>
40+
file.filename.startsWith('.github/') || file.filename === 'mx.graalpython/suite.py'
41+
);
42+
const hasOnlyDocsChanges = changedFiles.length > 0 && changedFiles.every(file => file.filename.startsWith('docs/'));
43+
44+
core.setOutput('workflow_or_suite', hasWorkflowOrSuiteChanges ? 'true' : 'false');
45+
core.setOutput('docs_only', hasOnlyDocsChanges ? 'true' : 'false');
2546
2647
- name: Check if workflow should run
2748
id: decision
2849
uses: actions/github-script@v8
2950
env:
3051
HAS_WORKFLOW_OR_SUITE_CHANGES: ${{ steps.changes.outputs.workflow_or_suite || 'false' }}
52+
HAS_ONLY_DOCS_CHANGES: ${{ steps.changes.outputs.docs_only || 'false' }}
3153
with:
3254
script: |
3355
const eventName = context.eventName;
3456
const hasWorkflowOrSuiteChanges = process.env.HAS_WORKFLOW_OR_SUITE_CHANGES === 'true';
57+
const hasOnlyDocsChanges = process.env.HAS_ONLY_DOCS_CHANGES === 'true';
3558
3659
if (eventName === 'workflow_dispatch') {
3760
core.setOutput('run_ci', 'true');
@@ -53,6 +76,12 @@ jobs:
5376
return;
5477
}
5578
79+
if (hasOnlyDocsChanges) {
80+
core.setOutput('run_ci', 'false');
81+
core.setOutput('reason', 'docs-only changes');
82+
return;
83+
}
84+
5685
if (hasWorkflowOrSuiteChanges) {
5786
core.setOutput('run_ci', 'true');
5887
core.setOutput('reason', '.github or suite.py changes');
@@ -84,6 +113,7 @@ jobs:
84113
85114
abi-check:
86115
if: needs.should-run.outputs.run_ci == 'true'
116+
needs: should-run
87117
runs-on: ubuntu-latest
88118
steps:
89119
- uses: actions/checkout@v6
@@ -114,6 +144,7 @@ jobs:
114144

115145
build-standalone-artifacts:
116146
if: needs.should-run.outputs.run_ci == 'true' && success()
147+
needs: should-run
117148
uses: ./.github/workflows/ci-matrix-gen.yml
118149
with:
119150
jobs_to_run: ^(?:python-svm-build|style|style-ecj)-gate-.*$
@@ -122,15 +153,15 @@ jobs:
122153

123154
run-tests:
124155
if: needs.should-run.outputs.run_ci == 'true' && success()
125-
needs: build-standalone-artifacts
156+
needs: [should-run, build-standalone-artifacts]
126157
uses: ./.github/workflows/ci-matrix-gen.yml
127158
with:
128159
jobs_to_run: ^(?!python-svm-build|style).*-gate.*$
129160
export_test_reports: true
130161

131162
collect-reports:
132163
if: needs.should-run.outputs.run_ci == 'true' && always()
133-
needs: run-tests
164+
needs: [should-run, run-tests]
134165
runs-on: ubuntu-latest
135166
steps:
136167
- uses: actions/checkout@v6

0 commit comments

Comments
 (0)