diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..a7e7ee2 --- /dev/null +++ b/.github/workflows/test.yaml @@ -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 }} diff --git a/.gitignore b/.gitignore index 102f12b..8a6472f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ _build _opam -_release -_esy +_coverage .depend .merlin @@ -14,9 +13,3 @@ _esy node_modules .DS_Store - -# Melange Specifics -.bsb.lock -dune.mel -.melange.eobjs -/dune \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 416eea7..53cbc09 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,6 @@ "ocaml.sandbox": { "kind": "opam", "switch": "${workspaceFolder:pinc-lang}" - } -} \ No newline at end of file + }, + "liveServer.settings.port": 5501 +} diff --git a/Makefile b/Makefile index 71e04c5..ac518cd 100644 --- a/Makefile +++ b/Makefile @@ -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 @@ -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: @@ -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 diff --git a/dune-project b/dune-project index b2d54b3..ae80872 100644 --- a/dune-project +++ b/dune-project @@ -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) + )) diff --git a/lib/dune b/lib/dune index e4e0f6b..fd0a9e5 100644 --- a/lib/dune +++ b/lib/dune @@ -1,4 +1,6 @@ (library (name pinc) (public_name pinc-lang) - (libraries Pinc_Backend)) + (libraries Pinc_Backend) + (instrumentation + (backend bisect_ppx))) diff --git a/lib/pinc_backend/dune b/lib/pinc_backend/dune index a70c721..ba90879 100644 --- a/lib/pinc_backend/dune +++ b/lib/pinc_backend/dune @@ -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))) diff --git a/lib/pinc_diagnostics/dune b/lib/pinc_diagnostics/dune index 7bc1a03..960c529 100644 --- a/lib/pinc_diagnostics/dune +++ b/lib/pinc_diagnostics/dune @@ -1,4 +1,6 @@ (library (name Pinc_Diagnostics) (public_name pinc-lang.diagnostics) - (libraries fmt)) + (libraries fmt) + (instrumentation + (backend bisect_ppx))) diff --git a/lib/pinc_frontend/dune b/lib/pinc_frontend/dune index 30cb749..4eab1fc 100644 --- a/lib/pinc_frontend/dune +++ b/lib/pinc_frontend/dune @@ -1,4 +1,6 @@ (library (name Pinc_Frontend) (public_name pinc-lang.frontend) - (libraries Pinc_Diagnostics)) + (libraries Pinc_Diagnostics) + (instrumentation + (backend bisect_ppx))) diff --git a/pinc-lang.opam b/pinc-lang.opam index 21f1199..8f6662d 100644 --- a/pinc-lang.opam +++ b/pinc-lang.opam @@ -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: [