Skip to content

Commit bafa764

Browse files
fdsimmsadampash
authored andcommitted
chore: set up ciftr for failed test reports (#343)
1 parent 262dda9 commit bafa764

File tree

6 files changed

+36
-58
lines changed

6 files changed

+36
-58
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
},
109109
"dependencies": {
110110
"@babel/runtime-corejs2": "^7.2.0",
111+
"@postlight/ci-failed-test-reporter": "^1.0",
111112
"browser-request": "github:postlight/browser-request#feat-add-headers-to-response",
112113
"cheerio": "^0.22.0",
113114
"difflib": "github:postlight/difflib.js",

scripts/comment-for-pr.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const Mercury = require('../dist/mercury.js');
44
const fs = require('fs');
55
const getTestReport = require('./get-test-report');
66
const execSync = require('child_process').execSync;
7+
const { getReport } = require('@postlight/ci-failed-test-reporter');
78

89
const run = () => {
910
const screenshotPath = process.argv[2];
@@ -37,7 +38,7 @@ const run = () => {
3738
fs.writeFileSync(fixtureArtifactPath, html);
3839

3940
const testReport =
40-
getTestReport('./test-output.json') || '✅ All tests passed';
41+
getReport('./test-output.json') || '✅ All tests passed';
4142

4243
const comment = `### 🤖 Automated Parsing Preview 🤖
4344
**Commit:** \`${bot.env.commitMessage}\`

scripts/get-test-report.js

-57
This file was deleted.

scripts/pr-parser-preview.sh

+1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ if [[ $fixtures ]]; then
2424
done
2525
else
2626
echo "No fixtures added in this PR, so no preview needed"
27+
node scripts/write-test-report.js
2728
fi

scripts/write-test-report.js

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
4+
const { getReport } = require('@postlight/ci-failed-test-reporter');
5+
6+
const report = getReport(path.join(__dirname, '../', '/test-output.json'));
7+
if (report) {
8+
const commentPath = 'tmp/artifacts/comment.json';
9+
fs.mkdirSync('tmp');
10+
fs.mkdirSync('tmp/artifacts');
11+
fs.writeFileSync(
12+
commentPath,
13+
JSON.stringify({
14+
body: report,
15+
issue: process.env.CIRCLE_PULL_REQUEST,
16+
})
17+
);
18+
}

yarn.lock

+14
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,14 @@
597597
universal-user-agent "^2.0.0"
598598
url-template "^2.0.8"
599599

600+
"@postlight/ci-failed-test-reporter@^1.0":
601+
version "1.0.22"
602+
resolved "https://registry.yarnpkg.com/@postlight/ci-failed-test-reporter/-/ci-failed-test-reporter-1.0.22.tgz#c382c3e75a4bcf078e4ed1abf14ea63d074d56b3"
603+
integrity sha512-k8YkZgrxgnYoju6Y0XZTXKk2fFeWBZ0+voA3WyVvEK3i9FsExCNMoKb5s0VBSqO6V9FxIQDXhjmcwn6t8cIDWA==
604+
dependencies:
605+
dotenv "^6.2.0"
606+
node-fetch "^2.3.0"
607+
600608
"@samverschueren/stream-to-observable@^0.3.0":
601609
version "0.3.0"
602610
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
@@ -2513,6 +2521,11 @@ [email protected], domutils@^1.5.1:
25132521
dom-serializer "0"
25142522
domelementtype "1"
25152523

2524+
dotenv@^6.2.0:
2525+
version "6.2.0"
2526+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064"
2527+
integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==
2528+
25162529
duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2, duplexer2@~0.1.4:
25172530
version "0.1.4"
25182531
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
@@ -5637,6 +5650,7 @@ [email protected]:
56375650
node-fetch@^2.3.0:
56385651
version "2.3.0"
56395652
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5"
5653+
integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==
56405654

56415655
node-int64@^0.4.0:
56425656
version "0.4.0"

0 commit comments

Comments
 (0)