danger-js
danger-js copied to clipboard
Running on "push" event instead of pull_request
Describe the bug
After setting up a new repo (private), I am not able to get Danger running (I am using a copy of a dangerfile.js
that is working on existing repo).
The error is Unable to evaluate the Dangerfile TypeError: danger.git.fileMatch is not a function
(see Debug trace).
When run locally using
yarn danger local -b main --text-only
then no error occured. The checks are performed as expected.
To Reproduce Steps to reproduce the behavior:
- Setup a new gh repo with a simple dangerfile eg
const dangerFile = danger.git.fileMatch(DANGER_FILE);
- Setup a gh action running danger
DEBUG="*" yarn danger ci -b main --text-only
Expected behavior No failure expected.
Debug trace
Run DEBUG="*" yarn danger ci -b main --text-only
2021-02-17T19:33:49.432Z danger:process_runner Debug mode on for Danger v10.6.2
2021-02-17T19:33:49.434Z danger:process_runner Starting sub-process run
2021-02-17T19:33:49.442Z danger:process_runner {
dangerJSONDSL: {
git: {
commits: [],
created_files: [],
deleted_files: [],
modified_files: []
},
github: {},
settings: { github: [Object], cliArgs: [Object] }
}
}
2021-02-17T19:33:49.442Z danger:process_runner Preparing to run: /opt/hostedtoolcache/node/12.20.2/x64/bin/node,/home/runner/work/live-platform-dataset/live-platform-dataset/.yarn/cache/danger-npm-10.6.2-bd26b96131-2ac6b50d29.zip/node_modules/danger/distribution/commands/danger-runner.js,-b,main,--text-only
2021-02-17T19:33:49.442Z danger:runDangerSubprocess Running sub-process: node - /home/runner/work/live-platform-dataset/live-platform-dataset/.yarn/cache/danger-npm-10.6.2-bd26b96131-2ac6b50d29.zip/node_modules/danger/distribution/commands/danger-runner.js,-b,main,--text-only
2021-02-17T19:33:49.450Z danger:runDangerSubprocess Started passing in STDIN
2021-02-17T19:33:49.451Z danger:runDangerSubprocess Passed DSL in via STDIN
2021-02-17T19:33:50.176Z danger:runner Started Danger runner with
2021-02-17T19:33:50.183Z danger:runner Got STDIN for Danger Run
2021-02-17T19:33:50.185Z danger:jsonToDSL Creating event DSL from JSON
2021-02-17T19:33:50.205Z danger:runner Evaluating dangerfile.js
2021-02-17T19:33:50.212Z danger:transpiler:setup Does not have Babel set up
2021-02-17T19:33:50.212Z danger:inline_runner Started parsing Dangerfile: dangerfile.js
Unable to evaluate the Dangerfile
TypeError: danger.git.fileMatch is not a function
Environment
software | version |
---|---|
danger.js | 10.6.2 |
node | 12 |
yarn | 2 |
Operating System | ubuntu-20.04 |
Additional context Github workflow
name: Check branch
on: push
jobs:
checks:
name: Run branch checks
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '12'
- name: Yarn
run: yarn install --immutable --immutable-cache
- name: Danger
run: DEBUG="*" yarn danger ci -b main --text-only
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Lint code
run: yarn lint
- name: Unit tests
run: yarn test
You're running on a push event, so there's no pull request metadata (which adds 'git') - I'd be open to adding support for Danger to try get some useful metadata from the push event to fill out the git