Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: fix autobahn workflow #3291

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 4 additions & 19 deletions .github/workflows/autobahn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Autobahn
on:
workflow_dispatch:

pull_request_target:
pull_request:
paths:
- '.github/workflows/autobahn.yml'
- 'lib/web/websocket/**'
Expand Down Expand Up @@ -30,7 +30,6 @@ jobs:
- name: Checkout Code
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
with:
ref: "${{ github.event.pull_request.merge_commit_sha }}"
persist-credentials: false
clean: false

Expand All @@ -49,24 +48,10 @@ jobs:
run: npm run test:websocket:autobahn
env:
FUZZING_SERVER_URL: ws://fuzzingserver:9001
LOG_ON_ERROR: false

- name: Report into CI
- name: Report CI
id: report-ci
run: npm run test:websocket:autobahn:report

- name: Generate Report for PR Comment
if: github.event_name == 'pull_request_target'
id: report-markdown
run: |
echo "comment<<nEOFn" >> $GITHUB_OUTPUT
node test/autobahn/report.js >> $GITHUB_OUTPUT
echo "nEOFn" >> $GITHUB_OUTPUT
env:
REPORTER: markdown

- name: Comment PR
if: github.event_name == 'pull_request_target'
uses: thollander/actions-comment-pull-request@v2
with:
message: ${{ steps.report-markdown.outputs.comment }}
comment_tag: autobahn
FAIL_ON_ERROR: true
10 changes: 7 additions & 3 deletions test/autobahn/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

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

const logOnError = process.env.LOG_ON_ERROR === 'true'

let currentTest = 1
let testCount

Expand All @@ -28,9 +30,11 @@ function nextTest () {
currentTest++
process.nextTick(nextTest)
})
ws.addEventListener('error', (e) => {
console.error(e.error)
})
if (logOnError) {
ws.addEventListener('error', (e) => {
console.error(e.error)
})
}
}

const ws = new WebSocket(`${autobahnFuzzingserverUrl}/getCaseCount`)
Expand Down
68 changes: 16 additions & 52 deletions test/autobahn/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const result = require('./reports/clients/index.json').undici

const failOnError = process.env.FAIL_ON_ERROR === 'true'
const reporter = process.env.REPORTER || 'table'
let runFailed = false

let okTests = 0
Expand Down Expand Up @@ -86,57 +85,22 @@ for (const key of keys) {
}
}

if (
reporter === 'table'
) {
console.log('Autobahn Test Report\n\nSummary:')

console.table({
OK: okTests,
Failed: failedTests,
'Non-Strict': nonStrictTests,
'Wrong Code': wrongCodeTests,
Unclean: uncleanTests,
'Failed By Client': failedByClientTests,
Informational: informationalTests,
Unimplemented: unimplementedTests,
'Total Tests': totalTests
})

console.log('Details:')

console.table(reorderedResult)
}
console.log('Autobahn Test Report\n\nSummary:')

console.table({
OK: okTests,
Failed: failedTests,
'Non-Strict': nonStrictTests,
'Wrong Code': wrongCodeTests,
Unclean: uncleanTests,
'Failed By Client': failedByClientTests,
Informational: informationalTests,
Unimplemented: unimplementedTests,
Total: totalTests
})

if (reporter === 'markdown') {
console.log(`## Autobahn Test Report

### Summary

| Type | Count |
|---|---|
| OK | ${okTests} |
| Failed | ${failedTests} |
| Non-Strict | ${nonStrictTests} |
| Wrong Code | ${wrongCodeTests} |
| Unclean | ${uncleanTests} |
| Failed By Client | ${failedByClientTests} |
| Informational | ${informationalTests} |
| Unimplemented | ${unimplementedTests} |
| Total Tests | ${totalTests} |

<details>
<summary>Details</summary>

| Test Case | Behavior | Close Behavior | Duration | Remote Close Code |
|---|---|---|---|---|
${keys.map(key => {
const testCase = reorderedResult[key]
return `| ${key} | ${testCase.behavior} | ${testCase.behaviorClose} | ${testCase.duration} | ${testCase.remoteCloseCode} |`
}).join('\n')}

</details>
`)
}
console.log('Details:')

console.table(reorderedResult)

process.exit(runFailed ? 1 : 0)
Loading