Skip to content

Commit

Permalink
chore: add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
eWert-Online committed Jul 8, 2023
1 parent 3b05fba commit 9ceb651
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 20 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
push:
branches:
- 'main'

pull_request:
branches:
- '*'

jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
ocaml-compiler:
- 5.0.x

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- name: Install dependencies
run: opam install . --locked --deps-only --with-test --yes

- name: Build and test
run: |
make
make test
make test-coverage
- name: Send coverage
run: |
opam exec -- bisect-ppx-report send-to Coveralls --coverage-path /tmp/pinc-lang
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 1 addition & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
_build
_opam
_release
_esy
_coverage

.depend
.merlin
Expand All @@ -14,9 +13,3 @@ _esy
node_modules

.DS_Store

# Melange Specifics
.bsb.lock
dune.mel
.melange.eobjs
/dune
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"ocaml.sandbox": {
"kind": "opam",
"switch": "${workspaceFolder:pinc-lang}"
}
}
},
"liveServer.settings.port": 5501
}
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: all build install update fmt fmt-check test test-update clean clear
.SILENT: all build install update fmt fmt-check test test-update clean clear
.PHONY: all build install update fmt fmt-check test test-update test-coverage clean clear
.SILENT: all build install update fmt fmt-check test test-update test-coverage clean clear

all: build

Expand All @@ -10,8 +10,7 @@ install:
if ! [ -e _opam ]; then \
opam switch create . --empty ; \
fi
opam install . --locked --deps-only --working-dir --yes
opam install -y ocaml-lsp-server ocamlformat
opam install . --deps-only --with-test --with-dev-setup --yes
opam lock .

update:
Expand All @@ -30,8 +29,14 @@ test:
test-update:
dune build @runtest --auto-promote

test-coverage:
if [ -d /tmp/pinc-lang ]; then rm -r /tmp/pinc-lang; fi
mkdir -p /tmp/pinc-lang
BISECT_FILE=/tmp/pinc-lang/pinc-lang dune runtest --no-print-directory --instrument-with bisect_ppx --force
bisect-ppx-report html --coverage-path /tmp/pinc-lang
bisect-ppx-report summary --coverage-path /tmp/pinc-lang

clean:
mel clean
rm -rf _build

clear: clean
Expand Down
9 changes: 8 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,11 @@
(package
(name pinc-lang)
(synopsis "The PiNC Language as Syntax and Interpreter")
(depends ocaml fmt dune))
(depends
ocaml
fmt
dune
(bisect_ppx :with-test)
(ocaml-lsp-server :with-dev-setup)
(ocamlformat :with-dev-setup)
))
4 changes: 3 additions & 1 deletion lib/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(library
(name pinc)
(public_name pinc-lang)
(libraries Pinc_Backend))
(libraries Pinc_Backend)
(instrumentation
(backend bisect_ppx)))
4 changes: 3 additions & 1 deletion lib/pinc_backend/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(library
(name Pinc_Backend)
(public_name pinc-lang.backend)
(libraries Pinc_Diagnostics Pinc_Frontend))
(libraries Pinc_Diagnostics Pinc_Frontend)
(instrumentation
(backend bisect_ppx)))
4 changes: 3 additions & 1 deletion lib/pinc_diagnostics/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(library
(name Pinc_Diagnostics)
(public_name pinc-lang.diagnostics)
(libraries fmt))
(libraries fmt)
(instrumentation
(backend bisect_ppx)))
4 changes: 3 additions & 1 deletion lib/pinc_frontend/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
(library
(name Pinc_Frontend)
(public_name pinc-lang.frontend)
(libraries Pinc_Diagnostics))
(libraries Pinc_Diagnostics)
(instrumentation
(backend bisect_ppx)))
3 changes: 3 additions & 0 deletions pinc-lang.opam
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ depends: [
"ocaml"
"fmt"
"dune" {>= "3.6"}
"bisect_ppx" {with-test}
"ocaml-lsp-server" {with-dev-setup}
"ocamlformat" {with-dev-setup}
"odoc" {with-doc}
]
build: [
Expand Down

0 comments on commit 9ceb651

Please sign in to comment.