Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
demiazz committed Nov 20, 2024
0 parents commit ee624d7
Show file tree
Hide file tree
Showing 21 changed files with 971 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Pages

on:
push:
branches:
- main

permissions:
contents: read
id-token: write
pages: write

concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
deploy:
if: github.repository == 'demiazz/advent-of-ocaml'

name: Advent of OCaml

runs-on: ubuntu-latest

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: 5.2.0
dune-cache: true

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
cache: pnpm
node-version-file: .tool-versions

- name: Install dependencies
shell: bash
run: make init-ci

- name: Build docs
run: make build

- name: Upload docs artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist

- name: Deploy docs to Github Pages
id: deployment
uses: actions/deploy-pages@v4
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Node.js

dist
node_modules

# Opam

_opam/

# Dune

_build/

# macOS

.DS_Store

# Tests

input.txt
2 changes: 2 additions & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
profile = default
version = 0.26.2
Empty file added .vscode/settings.json
Empty file.
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ISC License

Copyright (c) 2024, Alexey Plutalov

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
33 changes: 33 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
YEAR=2015
DAY=1
PART=1

.PHONY: init build-native build-web build dev-web

init:
opam switch create . 5.2.0 -y --deps-only
pnpm install
opam install -y . --deps-only --with-dev
opam exec opam-check-npm-deps

init-ci:
pnpm install
opam install -y . --deps-only
opam exec opam-check-npm-deps

build-native:
opam exec -- dune build

build-web: build-native
pnpm vite build

build: build-native build-web

dev-web: build-native
pnpm vite dev

dev-native:
opam exec -- dune build --watch

run: build-native
_build/default/native/main.exe -y $(YEAR) -d $(DAY) -p $(PART) -i input.txt
23 changes: 23 additions & 0 deletions advent-of-ocaml.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
opam-version: "2.0"
synopsis: "Solutions of Advent of Code on OCaml"
description: "Solutions of Advent of Code on OCaml"
maintainer: ["Alexey Plutalov <demiazz.py@gmail.com>"]
authors: ["Alexey Plutalov <demiazz.py@gmail.com>"]
license: "ISC"
homepage: "https://github.com/demiazz/advent-of-ocaml"
bug-reports: "https://github.com/demiazz/advent-of-ocaml/issues"
depends: [
"ocaml" {>= "5.2.0"}
"reason" {>= "3.13.0"}
"dune" {>= "3.16.1"}
"melange" {>= "4.0.1-52"}
"reason-react" {>= "0.15.0"}
"reason-react-ppx" {>= "0.15.0"}
"opam-check-npm-deps" {with-dev-setup}
"ocaml-lsp-server" {with-dev-setup}
"ocamlformat" {with-dev-dev-setup}
"dot-merlin-reader" {with-dev-setup}
"utop" {with-dev-setup}
"odoc" {with-doc}
]
dev-repo: "git+https://github.com/demiazz/advent-of-ocaml"
4 changes: 4 additions & 0 deletions advent_of_code/advent_of_code.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
let solve () =
Utils.print_message "Solved!";

()
5 changes: 5 additions & 0 deletions advent_of_code/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(library
(name advent_of_code)
(modules advent_of_code)
(libraries utils)
(modes melange native))
5 changes: 5 additions & 0 deletions dune-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(lang dune 3.16)

(using melange 0.1)

(name advent-of-ocaml)
23 changes: 23 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="utf-8" />

<title>Advent of OCaml</title>

<link
ref="stylesheet"
href="./node_modules/@fontsource/source-code-pro/300.css"
/>

<link rel="shortcut icon" href="./web/assets/favicon.png" />

<script
src="./_build/default/web/output/web/main.js"
type="module"
></script>
</head>
<body>
<div id="root"></div>
</body>
</html>
4 changes: 4 additions & 0 deletions native/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(executable
(public_name advent-of-ocaml)
(name main)
(libraries advent_of_code))
15 changes: 15 additions & 0 deletions native/main.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
let usage = "advent-of-ocaml -y <year> -d <day> -p <part> -i <file>"
let year : int ref = ref 0
let day : int ref = ref 0
let part : int ref = ref 0
let input_file = ref ""

let speclist : (string * Arg.spec * string) list =
[
("-y", Arg.Set_int year, "Set year");
("-d", Arg.Set_int day, "Set day");
("-p", Arg.Set_int part, "Set part");
("-i", Arg.Set_string input_file, "Set input file name");
]

let () = Arg.parse speclist (fun _ -> ()) usage
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "advent-of-ocaml",
"private": true,
"version": "0.0.0",
"description": "Solutions of Advent of Code on OCaml",
"main": "index.js",
"keywords": [
"advent of code",
"zig",
"wasm"
],
"author": "Alexey Plutalov",
"license": "ISC",
"packageManager": "pnpm@9.12.1",
"dependencies": {
"@fontsource/source-code-pro": "^5.1.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.3.0",
"vite": "^5.4.11"
}
}
Loading

0 comments on commit ee624d7

Please sign in to comment.