Skip to content

Commit

Permalink
chore: set up ciftr for failed test reports (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdsimms authored and adampash committed Apr 1, 2019
1 parent 262dda9 commit bafa764
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 58 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
},
"dependencies": {
"@babel/runtime-corejs2": "^7.2.0",
"@postlight/ci-failed-test-reporter": "^1.0",
"browser-request": "github:postlight/browser-request#feat-add-headers-to-response",
"cheerio": "^0.22.0",
"difflib": "github:postlight/difflib.js",
Expand Down
3 changes: 2 additions & 1 deletion scripts/comment-for-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Mercury = require('../dist/mercury.js');
const fs = require('fs');
const getTestReport = require('./get-test-report');
const execSync = require('child_process').execSync;
const { getReport } = require('@postlight/ci-failed-test-reporter');

const run = () => {
const screenshotPath = process.argv[2];
Expand Down Expand Up @@ -37,7 +38,7 @@ const run = () => {
fs.writeFileSync(fixtureArtifactPath, html);

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

const comment = `### 🤖 Automated Parsing Preview 🤖
**Commit:** \`${bot.env.commitMessage}\`
Expand Down
57 changes: 0 additions & 57 deletions scripts/get-test-report.js

This file was deleted.

1 change: 1 addition & 0 deletions scripts/pr-parser-preview.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ if [[ $fixtures ]]; then
done
else
echo "No fixtures added in this PR, so no preview needed"
node scripts/write-test-report.js
fi
18 changes: 18 additions & 0 deletions scripts/write-test-report.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const path = require('path');
const fs = require('fs');

const { getReport } = require('@postlight/ci-failed-test-reporter');

const report = getReport(path.join(__dirname, '../', '/test-output.json'));
if (report) {
const commentPath = 'tmp/artifacts/comment.json';
fs.mkdirSync('tmp');
fs.mkdirSync('tmp/artifacts');
fs.writeFileSync(
commentPath,
JSON.stringify({
body: report,
issue: process.env.CIRCLE_PULL_REQUEST,
})
);
}
14 changes: 14 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,14 @@
universal-user-agent "^2.0.0"
url-template "^2.0.8"

"@postlight/ci-failed-test-reporter@^1.0":
version "1.0.22"
resolved "https://registry.yarnpkg.com/@postlight/ci-failed-test-reporter/-/ci-failed-test-reporter-1.0.22.tgz#c382c3e75a4bcf078e4ed1abf14ea63d074d56b3"
integrity sha512-k8YkZgrxgnYoju6Y0XZTXKk2fFeWBZ0+voA3WyVvEK3i9FsExCNMoKb5s0VBSqO6V9FxIQDXhjmcwn6t8cIDWA==
dependencies:
dotenv "^6.2.0"
node-fetch "^2.3.0"

"@samverschueren/stream-to-observable@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
Expand Down Expand Up @@ -2513,6 +2521,11 @@ domutils@1.5.1, domutils@^1.5.1:
dom-serializer "0"
domelementtype "1"

dotenv@^6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064"
integrity sha512-HygQCKUBSFl8wKQZBSemMywRWcEDNidvNbjGVyZu3nbZ8qq9ubiPoGLMdRDpfSrpkkm9BXYFkpKxxFX38o/76w==

duplexer2@^0.1.2, duplexer2@~0.1.0, duplexer2@~0.1.2, duplexer2@~0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
Expand Down Expand Up @@ -5637,6 +5650,7 @@ node-environment-flags@1.0.4:
node-fetch@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.3.0.tgz#1a1d940bbfb916a1d3e0219f037e89e71f8c5fa5"
integrity sha512-MOd8pV3fxENbryESLgVIeaGKrdl+uaYhCSSVkjeOb/31/njTpcis5aWfdqgNlHIrKOLRbMnfPINPOML2CIFeXA==

node-int64@^0.4.0:
version "0.4.0"
Expand Down

0 comments on commit bafa764

Please sign in to comment.