Skip to content

Commit

Permalink
Add support for automatic uploading to gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGross committed Mar 20, 2024
1 parent e302656 commit cc67972
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ instrument the code under test, but not the tester:
`bisect-ppx-report` can send reports to [**Coveralls**](https://coveralls.io)
and [**Codecov**](https://codecov.io/) directly from **Travis**, **CircleCI**,
and **GitHub Actions**. To do this, run
**GitHub Actions**, and **GitLab**. To do this, run
```
bisect-ppx-report send-to Coveralls
Expand Down Expand Up @@ -393,6 +393,7 @@ follows:
| Jenkins | `jenkins` | `$BUILD_ID` |
| Codeship | `codeship` | `$CI_BUILD_NUMBER` |
| GitHub Actions | `github` | `$GITHUB_RUN_NUMBER` |
| GitLab | `gitlab` | `$CI_JOB_ID` |
Note that Coveralls-style reports are less precise than the HTML reports
generated by Bisect_ppx, because Coveralls considers entire lines as visited or
Expand Down
8 changes: 8 additions & 0 deletions src/report/coveralls.ml
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ type ci = [
| `CircleCI
| `Travis
| `GitHub
| `GitLab
]

module CI :
Expand All @@ -169,22 +170,26 @@ struct
environment_variable "CIRCLECI" "true" `CircleCI @@ fun () ->
environment_variable "TRAVIS" "true" `Travis @@ fun () ->
environment_variable "GITHUB_ACTIONS" "true" `GitHub @@ fun () ->
environment_variable "GITLAB_CI" "true" `GitLab @@ fun () ->
None

let pretty_name = function
| `CircleCI -> "CircleCI"
| `Travis -> "Travis"
| `GitHub -> "GitHub Actions"
| `GitLab -> "GitLab CI"

let name_in_report = function
| `CircleCI -> "circleci"
| `Travis -> "travis-ci"
| `GitHub -> "github"
| `GitLab -> "gitlab"

let job_id_variable = function
| `CircleCI -> "CIRCLE_BUILD_NUM"
| `Travis -> "TRAVIS_JOB_ID"
| `GitHub -> "GITHUB_RUN_NUMBER"
| `GitLab -> "CI_JOB_ID"
end

type coverage_service = [
Expand Down Expand Up @@ -220,12 +225,14 @@ struct
match ci, service with
| `CircleCI, `Coveralls -> Some "CIRCLE_PULL_REQUEST"
| `GitHub, `Coveralls -> Some "PULL_REQUEST_NUMBER"
| `GitLab, `Coveralls -> Some "CI_EXTERNAL_PULL_REQUEST_IID"
| _ -> None

let needs_repo_token ci service =
match ci, service with
| `CircleCI, `Coveralls -> true
| `GitHub, `Coveralls -> true
| `GitLab, `Coveralls -> true
| _ -> false

let repo_token_variables = function
Expand All @@ -236,6 +243,7 @@ struct
match ci, service with
| `CircleCI, `Coveralls -> true
| `GitHub, `Coveralls -> true
| `GitLab, `Coveralls -> true
| _ -> false
end

Expand Down

0 comments on commit cc67972

Please sign in to comment.