-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdangerfile.ts
49 lines (39 loc) · 1.47 KB
/
dangerfile.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { contains, danger, fail, message } from "danger";
const currentCommitSHA = danger.git.commits[danger.git.commits.length - 1].sha;
function checkPackageLock() {
const hasPackageLock =
danger.git.created_files.filter(p => p.includes("package-lock.json")).length > 0;
if (hasPackageLock) {
fail("Detected package-lock.json, failing build. Do not use npm, use yarn instead.");
}
}
function checkSmartContractGitModules() {
const updatesContracts = (danger.github.pr.body + danger.github.pr.title).includes(
"#with-contracts",
);
const hasContractSubmodule = danger.git.modified_files.some(p =>
p.includes("platform-contracts-artifacts/"),
);
if (hasContractSubmodule && !updatesContracts) {
fail(
"Detected platform-contracts-artifacts in your PR, most likely this is by mistake please push alone",
);
}
}
function reportVisualRegression() {
try {
const reportLink = `https://s3.eu-central-1.amazonaws.com/neufund.visual.regression/${currentCommitSHA}/report/index.html`;
const reportData = require("./.reg/out.json");
message(`[Visual regression report](${reportLink})
Changed files: **${reportData.failedItems.length}**
New files: **${reportData.newItems.length}**
Deleted files: **${reportData.deletedItems.length}**
`);
} catch (e) {
console.error("Error: ", e);
fail("Could not access visual regression report");
}
}
checkPackageLock();
checkSmartContractGitModules();
reportVisualRegression();