PR 체크할 때 이런 에러 로그가 나오면서 danger가 될 땐 workflow yml을 살펴보자

로그 전체

/opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/danger-8.6.1/lib/danger/scm_source/git_repo.rb:139:in `find_merge_base': Cannot find a merge base between danger_base and danger_head. If you are using shallow clone/fetch, try increasing the --depth (RuntimeError)
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/danger-8.6.1/lib/danger/scm_source/git_repo.rb:22:in `diff_for_folder'
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/danger-8.6.1/lib/danger/danger_core/dangerfile.rb:274:in `setup_for_running'
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/danger-8.6.1/lib/danger/danger_core/dangerfile.rb:284:in `run'
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/danger-8.6.1/lib/danger/danger_core/executor.rb:29:in `run'
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/danger-8.6.1/lib/danger/commands/runner.rb:73:in `run'
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/lib/ruby/gems/2.6.0/gems/danger-8.6.1/bin/danger:5:in `<top (required)>'
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/bin/danger:23:in `load'
    from /opt/hostedtoolcache/Ruby/2.6.10/x64/bin/danger:23:in `<main>'
Error: The process '/opt/hostedtoolcache/Ruby/2.6.10/x64/bin/danger' failed with exit code 1

원인

로그 두 번째 줄에 있는

 

If you are using shallow clone/fetch, try increasing the --depth (RuntimeError)

 

로 알 수 있는데, danger가 체크용으로 해당 브런치를 clone하려는데 shallow clone을 사용하고 있어 가장 마지막의 1 커밋만 가져와 이력을 전부 확인할 수 없는 것이 원인인 듯싶다.

shallow clone?

일반적인 git clone 은 tag, commit 을 모두 checkout 하지만 시간이 더 걸리기 때문에, 모든 커밋을 가져올 필요가 없는 경우 shallow clone 을 사용해 checkout 시의 볼륨의 줄일 수 있다고 한다.

해결

https://github.com/actions/checkout 에서 checkout workflow의 사양을 확인해보면 depth의 기본값은 1이다.
찾아보니 수를 늘리는 것보단 오히려 아예 커밋을 가져오지 않도록 하는 게 방법인 것 같아서 일단은 그렇게 해결.

  danger:
    timeout-minutes: 5
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@master
        with:
          fetch-depth: 0

+ Recent posts