danger: Danger fails on CI when running on PR from a fork in GH Actions / Buddy Build
We just set up danger in our repository and it fails when running on PRs from forks.
What did you do?
bundle install
bundle exec danger --fail-on-errors=true
What did you expect to happen?
It would run danger and find the branch & commit in my fork.
What happened instead?
It failed to find the commits and/or the branch:
fatal: Couldn't find remote ref refs/heads/event-ordering
fatal: Couldn't find remote ref refs/heads/event-ordering
fatal: Couldn't find remote ref refs/heads/event-ordering
fatal: Couldn't find remote ref refs/heads/event-ordering
bundler: failed to load command: danger (/usr/local/bin/danger)
RuntimeError: Commit c2b6bb0b doesn't exist. Are you running `danger local/pr` against the correct repository? Also this usually happens when you rebase/reset and force-pushed.
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/lib/danger/scm_source/git_repo.rb:111:in `raise_if_we_cannot_find_the_commit'
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/lib/danger/scm_source/git_repo.rb:93:in `ensure_commitish_exists_on_branch!'
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/lib/danger/request_sources/github/github.rb:112:in `setup_danger_branches'
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/lib/danger/danger_core/environment_manager.rb:57:in `ensure_danger_branches_are_setup'
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/lib/danger/danger_core/dangerfile.rb:259:in `setup_for_running'
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/lib/danger/danger_core/dangerfile.rb:270:in `run'
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/lib/danger/danger_core/executor.rb:29:in `run'
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/lib/danger/commands/runner.rb:72:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.2/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.3.0/gems/danger-5.14.0/bin/danger:5:in `<top (required)>'
/usr/local/bin/danger:22:in `load'
/usr/local/bin/danger:22:in `<top (required)>'
Your Environment
- Which CI are you running on? Buddybuild
- Are you running the latest version of Danger? Yup
- What is your Dangerfile?
warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"
swiftlint.lint_files fail_on_error: true
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 5
- Comments: 38 (25 by maintainers)
Commits related to this issue
- Checkout HEAD commit until https://github.com/danger/danger/issues/1103 is fixed — committed to ffried/CocoaLumberjack by ffried 4 years ago
- Add checkout options https://github.com/danger/danger/issues/1103#issuecomment-635539947 — committed to konifar/engineering-careers by konifar 4 years ago
- Add checkout options ref: https://github.com/danger/danger/issues/1103 — committed to Clipy/Magnet by Econa77 4 years ago
- Add checkout options (#64) ref: https://github.com/danger/danger/issues/1103 — committed to Clipy/Magnet by Econa77 4 years ago
- Add checkout options ref: https://github.com/danger/danger/issues/1103 — committed to Clipy/Sauce by Econa77 4 years ago
- Add checkout options ref: https://github.com/danger/danger/issues/1103 — committed to Clipy/KeyHolder by Econa77 4 years ago
- Add checkout options (#53) ref: https://github.com/danger/danger/issues/1103 — committed to Clipy/KeyHolder by Econa77 4 years ago
- Add checkout options (#30) ref: https://github.com/danger/danger/issues/1103 — committed to Clipy/Sauce by Econa77 4 years ago
- ci: allow danger to execute from forked repos (#23) * ci: allow danger to execute from forked repos Add the fetch-depth param with value of 0 when checking out which should allow forks to run dan... — committed to b-reynolds/device-info-app by Chesire 4 years ago
- Change fetch-depth See here: https://github.com/danger/danger/issues/1103#issuecomment-635539947 — committed to robertodr/mrchem by robertodr 4 years ago
- Change fetch-depth (#348) * Change fetch-depth See here: https://github.com/danger/danger/issues/1103#issuecomment-635539947 * Check if GITHUB_TOKEN is necessary * Giggles * Which one do ... — committed to MRChemSoft/mrchem by robertodr 4 years ago
- Change fetch-depth (#348) * Change fetch-depth See here: https://github.com/danger/danger/issues/1103#issuecomment-635539947 * Check if GITHUB_TOKEN is necessary * Giggles * Which one do ... — committed to stigrj/mrchem by robertodr 4 years ago
- Prepare v1.0.1 (#357) * Fix README * Fix zenodo contributor list * Add Singularity instruction to README * Copy Python frontend module to build dir always Fixes #317 * Fix NMR * Add... — committed to MRChemSoft/mrchem by stigrj 4 years ago
- fix: run-danger workflow related to https://github.com/danger/danger/issues/1103 — committed to ipfs/awesome-ipfs by SgtPooki 2 years ago
- Add Danger CI Summary: OK this is a bit complicated. As of now this will work on branch-based PRs all the time and will often fail on fork-based PRs (but not always). SOOO, what we do is DETECT that... — committed to jaymzh/chef by jaymzh 9 months ago
- Add Danger CI Summary: OK this is a bit complicated. As of now this will work on branch-based PRs all the time and will often fail on fork-based PRs (but not always). SOOO, what we do is DETECT that... — committed to jaymzh/chef by jaymzh 9 months ago
- Add Danger CI Summary: OK this is a bit complicated. As of now this will work on branch-based PRs all the time and will often fail on fork-based PRs (but not always). SOOO, what we do is DETECT that... — committed to jaymzh/chef by jaymzh 9 months ago
- Add Danger CI Summary: OK this is a bit complicated. As of now this will work on branch-based PRs all the time and will often fail on fork-based PRs (but not always). SOOO, what we do is DETECT that... — committed to jaymzh/chef by jaymzh 9 months ago
- Add Danger CI Summary: OK this is a bit complicated. As of now this will work on branch-based PRs all the time and will often fail on fork-based PRs (but not always). SOOO, what we do is DETECT that... — committed to jaymzh/chef by jaymzh 9 months ago
- Add Danger CI Summary: OK this is a bit complicated. As of now this will work on branch-based PRs all the time and will often fail on fork-based PRs (but not always). SOOO, what we do is DETECT that... — committed to jaymzh/chef by jaymzh 8 months ago
Using:
Will only checkout the single commit to be tested-you need something with more depth, so you can either use
actions/checkout@v1or specify thefetch-depthas in:This solved my issues with Github Actions 😄
so I tried to work around this today, and while I didn’t get a solution, I think what i found may be enlightening.
I added a step to checkout the fork remote:
When I did that, however, Danger, I think, ended up comparing the branch to itself, and saw no delta, and thus was very happy.
So then I tried to pass in --base:
But then it complains it can’t find
mainanywhere in the repo (Commit main doesn't exist). That can’t be right!I then tried dropping the
checkout, but that didn’t work either. I even tried modifying my git-fix step to be:to make sure the right main and the right head would be there. This gets the right things in the right places:
But, this, once again, caused danger to simply see nothing.
I tried at this point modifying danger call to be this, though I think this is what it does by default:
But it sees nothing.
So then I decided to add
message(git.diff)to see what diff it thinks it’s seeing.Low and behold, it’s my diff. It crashes on
unless source.valid_encoding?(https://github.com/chef/chef/actions/runs/7148990967/job/19470679407?pr=14134), but in the stacktrace I can see the diff.So at this point, given I’ve made sure that both the base ref and the head ref are both there, I think it seems reasonable to believe there’s something that Danger isn’t quite catching here.
@Xorima
it’s in
ipfs/awesome-ipfsrepo (https://github.com/ipfs/awesome-ipfs/blob/master/.github/workflows/pull_requests.yml). Also, there was some feedback on the PR or issue I created in that repo fromgalarghthat you may find valuable regarding what settingpull_request_targetactually does.idk if this will fix everyone’s problems, but changing github workflow trigger from
pull_requesttopull_request_targetresolved the issue for me. see https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target