Skip to content

Commit 0564b46

Browse files
authored
ci: fix autobahn workflow (#3291)
1 parent 13523fd commit 0564b46

File tree

3 files changed

+27
-74
lines changed

3 files changed

+27
-74
lines changed

.github/workflows/autobahn.yml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Autobahn
22
on:
33
workflow_dispatch:
44

5-
pull_request_target:
5+
pull_request:
66
paths:
77
- '.github/workflows/autobahn.yml'
88
- 'lib/web/websocket/**'
@@ -30,7 +30,6 @@ jobs:
3030
- name: Checkout Code
3131
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
3232
with:
33-
ref: "${{ github.event.pull_request.merge_commit_sha }}"
3433
persist-credentials: false
3534
clean: false
3635

@@ -49,24 +48,10 @@ jobs:
4948
run: npm run test:websocket:autobahn
5049
env:
5150
FUZZING_SERVER_URL: ws://fuzzingserver:9001
51+
LOG_ON_ERROR: false
5252

53-
- name: Report into CI
53+
- name: Report CI
5454
id: report-ci
5555
run: npm run test:websocket:autobahn:report
56-
57-
- name: Generate Report for PR Comment
58-
if: github.event_name == 'pull_request_target'
59-
id: report-markdown
60-
run: |
61-
echo "comment<<nEOFn" >> $GITHUB_OUTPUT
62-
node test/autobahn/report.js >> $GITHUB_OUTPUT
63-
echo "nEOFn" >> $GITHUB_OUTPUT
6456
env:
65-
REPORTER: markdown
66-
67-
- name: Comment PR
68-
if: github.event_name == 'pull_request_target'
69-
uses: thollander/actions-comment-pull-request@v2
70-
with:
71-
message: ${{ steps.report-markdown.outputs.comment }}
72-
comment_tag: autobahn
57+
FAIL_ON_ERROR: true

test/autobahn/client.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
const { WebSocket } = require('../..')
44

5+
const logOnError = process.env.LOG_ON_ERROR === 'true'
6+
57
let currentTest = 1
68
let testCount
79

@@ -28,9 +30,11 @@ function nextTest () {
2830
currentTest++
2931
process.nextTick(nextTest)
3032
})
31-
ws.addEventListener('error', (e) => {
32-
console.error(e.error)
33-
})
33+
if (logOnError) {
34+
ws.addEventListener('error', (e) => {
35+
console.error(e.error)
36+
})
37+
}
3438
}
3539

3640
const ws = new WebSocket(`${autobahnFuzzingserverUrl}/getCaseCount`)

test/autobahn/report.js

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const result = require('./reports/clients/index.json').undici
44

55
const failOnError = process.env.FAIL_ON_ERROR === 'true'
6-
const reporter = process.env.REPORTER || 'table'
76
let runFailed = false
87

98
let okTests = 0
@@ -86,57 +85,22 @@ for (const key of keys) {
8685
}
8786
}
8887

89-
if (
90-
reporter === 'table'
91-
) {
92-
console.log('Autobahn Test Report\n\nSummary:')
93-
94-
console.table({
95-
OK: okTests,
96-
Failed: failedTests,
97-
'Non-Strict': nonStrictTests,
98-
'Wrong Code': wrongCodeTests,
99-
Unclean: uncleanTests,
100-
'Failed By Client': failedByClientTests,
101-
Informational: informationalTests,
102-
Unimplemented: unimplementedTests,
103-
'Total Tests': totalTests
104-
})
105-
106-
console.log('Details:')
107-
108-
console.table(reorderedResult)
109-
}
88+
console.log('Autobahn Test Report\n\nSummary:')
89+
90+
console.table({
91+
OK: okTests,
92+
Failed: failedTests,
93+
'Non-Strict': nonStrictTests,
94+
'Wrong Code': wrongCodeTests,
95+
Unclean: uncleanTests,
96+
'Failed By Client': failedByClientTests,
97+
Informational: informationalTests,
98+
Unimplemented: unimplementedTests,
99+
Total: totalTests
100+
})
110101

111-
if (reporter === 'markdown') {
112-
console.log(`## Autobahn Test Report
113-
114-
### Summary
115-
116-
| Type | Count |
117-
|---|---|
118-
| OK | ${okTests} |
119-
| Failed | ${failedTests} |
120-
| Non-Strict | ${nonStrictTests} |
121-
| Wrong Code | ${wrongCodeTests} |
122-
| Unclean | ${uncleanTests} |
123-
| Failed By Client | ${failedByClientTests} |
124-
| Informational | ${informationalTests} |
125-
| Unimplemented | ${unimplementedTests} |
126-
| Total Tests | ${totalTests} |
127-
128-
<details>
129-
<summary>Details</summary>
130-
131-
| Test Case | Behavior | Close Behavior | Duration | Remote Close Code |
132-
|---|---|---|---|---|
133-
${keys.map(key => {
134-
const testCase = reorderedResult[key]
135-
return `| ${key} | ${testCase.behavior} | ${testCase.behaviorClose} | ${testCase.duration} | ${testCase.remoteCloseCode} |`
136-
}).join('\n')}
137-
138-
</details>
139-
`)
140-
}
102+
console.log('Details:')
103+
104+
console.table(reorderedResult)
141105

142106
process.exit(runFailed ? 1 : 0)

0 commit comments

Comments
 (0)