Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure if this is right, but it's what's listed here

| _ -> 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