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

Commitsar fails with 0 commits to check on main branch #354

Open
kowalczykp opened this issue Feb 10, 2021 · 3 comments
Open

Commitsar fails with 0 commits to check on main branch #354

kowalczykp opened this issue Feb 10, 2021 · 3 comments

Comments

@kowalczykp
Copy link
Contributor

kowalczykp commented Feb 10, 2021

When dealing with commits on branches/PRs, commitsar works as expected, but it behaves inconsistently on main branch:

When PR lands on main, as the last commit (fast-forward merge without merge commit) and CI (gitlab CI) manages to finish the commitsar pipeline before any new changes land, everything works as expected: Only a single/last commit is being found and checked.

When new changes land on main BEFORE the commitsar pipeline runs for previous commits, the following error happens:

$ commitsar --verbose
[DEBUG] Starting pipeline: commit-pipeline
Starting analysis of commits on branch HEAD
[DEBUG] Stopped getting commits on branch: object not found
[DEBUG] Stopped getting commits on branch: object not found
0 commits filtered out
Found 0 commit to check
[DEBUG] All pipelines complete
[DEBUG] [commit-pipeline] No commits found, please check you are on a branch outside of main
Some errors were found

While this mostly happens for frequent commits scenarios, the easiest way to deterministically reproduce it is to re-run a pipeline that previously passed on the main branch, but now has new commits ahead of it. This is always consistent and results in failure.

IMO Expected behaviour would be to check a single commit, that's triggering the CI and ensure the pipeline results is deterministic and re-running it on same commit produces the same output

Possibly related: #167

@kowalczykp
Copy link
Contributor Author

The current workaround for us is, to use two separate pipelines, where the main branch validation operates on the commit range. Gitlab CI based workaround relying on CI populated variables that help to identify the last commit:

validate-commits-branches:
  stage: test
  image: aevea/commitsar
  except:
    refs:
      - master
  script:
    - git fetch origin master
    - commitsar --verbose
  needs: []

validate-commits-master:
  stage: test
  image: aevea/commitsar
  only:
    refs:
      - master
  script:
    - commitsar --verbose $CI_COMMIT_BEFORE_SHA:$CI_COMMIT_SHA
  needs: []

@fallion
Copy link
Member

fallion commented Feb 11, 2021

I will investigate this.Thanks for the report @kowalczykp

@fallion
Copy link
Member

fallion commented Mar 4, 2021

@kowalczykp sorry to be getting to this so late.

I will set up commitsar to default to the commit provided by CI if running in CI. The issue is the git fetch origin master which will pull the latest commit and commitsar will try to check HEAD.

Most CIs provide this info so I'll set it up :)

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