codeclimate / test-reporter

Code Climate Test Reporter
MIT License
154 stars 76 forks source link

missing semaphore environmental variable #484

Open ethn opened 2 years ago

ethn commented 2 years ago

Sorry I'm too lazy to write a PR for this, but the following from env/git.go...

var gitBranchVars = []string{"GIT_BRANCH", "APPVEYOR_REPO_BRANCH", "BRANCH_NAME", "BUILDKITE_BRANCH", "CIRCLE_BRANCH", "CI_BRANCH", "CI_BUILD_REF_NAME", "DRONE_BRANCH", "HEROKU_TEST_RUN_BRANCH", "TRAVIS_PULL_REQUEST_BRANCH", "TRAVIS_BRANCH", "WERCKER_GIT_BRANCH", "CI_COMMIT_REF_NAME", "BITRISE_GIT_BRANCH", "SEMAPHORE_GIT_PR_BRANCH", "SEMAPHORE_GIT_BRANCH", "GITHUB_REF_NAME"}

...contains a nice pattern for semaphore by listing these two in order: "SEMAPHORE_GIT_PR_BRANCH", "SEMAPHORE_GIT_BRANCH".

However the same is not true for the commit shas:

var gitCommitShaVars = []string{"GIT_COMMIT_SHA", "APPVEYOR_REPO_COMMIT", "BUILDKITE_COMMIT", "CIRCLE_SHA1", "CI_BUILD_REF", "CI_BUILD_SHA", "CI_COMMIT", "CI_COMMIT_ID", "DRONE_COMMIT", "GIT_COMMIT", "HEROKU_TEST_RUN_COMMIT_VERSION", "WERCKER_GIT_COMMIT", "TRAVIS_PULL_REQUEST_SHA", "TRAVIS_COMMIT", "CI_COMMIT_SHA", "BITRISE_GIT_COMMIT", "SEMAPHORE_GIT_SHA", "GITHUB_SHA"}

This leads to problems with pull request status updates on code climate, because semaphore is using the merge sha rather than the pr's head sha. (see https://docs.semaphoreci.com/essentials/project-workflow-trigger-options/)

If you were to add "SEMAPHORE_GIT_PR_SHA" immediately before "SEMAPHORE_GIT_SHA", this would solve that problem (and better parallel the branch handling).

ethn commented 2 years ago

(Our status updates had been hanging for months. I identified this problem today and was able to implement a workaround in semaphore, but this should fix problems for anyone using this integration).