Skip to content

Commit

Permalink
code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
epatrizio committed Aug 29, 2024
1 parent 50ed435 commit 16d2d1e
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
opam exec -- dune build @install
- name: test
run: |
opam exec -- dune runtest
BISECT_FILE=$(pwd)/bisect opam exec -- dune runtest --force --instrument-with bisect_ppx
# opam exec -- dune runtest
- name: lint-doc
run: |
ODOC_WARN_ERROR=true opam exec -- dune build @doc 2> output.txt || true
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: deploy

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: cache
id: cache-opam
uses: actions/cache@v4
env:
cache-name: cache-opam-deploy
with:
path: |
~/work/ola/ola/_opam/
key: ${{ runner.os }}-deploy-${{ env.cache-name }}-${{ hashFiles('**/*.opam') }}
- name: setup-ocaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "4.14"
dune-cache: true
opam-pin: true
allow-prerelease-opam: false
# - name: depext
# run: |
# sudo apt update
# opam install . --depext-only --with-test --with-doc
- name: setup-deploy
if: steps.cache-opam.outputs.cache-hit != 'true'
run: |
opam install . --deps-only --with-test --with-doc
opam install bisect_ppx ocb
# - name: api
# run: |
# touch doc/.nojekyll
# opam exec -- dune build @doc
# mv _build/default/_doc/_html doc/api
- name: build
run: |
opam exec -- dune build @install
- name: coverage
run: |
BISECT_FILE=$(pwd)/bisect opam exec -- dune runtest --force --instrument-with bisect_ppx
opam exec -- bisect-ppx-report html
- name: coverage-badge
run: |
label=coverage
percentage=$(opam exec -- bisect-ppx-report summary | sed -E 's/.*\((..).*/\1/g')
color=$(printf "%x%x%x" $((255-$percentage)) $((155+$percentage)) 85)
opam exec -- ocb --style classic --label $label --status $percentage'%' --color $color > _coverage/badge.svg
# - name: deploy
# uses: JamesIves/[email protected]
# with:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# BRANCH: gh-pages
# FOLDER: doc/
# CLEAN: true
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
*.cmxa

# ocamlbuild working directory
_build/
_build
_coverage

# ocamlbuild targets
*.byte
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ola - An OCaml Lua language interpreter
# ola - An OCaml Lua language interpreter [![build status](https://github.com/epatrizio/ola/workflows/build/badge.svg)](https://github.com/epatrizio/ola/actions)

This project is an interpreter of the [Lua 5.4](https://www.lua.org/manual/5.4/manual.html) programming language
written in [OCaml](https://ocaml.org) with the [Dune](https://dune.build) build system.
Expand All @@ -23,6 +23,11 @@ interprete ...
Hello, world!
```

```sh
$ bisect-ppx-report summary
Coverage: 225/1379 (16.32%)
```

- Install in current [opam OCaml switch](https://ocaml.org/docs/opam-switch-introduction): `dune install`
- Run: `ola file_name.lua` - `ola file_name.lua --debug`

Expand Down
18 changes: 15 additions & 3 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

(maintainers "Eric Patrizio <[email protected]>")

(source (github epatrizio/ola))
(source
(github epatrizio/ola))

(generate_opam_files true)

Expand All @@ -23,8 +24,10 @@
(package
(name ola)
(synopsis "OCaml Lua Interpreter")
(description "OCaml Lua Interpreter. Experimental project, work in progress ...")
(tags (ola ocaml lua interpreter))
(description
"OCaml Lua Interpreter. Experimental project, work in progress ...")
(tags
(ola ocaml lua interpreter))
(depends
(ocaml
(>= 4.14))
Expand All @@ -33,6 +36,15 @@
(and
:build
(>= 20220210)))
(bisect_ppx
(and
(>= 2.5)
:with-dev-setup))
(ocb
(and
:with-test
(>= "0.1")
:dev))
(odoc :with-doc)
(mdx
(and
Expand Down
2 changes: 2 additions & 0 deletions ola.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ depends: [
"ocaml" {>= "4.14"}
"sedlex"
"menhir" {build & >= "20220210"}
"bisect_ppx" {>= "2.5" & with-dev-setup}
"ocb" {with-test & >= "0.1" & dev}
"odoc" {with-doc}
"mdx" {with-test & >= "2.1"}
]
Expand Down
2 changes: 2 additions & 0 deletions src/bisect.exclude
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
file "src/parser.ml"
file "src/lexer.ml"
5 changes: 4 additions & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
typer)
(preprocess
(pps sedlex.ppx))
(libraries sedlex menhirLib))
(libraries sedlex menhirLib)
(instrumentation
(backend bisect_ppx --exclusions src/bisect.exclude)
(deps bisect.exclude)))

(menhir
(modules parser))

0 comments on commit 16d2d1e

Please sign in to comment.