Skip to content

Commit

Permalink
Add partial automated support for Heroku CI builds
Browse files Browse the repository at this point in the history
Heroku CI currently exposes the following environment variables during
CI builds:

- `HEROKU_TEST_RUN_BRANCH`: A string representing the branch of the commit under test
- `HEROKU_TEST_RUN_COMMIT_VERSION`: A string representing the commit version under test (This is the SHA in most cases)
- `HEROKU_TEST_RUN_ID`: A string uuid representing the unique ID of the test run

source: https://devcenter.heroku.com/articles/heroku-ci#configuration-using-app-json

The Code Climate test reporter relies on a git committed at timestamp to
reliably render accurate test coverage annotations on codeclimate.com
and on github.com via the browser extension.

For now, we can automatically apply the environment variables supported
by Heroku CI, but a couple others will have to be manually supplied by
the user:

```
export CI_NAME="heroku"
export GIT_COMMITTED_AT="$(date +%s)"
```

Related to: #226
  • Loading branch information
dblandin committed Feb 19, 2018
1 parent bd46b05 commit a031850
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion env/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ func loadCIInfo() ci {

var ciNameVars = []string{"CI_NAME", "APPVEYOR", "BUILDKITE", "CIRCLECI", "GITLAB_CI", "JENKINS_URL", "SEMAPHORE", "TDDIUM", "TRAVIS", "WERCKER", "CI"}

var ciBuildIDVars = []string{"CI_BUILD_ID", "APPVEYOR_BUILD_ID", "BUILDKITE_JOB_ID", "BUILD_NUMBER", "CIRCLE_BUILD_NUM", "CI_BUILD_NUMBER", "DRONE_BUILD_NUMBER", "SEMAPHORE_BUILD_NUMBER", "TDDIUM_SESSION_ID", "TRAVIS_JOB_ID", "WERCKER_BUILD_ID"}
var ciBuildIDVars = []string{"CI_BUILD_ID", "APPVEYOR_BUILD_ID", "BUILDKITE_JOB_ID", "BUILD_NUMBER", "CIRCLE_BUILD_NUM", "CI_BUILD_NUMBER", "DRONE_BUILD_NUMBER", "HEROKU_TEST_RUN_ID", "SEMAPHORE_BUILD_NUMBER", "TDDIUM_SESSION_ID", "TRAVIS_JOB_ID", "WERCKER_BUILD_ID"}

var ciBuildURLVars = []string{"CI_BUILD_URL", "APPVEYOR_API_URL", "BUILDKITE_BUILD_URL", "BUILD_URL", "CIRCLE_BUILD_NUM", "DRONE_BUILD_LINK", "WERCKER_BUILD_URL"}
4 changes: 2 additions & 2 deletions env/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ func loadFromGit(gitArgs ...string) (string, error) {
return strings.TrimSpace(string(out)), nil
}

var gitBranchVars = []string{"GIT_BRANCH", "APPVEYOR_REPO_BRANCH", "BRANCH_NAME", "BUILDKITE_BRANCH", "CIRCLE_BRANCH", "CI_BRANCH", "CI_BUILD_REF_NAME", "DRONE_BRANCH", "TRAVIS_PULL_REQUEST_BRANCH", "TRAVIS_BRANCH", "WERCKER_GIT_BRANCH", "CI_COMMIT_REF_NAME"}
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"}

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", "WERCKER_GIT_COMMIT", "TRAVIS_PULL_REQUEST_SHA", "TRAVIS_COMMIT", "CI_COMMIT_SHA"}
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"}

var gitCommittedAtVars = []string{"GIT_COMMITTED_AT", "GIT_COMMITED_AT", "CI_COMMITTED_AT", "CI_COMMITED_AT", "CI_TIMESTAMP"}

Expand Down

0 comments on commit a031850

Please sign in to comment.