Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve stacktrace when dangerfile failed to run #623

Open
sibelius opened this issue Jun 28, 2018 · 2 comments
Open

improve stacktrace when dangerfile failed to run #623

sibelius opened this issue Jun 28, 2018 · 2 comments

Comments

@sibelius
Copy link

for this dangerfile.js

import { danger, warn, message } from 'danger';
import fs from 'fs';

// TODO - improve dangerjs

const modifiedMD = danger.git.modified_files.join('\n- ');

const allFiles = danger.git.modified_files.concat(danger.git.created_files);

const includesEdge = allFiles.map(file => {
  const reAdd = /\BAdd|Add\B/g;
  const reEdge = /\BEdge|Edge\B/g;
  const content = fs.readFileSync(file).toString();
  const fileHasAMutationAdd = file.match(reAdd);
  const fileHaveAnEdge = content.match(reEdge);
  fileHasAMutationAdd &&
    !fileHaveAnEdge &&
    warn(`This file ${file} seems to be an add mutation and not include an output Edge`);
});

message(`Changed Files in this PR: \n - ${modifiedMD}`);

it is throwing the following error stacktrace:

ENOENT: no such file or directory, open '.github/PULL_REQUEST_TEMPLATE.md'
Error: ENOENT: no such file or directory, open '.github/PULL_REQUEST_TEMPLATE.md'
    at Object.fs.openSync (fs.js:660:18)
    at Object.fs.readFileSync (fs.js:565:33)
    at Object.apply (/app/node_modules/vm2/lib/contextify.js:288:34)
    at /app/danger-0.jelc7b1175j.js:18:30
    at Object.apply (/app/node_modules/vm2/lib/contextify.js:87:36)
    at Array.map (<anonymous>)
    at Object.apply (/app/node_modules/vm2/lib/contextify.js:288:34)
    at Object.<anonymous> (/app/danger-0.jelc7b1175j.js:14:29)
    at NodeVM.run (/app/node_modules/vm2/lib/main.js:427:27)
    at Object.<anonymous> (/app/node_modules/danger/distribution/runner/runners/vm2.js:97:37)
    at step (/app/node_modules/danger/distribution/runner/runners/vm2.js:40:23)
    at Object.next (/app/node_modules/danger/distribution/runner/runners/vm2.js:21:53)
    at /app/node_modules/danger/distribution/runner/runners/vm2.js:15:71
    at new Promise (<anonymous>)
    at __awaiter (/app/node_modules/danger/distribution/runner/runners/vm2.js:11:12)
    at Object.exports.runDangerfileEnvironment (/app/node_modules/danger/distribution/runner/runners/vm2.js:80:121)

it'd be great to show where in dangerfile the error was thrown

@orta
Copy link
Member

orta commented Jun 28, 2018

This problem only happens on self hosted instances using vm2, and shouldn't be an issue in peril staging (where evaluation is a 90% closer to normally running a node script) so I'm unlikely to take a stab at this

@sibelius
Copy link
Author

this happened on peril (on heroku) running a dangerfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants