Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlesAverill committed Aug 8, 2023
0 parents commit a2ed0fc
Show file tree
Hide file tree
Showing 27 changed files with 467 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI

on:
push:
branches: [ main ]

jobs:
build_test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Use OCaml 4.13.x
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.13.x

- name: Install Dependencies
run: |
opam install . --deps-only --with-test
eval $(opam env)
- name: Build Emulator
run: make build

- name: Run Unit Tests
run: make test

build_docs:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Use OCaml 4.13.x
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.13.x

- name: Install Dependencies
run: |
opam install . --deps-only --with-doc
eval $(opam env)
- name: Build Documentation
run: |
make docs
- name: Copy documentation to gh-pages branch
uses: actions/upload-artifact@v3
with:
name: docs
path: docs
retention-days: 1

publish_docs:
runs-on: ubuntu-latest
needs: build_docs

steps:
- uses: actions/checkout@v2
with:
ref: gh-pages

- name: Download documentation files
uses: actions/download-artifact@v2
with:
name: docs
path: docs

- name: Commit
uses: EndBug/add-and-commit@v9
with:
author_name: _AUTHOR_NAME_
author_email: _AUTHOR_EMAIL_
message: "Latest docs - ${{ github.event.repository.updated_at}}"
branch: gh-pages
add: '[./*]'
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*~
*.annot
*.cmo
*.cma
*.cmi
*.a
*.o
*.cmx
*.cmxs
*.cmxa
_build
1 change: 1 addition & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=0.25.1
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 _AUTHOR_NAME_

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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 OR COPYRIGHT HOLDERS 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.
77 changes: 77 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
.PHONY: default build install uninstall test clean fmt
.IGNORE: fmt

default: build

fmt:
opam exec -- dune build @fmt
opam exec -- dune promote

build: fmt
opam exec -- dune build

install:
opam exec -- dune install

uninstall:
opam exec -- dune uninstall

clean:
opam exec -- dune clean
git clean -dfXq

test: fmt
opam exec -- dune runtest

testf: fmt
opam exec -- dune runtest -f

run: build
opam exec -- dune exec -- _PROJECT_NAME_

raw_run: build
clear
_build/default/bin/main.exe

debug: build
opam exec -- ocamldebug _build/default/_PROJECT_NAME_/main.bc

DOCS_PATH=docs/
DOCS_NAME=_PROJECT_NAME_
DOCS_DESCR=An Ocaml Window Manager
DOCS_INDEX_TITLE=$(DOCS_NAME) - $(DOCS_DESCR)
define DOCS_EMBED
<meta content="$(DOCS_NAME)" property="og:title" />\
<meta content="$(DOCS_DESCR)" property="og:description" />\
<meta content="https://github.com/_AUTHOR_USERNAME_/_PROJECT_NAME_" property="og:url" />
endef

cleandocs:
if [ ! -d $(DOCS_PATH) ]; then \
mkdir $(DOCS_PATH); \
fi
rm -rf $(DOCS_PATH)module $(DOCS_PATH)docs $(DOCS_PATH)odoc.support $(DOCS_PATH)index.html

docs: cleandocs build
opam exec -- dune build @doc
mv -f _build/default/_doc/_html/* $(DOCS_PATH)
rm -f $(DOCS_PATH)index.html
mv $(DOCS_PATH)_PROJECT_NAME_/_PROJECT_NAME_.html $(DOCS_PATH)index.html
mv $(DOCS_PATH)_PROJECT_NAME_ $(DOCS_PATH)module

@echo "Preparing Index\n--------------"
# Header
sed -i 's/<title>.*<\/title>/<title>$(DOCS_INDEX_TITLE)<\/title>/g' $(DOCS_PATH)index.html
sed -i 's@</head>@<link rel="icon" href="media/favicon.ico" type="image/x-icon">\n</head>@g' $(DOCS_PATH)index.html
sed -i 's@</head>@$(DOCS_EMBED)\n</head>@g' $(DOCS_PATH)index.html
sed -i 's/..\/odoc.support/odoc.support/g' $(DOCS_PATH)index.html
# Body
sed -i 's@<nav class="odoc-nav">.*gbcamel</nav>@@g' $(DOCS_PATH)index.html

push: cleandocs build
@read -p "Commit message: " input; \
if [ -z "$input" ]; then \
echo "Error: Please provide a valid commit message."; \
exit 1; \
fi; \
git add . && git commit -m "$$input" && git push origin main
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Friendly OCaml Template

Just run `setup.sh` to set up a ready-for-development OCaml environment
4 changes: 4 additions & 0 deletions bin/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(executable
(public_name _PROJECT_NAME_)
(name main)
(libraries _PROJECT_NAME_))
1 change: 1 addition & 0 deletions bin/main.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let () = print_endline "Hello, World!"
23 changes: 23 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(lang dune 3.9)

(name _PROJECT_NAME_)

(generate_opam_files true)

(source
(github _AUTHOR_USERNAME_/_PROJECT_NAME_))

(authors "_AUTHOR_NAME_")

(maintainers "_AUTHOR_NAME_")

(license LICENSE)

(documentation https://github.com/_AUTHOR_USERNAME_/_PROJECT_NAME_)

(package
(name _PROJECT_NAME_)
(synopsis "An OCaml Window Mangaer")
(description "A window manager built on top of the Graphics library")
(depends ocaml dune graphics))

1 change: 1 addition & 0 deletions gbcamel.odocl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dir: ./docs
2 changes: 2 additions & 0 deletions lib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(library
(name _PROJECT_NAME_))
81 changes: 81 additions & 0 deletions ocaml_template/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI

on:
push:
branches: [ main ]

jobs:
build_test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Use OCaml 4.13.x
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.13.x

- name: Install Dependencies
run: |
opam install . --deps-only --with-test
eval $(opam env)
- name: Build Emulator
run: make build

- name: Run Unit Tests
run: make test

build_docs:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Use OCaml 4.13.x
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.13.x

- name: Install Dependencies
run: |
opam install . --deps-only --with-doc
eval $(opam env)
- name: Build Documentation
run: |
make docs
- name: Copy documentation to gh-pages branch
uses: actions/upload-artifact@v3
with:
name: docs
path: docs
retention-days: 1

publish_docs:
runs-on: ubuntu-latest
needs: build_docs

steps:
- uses: actions/checkout@v2
with:
ref: gh-pages

- name: Download documentation files
uses: actions/download-artifact@v2
with:
name: docs
path: docs

- name: Commit
uses: EndBug/add-and-commit@v9
with:
author_name: _AUTHOR_NAME_
author_email: _AUTHOR_EMAIL_
message: "Latest docs - ${{ github.event.repository.updated_at}}"
branch: gh-pages
add: '[./*]'
11 changes: 11 additions & 0 deletions ocaml_template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*~
*.annot
*.cmo
*.cma
*.cmi
*.a
*.o
*.cmx
*.cmxs
*.cmxa
_build
1 change: 1 addition & 0 deletions ocaml_template/.ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=0.25.1
21 changes: 21 additions & 0 deletions ocaml_template/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 _AUTHOR_NAME_

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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 OR COPYRIGHT HOLDERS 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.
Loading

0 comments on commit a2ed0fc

Please sign in to comment.