danger / swift

⚠️ Stop saying "you forgot to …" in code review

Home Page:https://danger.systems/swift/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Danger Swift not working with Github Merge Queue

spqw opened this issue · comments

  • Github Merge Queue creates temporary branches for merge groups which can aggregate several pull requests to run checks on several pull requests at once
  • When adding Danger swift as a required check on branch protection rules on Github, this is also applied to Merge Queue Checks
  • Danger checks fail on temporary branches from Github Merge Queue because it is expecting to be run on a pull request branch
  • How to make sure Danger checks run well with Github Merge queues?

I have not used merge queues, so I'm not sure how much I can help but I will try 😁
Which CI platform are you using to run danger? GitHub actions?

  • CI - Teamcity, but it should be the same with any CI platform
  • Using the danger-swift executable
  • The temporary branches for github merge queue have the special prefix "gh-readonly-queue/{base_branch}"

Danger, in order to work, needs the PR data, to get that it takes from the CI platform the PR ID and repo slug.
In team city this means that the env variable PULL_REQUEST_URL needs to be present and correct https://github.com/danger/danger-js/blob/main/source/ci_source/providers/TeamCity.ts
Is that variable present?

  • This is exactly the issue. It is not trivial to map github temporary branch to a set of pull request urls, due the nature of temporary branches used in a merge queue
  • Indeed, such temporary branch aggregate several pull requests into one
  • One workaround for us could be to skip danger.github checks when the current branch starts with gh-readonly-queue
  • But it seems that danger-swift will try to fetch pull request related info even if there if we're not using danger.github
  • Is it be possible to run danger in a mode where we are comparing a head branch with a base branch, only relying on git diff?

Examples of DSL elements we are using and that we want to be able to run on merge queue checks

  • danger.git.modifiedFiles
  • danger.git.createdFiles
  • danger.git.deletedFiles

Examples of DSL elements we would like to use on pull requests checks, and skip on merge queue checks, i.e. check the current branch starts with gh-readonly-queue

  • danger.github.pullRequest.body