Skip to content

Commit 397f496

Browse files
authored
ci: fix publish hybridse test result from fork (#3738)
1 parent ff3ef0d commit 397f496

8 files changed

+60
-42
lines changed

.github/workflows/cicd.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ jobs:
204204
path: openmldb-*.tar.gz
205205
name: release-artifacts
206206

207+
- name: Upload Event File
208+
if: always()
209+
uses: actions/upload-artifact@v3
210+
with:
211+
name: event-file
212+
path: ${{ github.event_path }}
213+
207214
release:
208215
runs-on: ubuntu-latest
209216
# if test failed, shouldn't release

.github/workflows/hybridse-ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
# this option enables print inner output rows of each node in runner
5858
HYBRIDSE_DEBUG: true
5959
steps:
60-
- uses: actions/checkout@v3
60+
- uses: actions/checkout@v4
6161

6262
- name: Install dependencies
6363
run: |
@@ -79,6 +79,13 @@ jobs:
7979
run: |
8080
make hybridse-test
8181
82+
- name: Upload Event File
83+
if: always()
84+
uses: actions/upload-artifact@v3
85+
with:
86+
name: event-file
87+
path: ${{ github.event_path }}
88+
8289
- name: Upload Cpp UT Results
8390
if: always()
8491
uses: actions/upload-artifact@v3
@@ -89,7 +96,7 @@ jobs:
8996
9097
publish-test-results-linux:
9198
needs: ["linux-build"]
92-
# the action will only run on 4paradigm/HybridSE's context, not for fork repo or dependabot
99+
# the action will only run on 4paradigm/OpenMLDB's context, not for fork repo or dependabot
93100
if: >
94101
always() && github.event_name == 'push' || (
95102
github.event.pull_request.head.repo.full_name == github.repository &&
@@ -104,7 +111,7 @@ jobs:
104111

105112
publish-test-results-mac:
106113
needs: ["macos-build"]
107-
# the action will only run on 4paradigm/HybridSE's context, not for fork repo or dependabot
114+
# the action will only run on 4paradigm/OpenMLDB's context, not for fork repo or dependabot
108115
if: >
109116
always() && github.event_name == 'push' || (
110117
github.event.pull_request.head.repo.full_name == github.repository &&

.github/workflows/publish-test-result-from-fork.yml renamed to .github/workflows/publish-cicd-test-result-from-fork.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ jobs:
2121
files: artifacts/linux-ut-result-*/**/*.xml
2222
check_name: Linux Test Report
2323
comment_title: Linux Test Report
24+
event_name: ${{ github.event.workflow_run.event }}
25+
run_id: ${{ github.event.workflow_run.id }}

.github/workflows/publish-hybridse-test-result-from-fork.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
files: artifacts/linux-ut-result-*/**/*.xml
2222
check_name: HybridSE Linux Test Report
2323
comment_title: HybridSE Linux Test Report
24+
event_name: ${{ github.event.workflow_run.event }}
25+
run_id: ${{ github.event.workflow_run.id }}
2426

2527
test-results-mac:
2628
if: >
@@ -31,7 +33,9 @@ jobs:
3133
name: Publish HybridSE Mac UT Results
3234
uses: ./.github/workflows/publish-test-result-from-fork-action.yml
3335
with:
34-
commit: ${{ github.event.workflow_run.head_sha }}
35-
files: artifacts/macos-ut-result-*/**/*.xml
36-
check_name: HybridSE Mac Test Report
37-
comment_title: HybridSE Mac Test Report
36+
commit: ${{ github.event.workflow_run.head_sha }}
37+
files: artifacts/macos-ut-result-*/**/*.xml
38+
check_name: HybridSE Mac Test Report
39+
comment_title: HybridSE Mac Test Report
40+
event_name: ${{ github.event.workflow_run.event }}
41+
run_id: ${{ github.event.workflow_run.id }}

.github/workflows/publish-sdk-test-result-from-fork.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ jobs:
2121
files: artifacts/linux-ut-result-*/**/*.xml
2222
check_name: SDK Test Report
2323
comment_title: SDK Test Report
24+
event_name: ${{ github.event.workflow_run.event }}
25+
run_id: ${{ github.event.workflow_run.id }}

.github/workflows/publish-test-result-from-fork-action.yml

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,43 @@ on:
77
files:
88
required: true
99
type: string
10+
event_name:
11+
required: true
12+
type: string
1013
check_name:
1114
required: true
1215
type: string
1316
comment_title:
1417
required: true
1518
type: string
19+
run_id:
20+
required: true
21+
type: number
22+
23+
permissions:
24+
checks: write
25+
pull-requests: write
26+
27+
# required by download step to access artifacts API
28+
actions: read
1629

1730
jobs:
1831
test-results:
1932
runs-on: ubuntu-latest
2033
steps:
21-
- name: Download Artifacts
22-
uses: actions/github-script@v3
34+
- name: Download and Extract Artifacts
35+
uses: dawidd6/action-download-artifact@v3
2336
with:
24-
script: |
25-
var fs = require('fs');
26-
var path = require('path');
27-
var artifacts_path = path.join('${{github.workspace}}', 'artifacts')
28-
fs.mkdirSync(artifacts_path, { recursive: true })
29-
30-
var artifacts = await github.actions.listWorkflowRunArtifacts({
31-
owner: context.repo.owner,
32-
repo: context.repo.repo,
33-
run_id: ${{ github.event.workflow_run.id }},
34-
});
37+
run_id: ${{ inputs.run_id }}
38+
path: artifacts
3539

36-
for (const artifact of artifacts.data.artifacts) {
37-
var download = await github.actions.downloadArtifact({
38-
owner: context.repo.owner,
39-
repo: context.repo.repo,
40-
artifact_id: artifact.id,
41-
archive_format: 'zip',
42-
});
43-
var artifact_path = path.join(artifacts_path, `${artifact.name}.zip`)
44-
fs.writeFileSync(artifact_path, Buffer.from(download.data));
45-
console.log(`Downloaded ${artifact_path}`);
46-
}
47-
- name: Extract Artifacts
48-
run: |
49-
for file in artifacts/*.zip
50-
do
51-
if [ -f "$file" ]
52-
then
53-
dir="${file/%.zip/}"
54-
mkdir -p "$dir"
55-
unzip -d "$dir" "$file"
56-
fi
57-
done
5840
- name: Publish UT Results
5941
uses: EnricoMi/publish-unit-test-result-action@v2
6042
with:
6143
commit: ${{ inputs.commit }}
6244
files: ${{ inputs.files }}
6345
check_name: ${{ inputs.check_name }}
6446
comment_title: ${{ inputs.comment_title }}
47+
event_name: ${{ inputs.event_name }}
48+
# u should upload the event file with upload name 'event-file'
49+
event_file: artifacts/event-file/event.json

.github/workflows/publish-test-results-action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ on:
1111
required: true
1212
type: string
1313

14+
permissions:
15+
checks: write
16+
pull-requests: write
17+
1418
jobs:
1519
publish-test-results:
1620
runs-on: ubuntu-latest

.github/workflows/sdk.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ jobs:
100100
run: |
101101
./mvnw --batch-mode test
102102
103+
- name: Upload Event File
104+
if: always()
105+
uses: actions/upload-artifact@v2
106+
with:
107+
name: event-file
108+
path: ${{ github.event_path }}
109+
103110
- name: upload java ut results
104111
if: always()
105112
uses: actions/upload-artifact@v2

0 commit comments

Comments
 (0)