Skip to content

Commit d972723

Browse files
authored
feature: code coverage support (#1064)
Signed-off-by: Ali Caglayan <[email protected]>
1 parent 07ba12b commit d972723

File tree

10 files changed

+67
-7
lines changed

10 files changed

+67
-7
lines changed

.github/workflows/build-and-test.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,34 @@ jobs:
6363

6464
- name: Run the template integration tests
6565
run: opam exec -- make test-e2e
66+
67+
coverage:
68+
name: Coverage
69+
runs-on: ubuntu-latest
70+
strategy:
71+
fail-fast: false
72+
matrix:
73+
ocaml-compiler:
74+
- 4.14.x
75+
steps:
76+
- uses: actions/checkout@v3
77+
- name: Use OCaml ${{ matrix.ocaml-compiler }}
78+
uses: ocaml/setup-ocaml@v2
79+
with:
80+
ocaml-compiler: ${{ matrix.ocaml-compiler }}
81+
opam-depext: false
82+
83+
- name: Set git user
84+
run: |
85+
git config --global user.name github-actions[bot]
86+
git config --global user.email github-actions[bot]@users.noreply.github.com
87+
88+
- name: Install deps on Unix
89+
run: |
90+
opam install . --deps-only
91+
opam exec -- make coverage-deps install-test-deps
92+
- run: opam exec -- make test-coverage
93+
continue-on-error: true
94+
env:
95+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
PULL_REQUEST_NUMBER: ${{ github.event.number }}

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,12 @@ nix-fmt:
9393
$(MAKE) yarn-install
9494
dune build @fmt --auto-promote
9595
cd $(TEST_E2E_DIR) && yarn fmt
96+
97+
.PHONY: coverage-deps
98+
coverage-deps:
99+
opam install -y bisect_ppx
100+
101+
.PHONY: test-coverage
102+
test-coverage:
103+
dune build --instrument-with bisect_ppx --force @lsp/test/runtest @lsp-fiber/runtest @jsonrpc-fiber/runtest @ocaml-lsp-server/runtest
104+
bisect-ppx-report send-to Coveralls

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
# OCaml-LSP <!-- omit from toc -->
22
<!-- TOC is updated automatically by "Markdown All in One" vscode extension -->
33

4-
[![Build](https://github.com/ocaml/ocaml-lsp/workflows/Build%20and%20Test/badge.svg)](https://github.com/ocaml/ocaml-lsp/actions)
4+
[![Build][build-badge]][build]
5+
[![Coverage Status][coverall-badge]][coverall]
6+
7+
[build-badge]: https://github.com/ocaml/ocaml-lsp/workflows/Build%20and%20Test/badge.svg
8+
[build]: https://github.com/ocaml/ocaml-lsp/actions
9+
[coverall-badge]: https://coveralls.io/repos/github/ocaml/ocaml-lsp/badge.svg?branch=master
10+
[coverall]: https://coveralls.io/github/ocaml/ocaml-lsp?branch=master
511

612
OCaml-LSP is a language server for OCaml that implements [Language Server
713
Protocol](https://microsoft.github.io/language-server-protocol/) (LSP).
@@ -27,6 +33,7 @@ Protocol](https://microsoft.github.io/language-server-protocol/) (LSP).
2733
- [Unusual features](#unusual-features)
2834
- [Debugging](#debugging)
2935
- [Contributing to project](#contributing-to-project)
36+
- [Changelog](#changelog)
3037
- [Tests](#tests)
3138
- [Relationship to Other Tools](#relationship-to-other-tools)
3239
- [History](#history)

jsonrpc-fiber/src/dune

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
(library
22
(name jsonrpc_fiber)
3-
(libraries fiber dyn jsonrpc ppx_yojson_conv_lib stdune yojson))
3+
(libraries fiber dyn jsonrpc ppx_yojson_conv_lib stdune yojson)
4+
(instrumentation
5+
(backend bisect_ppx)))

jsonrpc/src/dune

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
(library
2-
(public_name jsonrpc))
2+
(public_name jsonrpc)
3+
(instrumentation
4+
(backend bisect_ppx)))

lsp-fiber/src/dune

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@
99
lsp
1010
ppx_yojson_conv_lib
1111
stdune
12-
yojson))
12+
yojson)
13+
(instrumentation
14+
(backend bisect_ppx)))

lsp/src/dune

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
(public_name lsp)
66
(libraries jsonrpc ppx_yojson_conv_lib uutf yojson)
77
(lint
8-
(pps ppx_yojson_conv)))
8+
(pps ppx_yojson_conv))
9+
(instrumentation
10+
(backend bisect_ppx)))
911

1012
(cinaps
1113
(files types.ml types.mli)

ocaml-lsp-server/bin/dune

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
(name main)
33
(package ocaml-lsp-server)
44
(public_name ocamllsp)
5-
(libraries dune-build-info stdune lsp ocaml_lsp_server))
5+
(libraries dune-build-info stdune lsp ocaml_lsp_server)
6+
(instrumentation
7+
(backend bisect_ppx)))

ocaml-lsp-server/src/dune

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
ocamlformat-rpc-lib
3737
ocamlc-loc)
3838
(lint
39-
(pps ppx_yojson_conv)))
39+
(pps ppx_yojson_conv))
40+
(instrumentation
41+
(backend bisect_ppx)))
4042

4143
(include_subdirs unqualified)

submodules/lev/.github/workflows/workflow.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,4 @@ jobs:
3838
- run: opam install --deps-only --with-doc --with-test .
3939
- run: opam exec -- dune build
4040
- run: opam exec -- dune runtest
41+

0 commit comments

Comments
 (0)