Skip to content

Commit 9698d9a

Browse files
authored
dx: comment on custom parser pr fix (#278)
* dx: comment on custom parser pr fix * fix path * write json * chore: rename comment script
1 parent ed14203 commit 9698d9a

3 files changed

Lines changed: 20 additions & 14 deletions

File tree

fixtures/www.howtogeek.com/1482438125052.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const bot = require('@jesses/circle-github-bot').default.create();
33
const Mercury = require('../dist/mercury.js');
44
const fs = require('fs');
55
const getTestReport = require('./get-test-report');
6+
const execSync = require('child_process').execSync;
67

78
const run = () => {
89
const screenshotPath = process.argv[2];
@@ -38,19 +39,17 @@ const run = () => {
3839
const testReport =
3940
getTestReport('./test-output.json') || '✅ All tests passed';
4041

41-
bot.comment(
42-
process.env.GH_AUTH_TOKEN,
43-
`### 🤖 Automated Parsing Preview 🤖
42+
const comment = `### 🤖 Automated Parsing Preview 🤖
4443
**Commit:** \`${bot.env.commitMessage}\`
4544
4645
![Screenshot of fixture (this embed should work after repo is public)](${bot.artifactUrl(
47-
screenshotPath
48-
)})
46+
screenshotPath
47+
)})
4948
5049
[Original Article](${url}) | ${bot.artifactLink(
51-
fixtureArtifactPath,
52-
'HTML Fixture'
53-
)} | ${bot.artifactLink(previewPath, 'Parsed Content Preview')}
50+
fixtureArtifactPath,
51+
'HTML Fixture'
52+
)} | ${bot.artifactLink(previewPath, 'Parsed Content Preview')}
5453
5554
<details>
5655
<summary><b>Parsed JSON</b></summary>
@@ -66,12 +65,19 @@ ${JSON.stringify(json, null, 2)}
6665
**\`null\` fields**
6766
6867
${Object.keys(json)
69-
.map(key => (json[key] !== null ? '' : ` * \`${key}\n\``))
70-
.join('\n\n') || 'None'}
68+
.map(key => (json[key] !== null ? '' : ` * \`${key}\n\``))
69+
.join('\n\n') || 'None'}
7170
7271
7372
${testReport}
74-
`
73+
`;
74+
const commentPath = 'tmp/artifacts/comment.json';
75+
fs.writeFileSync(
76+
commentPath,
77+
JSON.stringify({
78+
body: comment,
79+
issue: process.env.CIRCLE_PULL_REQUEST,
80+
})
7581
);
7682
});
7783
}

scripts/pr-parser-preview.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if [[ $fixtures ]]; then
2020
do
2121
# Create a comment with a link to the screenshot
2222
# and json output for the fixture
23-
node scripts/comment-on-pr.js $screenshot
23+
node scripts/comment-for-pr.js $screenshot
2424
done
2525
else
2626
echo "No fixtures added in this PR, so no preview needed"

0 commit comments

Comments
 (0)