summaryrefslogtreecommitdiff
path: root/2024/OCaml/Taskfile.yml
diff options
context:
space:
mode:
authorDJ O'Leary <dijitol@proton.me>2025-03-03 00:56:33 +0100
committerDJ O'Leary <dijitol@proton.me>2025-03-03 00:56:33 +0100
commite24effa8fd3574e9d396be0e1a47f101c27c0a60 (patch)
tree793896d20384facd10d925e09f8f0dd89c930cce /2024/OCaml/Taskfile.yml
perf: Merge Advent of Code year specific repos
Diffstat (limited to '2024/OCaml/Taskfile.yml')
-rw-r--r--2024/OCaml/Taskfile.yml100
1 files changed, 100 insertions, 0 deletions
diff --git a/2024/OCaml/Taskfile.yml b/2024/OCaml/Taskfile.yml
new file mode 100644
index 0000000..067ecec
--- /dev/null
+++ b/2024/OCaml/Taskfile.yml
@@ -0,0 +1,100 @@
+# https://taskfile.dev
+
+version: '3'
+
+vars:
+ PROJECT_NAME: AoC_2024
+ YEAR: 2024
+ ASSET_DIR: input
+ SRC_DIR: lib
+ SRC_TEMPLATE: part.ml
+ TEST_DIR: test
+ TEST_TEMPLATE: test.ml
+
+dotenv: ['.env']
+
+tasks:
+ default:
+ desc: "Prints this message"
+ cmds:
+ - cmd: task --list-all
+
+ day:setup:
+ desc: "Creates the files needed to solve a day of Advent of Code"
+ requires:
+ vars:
+ - DAY
+ vars:
+ FORMATTED_DAY: "{{if (lt (atoi .DAY) 10)}}0{{.DAY}}{{else}}{{.DAY}}{{end}}"
+ cmds:
+ - cmd: mkdir --parents {{ .SRC_DIR }}/day_{{ .FORMATTED_DAY }}
+ - cmd: cp templates/{{.SRC_TEMPLATE}} {{.SRC_DIR}}/day_{{.FORMATTED_DAY}}/part_01.ml
+ - cmd: mkdir --parents {{ .TEST_DIR }}
+ - cmd: cp templates/{{.TEST_TEMPLATE}} {{.TEST_DIR}}/day_{{.FORMATTED_DAY}}_part_01.ml
+ - task: fetch-input
+ - task: build
+ silent: true
+
+ fetch-input:
+ desc: "Fetches your input from adventofcode.com for the specified day"
+ internal: true
+ requires:
+ vars:
+ - DAY
+ vars:
+ URI: https://adventofcode.com/{{ .YEAR }}/day/{{.DAY}}/input
+ FORMATTED_DAY: "{{if (lt (atoi .DAY) 10)}}0{{.DAY}}{{else}}{{.DAY}}{{end}}"
+ cmds:
+ - cmd: curl --cookie 'session={{.SESSION}}' {{.URI}} > {{.ASSET_DIR}}/day_{{.FORMATTED_DAY}}.txt
+ silent: true
+
+ build:doc:
+ desc: "Builds documentation using ocamldoc"
+ preconditions:
+ - which ocamldoc
+ cmds:
+ - cmd: ocamldoc -html -d docs bin/main.ml
+ silent: true
+
+ build:
+ desc: "Builds the project"
+ preconditions:
+ - which dune
+ cmds:
+ - cmd: dune build
+
+ test:
+ desc: "Runs the tests in the 'tests' directory"
+ ignore_error: true
+ env:
+ OUNIT_CI: true
+ preconditions:
+ - which dune
+ deps:
+ - task: build
+ cmds:
+ - cmd: dune test {{.CLI_ARGS}}
+
+ test:watch:
+ desc: "Continuously runs the tests in the 'tests' directory"
+ ignore_error: true
+ sources:
+ - "lib/**/*.ml"
+ - "test/**/*.ml"
+ env:
+ OUNIT_CI: true
+ preconditions:
+ - which dune
+ deps:
+ - task: build
+ cmds:
+ - cmd: dune test --watch {{.CLI_ARGS}}
+
+ run:
+ desc: "Runs the project"
+ preconditions:
+ - which dune
+ deps:
+ - task: build
+ cmds:
+ - cmd: dune exec {{.PROJECT_NAME}}