testdriverai 7.2.37 → 7.2.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,10 @@ on:
|
|
|
9
9
|
jobs:
|
|
10
10
|
test:
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
pull-requests: write # Required to post comments on PRs
|
|
12
16
|
|
|
13
17
|
steps:
|
|
14
18
|
- uses: actions/checkout@v4
|
|
@@ -25,6 +29,8 @@ jobs:
|
|
|
25
29
|
- name: Run TestDriver.ai tests
|
|
26
30
|
env:
|
|
27
31
|
TD_API_KEY: ${{ secrets.TD_API_KEY }}
|
|
32
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
33
|
+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
28
34
|
run: npx vitest run
|
|
29
35
|
|
|
30
36
|
- name: Upload test results
|
|
@@ -2,8 +2,8 @@ import { execSync } from "child_process";
|
|
|
2
2
|
import crypto from "crypto";
|
|
3
3
|
import { createRequire } from "module";
|
|
4
4
|
import path from "path";
|
|
5
|
+
import { postOrUpdateTestResults } from "../lib/github-comment.mjs";
|
|
5
6
|
import { setTestRunInfo } from "./shared-test-state.mjs";
|
|
6
|
-
import { generateGitHubComment, postOrUpdateTestResults } from "../lib/github-comment.mjs";
|
|
7
7
|
|
|
8
8
|
// Use createRequire to import CommonJS modules without esbuild processing
|
|
9
9
|
const require = createRequire(import.meta.url);
|
package/lib/github-comment.mjs
CHANGED
|
@@ -47,10 +47,17 @@ function generateTestResultsTable(testCases, testRunUrl) {
|
|
|
47
47
|
return '_No test cases recorded_';
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
// Filter out skipped tests
|
|
51
|
+
const nonSkippedTests = testCases.filter(test => test.status !== 'skipped');
|
|
52
|
+
|
|
53
|
+
if (nonSkippedTests.length === 0) {
|
|
54
|
+
return '_No test cases to display (all tests were skipped)_';
|
|
55
|
+
}
|
|
56
|
+
|
|
50
57
|
let table = '| Status | Test | File | Duration | Replay |\n';
|
|
51
58
|
table += '|--------|------|------|----------|--------|\n';
|
|
52
59
|
|
|
53
|
-
for (const test of
|
|
60
|
+
for (const test of nonSkippedTests) {
|
|
54
61
|
const status = getStatusEmoji(test.status);
|
|
55
62
|
const name = test.testName || 'Unknown';
|
|
56
63
|
const file = test.testFile || 'unknown';
|
|
@@ -65,8 +72,8 @@ function generateTestResultsTable(testCases, testRunUrl) {
|
|
|
65
72
|
const replayId = extractReplayId(test.replayUrl);
|
|
66
73
|
if (replayId) {
|
|
67
74
|
const gifUrl = getReplayGifUrl(test.replayUrl, replayId);
|
|
68
|
-
// Embed GIF with link using HTML for
|
|
69
|
-
replay = `<a href="${linkUrl}"><img src="${gifUrl}"
|
|
75
|
+
// Embed GIF with link using HTML for height control
|
|
76
|
+
replay = `<a href="${linkUrl}"><img src="${gifUrl}" height="100" alt="Test replay" /></a>`;
|
|
70
77
|
} else {
|
|
71
78
|
// Fallback to text link if no GIF available
|
|
72
79
|
replay = `[🎥 View](${linkUrl})`;
|
|
@@ -258,9 +265,15 @@ export function generateGitHubComment(testRunData, testCases = []) {
|
|
|
258
265
|
comment += ` • **Duration:** ${formatDuration(duration)}`;
|
|
259
266
|
comment += ` • ${passedTests} passed`;
|
|
260
267
|
if (failedTests > 0) comment += `, ${failedTests} failed`;
|
|
261
|
-
if
|
|
268
|
+
// Only show skipped count if there are no passed or failed tests
|
|
269
|
+
if (skippedTests > 0 && passedTests === 0 && failedTests === 0) {
|
|
270
|
+
comment += `, ${skippedTests} skipped`;
|
|
271
|
+
}
|
|
262
272
|
comment += `\n\n`;
|
|
263
273
|
|
|
274
|
+
// Exceptions section (only if there are failures) - show first
|
|
275
|
+
comment += generateExceptionsSection(testCases, testRunUrl);
|
|
276
|
+
|
|
264
277
|
// Test results table (now includes embedded GIFs)
|
|
265
278
|
comment += '## 📝 Test Results\n\n';
|
|
266
279
|
comment += generateTestResultsTable(testCases, testRunUrl);
|
|
@@ -270,9 +283,6 @@ export function generateGitHubComment(testRunData, testCases = []) {
|
|
|
270
283
|
comment += `\n[📋 View Full Test Run](${testRunUrl})\n`;
|
|
271
284
|
}
|
|
272
285
|
|
|
273
|
-
// Exceptions section (only if there are failures)
|
|
274
|
-
comment += generateExceptionsSection(testCases, testRunUrl);
|
|
275
|
-
|
|
276
286
|
// Footer
|
|
277
287
|
comment += '\n---\n';
|
|
278
288
|
comment += `<sub>Generated by [TestDriver](https://testdriver.ai) • Run ID: \`${runId}\`</sub>\n`;
|
package/package.json
CHANGED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
name: TestDriver Tests with GitHub Comments
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
types: [opened, synchronize, reopened]
|
|
6
|
-
push:
|
|
7
|
-
branches: [main]
|
|
8
|
-
workflow_dispatch: # Allows manual trigger from Actions tab
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
test:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
permissions:
|
|
15
|
-
contents: read
|
|
16
|
-
pull-requests: write # Required to post comments on PRs
|
|
17
|
-
|
|
18
|
-
steps:
|
|
19
|
-
- name: Checkout code
|
|
20
|
-
uses: actions/checkout@v4
|
|
21
|
-
|
|
22
|
-
- name: Setup Node.js
|
|
23
|
-
uses: actions/setup-node@v4
|
|
24
|
-
with:
|
|
25
|
-
node-version: '20'
|
|
26
|
-
cache: 'npm'
|
|
27
|
-
|
|
28
|
-
- name: Install dependencies
|
|
29
|
-
run: npm ci
|
|
30
|
-
|
|
31
|
-
- name: Run assert test with GitHub comments
|
|
32
|
-
env:
|
|
33
|
-
# TestDriver API key (from repository secrets)
|
|
34
|
-
TD_API_KEY: ${{ secrets.TD_API_KEY }}
|
|
35
|
-
|
|
36
|
-
# GitHub token for posting comments (auto-provided)
|
|
37
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
38
|
-
|
|
39
|
-
# PR number for PR comments (auto-extracted for pull_request events)
|
|
40
|
-
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
41
|
-
|
|
42
|
-
# Git information (automatically provided by GitHub Actions)
|
|
43
|
-
# GITHUB_SHA, GITHUB_REF, GITHUB_REPOSITORY are already set
|
|
44
|
-
|
|
45
|
-
run: |
|
|
46
|
-
echo "🚀 Running TestDriver assert test..."
|
|
47
|
-
echo "📍 Repository: $GITHUB_REPOSITORY"
|
|
48
|
-
echo "🔢 PR Number: ${{ github.event.pull_request.number || 'N/A (not a PR)' }}"
|
|
49
|
-
echo "📦 Running test..."
|
|
50
|
-
npm run test:sdk -- test/testdriver/assert.test.mjs
|
|
51
|
-
|
|
52
|
-
- name: Upload test results (on failure)
|
|
53
|
-
if: failure()
|
|
54
|
-
uses: actions/upload-artifact@v4
|
|
55
|
-
with:
|
|
56
|
-
name: test-results
|
|
57
|
-
path: |
|
|
58
|
-
test-report.junit.xml
|
|
59
|
-
.testdriver/
|
|
60
|
-
retention-days: 7
|
|
61
|
-
|
|
62
|
-
- name: Comment on PR (manual fallback if auto-comment fails)
|
|
63
|
-
if: failure() && github.event_name == 'pull_request'
|
|
64
|
-
uses: actions/github-script@v7
|
|
65
|
-
with:
|
|
66
|
-
script: |
|
|
67
|
-
const testRunUrl = process.env.TESTDRIVER_RUN_URL || 'Check workflow logs';
|
|
68
|
-
github.rest.issues.createComment({
|
|
69
|
-
issue_number: context.issue.number,
|
|
70
|
-
owner: context.repo.owner,
|
|
71
|
-
repo: context.repo.repo,
|
|
72
|
-
body: `⚠️ TestDriver tests encountered an error. ${testRunUrl}`
|
|
73
|
-
})
|