Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanlong committed Jun 29, 2018
0 parents commit 8374f0a
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 80

# PEP8 says use 4-space indent
[*.py]
indent_size = 4

# Makefiles only support tab indents
[Makefile]
indent_style = tab
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
_build
_coverage
.merlin
*.install
bisect*.out
1 change: 1 addition & 0 deletions .ocp-indent
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JaneStreet
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <http://unlicense.org/>
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
all: build

build:
@jbuilder build @install @examples

clean:
@rm -rf `find . -name 'bisect*.out'` _coverage
@jbuilder clean

coverage: clean
@BISECT_ENABLE=YES jbuilder runtest
@bisect-ppx-report -I _build/default/ -html _coverage/ \
`find . -name 'bisect*.out'`

test:
@jbuilder runtest --force

.PHONY: all build clean coverage test
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[![CircleCI](https://circleci.com/gh/brendanlong/ocaml-project-template.svg?style=shield)](https://circleci.com/gh/brendanlong/ocaml-project-template)
[![Coverage Status](https://coveralls.io/repos/github/brendanlong/ocaml-project-template/badge.svg?branch=master)](https://coveralls.io/github/brendanlong/ocaml-project-template?branch=master)

# Example OCaml project

This is the base project I use when making new OCaml projects. It comes with:

- Dune (jbuilder) build system
- Git config
- ocp-indent and EditorConfig for 2-space indent
- Example opam config
- A public-domain license (replace with a different one if you don't like it)
- A generic OCaml CircleCI build
1 change: 1 addition & 0 deletions bin/example_bin.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
open Example
11 changes: 11 additions & 0 deletions bin/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(jbuild_version 1)

(executables
((names (example_bin))
(libraries (example))
(preprocess (pps (ppx_jane)))))

(alias
((name examples)
(deps (example_bin.exe))))

45 changes: 45 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
version: 2
jobs:
build:
docker:
- image: ocaml/opam:ubuntu-17.04_ocaml-4.05.0
environment:
TERM: xterm
steps:
- checkout
- run:
name: Update opam
command: |
opam remote remove default
opam remote add default https://opam.ocaml.org
- run:
name: Pin packages
command: |
for p in *.opam; do
opam pin add -y -n ${p%.opam} .
done
- run:
name: Install system dependencies
command: opam depext -y `basename -s .opam *.opam | tr '\n' ' '`
- run:
name: Install OCaml dependencies
command: opam install --deps-only -y `basename -s .opam *.opam | tr '\n' ' '`
- run:
# This is a separate step so we don't run tests for all of these ^
name: Install OCaml test dependencies
command: opam install --deps-only -t -y `basename -s .opam *.opam | tr '\n' ' '`
- run:
name: Build
command: opam config exec -- make
- run:
name: Test
command: opam config exec -- make coverage
- run:
name: Install ocveralls
command: opam install -y ocveralls
- run:
name: Upload coverage report
command: |
cd _build/default
shopt -s globstar
opam config exec -- ocveralls **/bisect*.out --send --repo_token $COVERALLS_REPO_TOKEN --git
19 changes: 19 additions & 0 deletions example.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
opam-version: "1.2"
version: "0.1"
maintainer: "you@example.com"
homepage: "https://github.com/your-org/project-name"
dev-repo: "https://github.com/your-org/project-name.git"
bug-reports: "https://github.com/your-org/project-name/issues"

build: ["jbuilder" "build" "-p" name "-j" jobs]
build-test: ["jbuilder" "runtest" "-p" name "-j" jobs]

depends: [
"ppx_jane" {build}
"bisect_ppx" {build & >= "1.3.1"}
"jbuilder" {build & >= "1.0+beta18"}

"ounit" {test}
]

available: [ocaml-version >= "4.05.0"]
1 change: 1 addition & 0 deletions src/.exclude
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
file regexp ".*_[jt].ml"
Empty file added src/example.ml
Empty file.
10 changes: 10 additions & 0 deletions src/jbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(jbuild_version 1)

(library
((name example)
(public_name example)
(libraries ())
(inline_tests ((flags (-verbose))))
(preprocess (pps (ppx_jane bisect_ppx -conditional
(-exclude-file src/.exclude))))
(preprocessor_deps (.exclude))))

0 comments on commit 8374f0a

Please sign in to comment.