-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
155 lines (121 loc) · 5.64 KB
/
Copy pathjustfile
File metadata and controls
155 lines (121 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# Fable.Actor development tasks
# Development mode: compile with a local Fable checkout instead of the pinned dotnet tool.
# Whatever branch that checkout has out is what gets used — every backend lives in one repo.
# Usage: just dev=true test-beam
# decision: switches every backend through one fable variable so dev mode cannot silently mix compiler versions
# assumption: the sibling ../Fable checkout contains src/Fable.Cli when dev=true
dev := "false"
fable_repo := justfile_directory() / "../Fable"
fable := if dev == "true" { "dotnet run --project " + fable_repo / "src/Fable.Cli" + " --" } else { "dotnet fable" }
src_path := "src/Fable.Actor"
build_path := "build"
test_path := "test"
# List available recipes
default:
@just --list
# Clean build artifacts
clean:
rm -rf apps _build {{build_path}}
rm -rf {{timeflies_path}}/apps {{timeflies_path}}/_build {{timeflies_py_out}}
# --- Build ---
# Build F# to Erlang via Fable.Beam, then compile with rebar3
build: clean
{{fable}} src/Fable.Actor --exclude Fable.Core --lang beam --outDir apps/fable_actor --noCache
rebar3 compile
# Build F# projects only (type check)
check:
dotnet build src/Fable.Actor
dotnet build {{test_path}}
# Format source files
format:
dotnet fantomas src {{test_path}}
# Setup tooling
restore:
dotnet tool restore
# Build and check
all: check build
# --- Packaging ---
# Create NuGet package with version from CHANGELOG.md
pack:
#!/usr/bin/env bash
set -euo pipefail
VERSION=$(grep -m1 '^## ' CHANGELOG.md | sed 's/^## \([^ ]*\).*/\1/')
dotnet pack {{src_path}} -c Release -p:PackageVersion=$VERSION -p:InformationalVersion=$VERSION
# Create NuGet package with specific version (used in CI)
pack-version version:
dotnet pack {{src_path}} -c Release -p:PackageVersion={{version}} -p:InformationalVersion={{version}}
# Release: pack and push to NuGet
release: pack
dotnet nuget push 'src/**/Release/*.nupkg' -s https://api.nuget.org/v3/index.json -k $NUGET_KEY
# Run EasyBuild.ShipIt for release management
shipit *args:
dotnet shipit --pre-release rc {{args}}
# --- Tests ---
# One suite in test/, compiled to each target from the same project. Assertions come from
# Scriptorium.Nib, the runner from Scriptorium.Quill.
# decision: compiles one test project to all targets because the library itself has one conditional project
# invariant: every test recipe executes the same F# suite through its target runtime
# tradeoff: target-specific setup stays in recipes and Helpers.fs to prevent divergent suites
# Run the behavioral suite on every target (.NET + Python + JS + BEAM)
test: test-native test-python test-js test-beam
# .NET target: a real behavioral run — the non-BEAM Actor is MailboxProcessor-based
test-native:
dotnet run --project {{test_path}}
# Python target: compile the suite to Python and run the explicit runner
test-python:
rm -rf {{build_path}}/tests-py
{{fable}} {{test_path}} --exclude Fable.Core --lang python --outDir {{build_path}}/tests-py
uv run python {{build_path}}/tests-py/main.py
# JS target: compile the suite to JS and run it under Node
test-js:
rm -rf {{build_path}}/tests-js
{{fable}} {{test_path}} --exclude Fable.Core --lang javascript --outDir {{build_path}}/tests-js
echo '{"type":"module"}' > {{build_path}}/tests-js/package.json
node {{build_path}}/tests-js/Main.js
# BEAM target: compile the suite to Erlang, build with rebar3, run on the BEAM VM.
# Fable pulls the Fable.Actor sources into the same outDir, so this app is self-contained
# and the generated rebar.config needs no edits. Quill calls halt/1 with the exit code.
test-beam:
rm -rf {{build_path}}/tests-beam
{{fable}} {{test_path}} --exclude Fable.Core --lang beam --outDir {{build_path}}/tests-beam
cd {{build_path}}/tests-beam && rebar3 compile
cd {{build_path}}/tests-beam && erl -noshell -pa _build/default/lib/*/ebin -eval 'main:main([])'
# --- Timeflies example ---
timeflies_path := "examples/timeflies-beam"
timeflies_src := timeflies_path / "src"
timeflies_app := timeflies_path / "apps/timeflies"
# Build timeflies example: F# → Erlang, compile with rebar3
build-timeflies: build
{{fable}} {{timeflies_src}} --exclude Fable.Core --lang beam --outDir {{timeflies_app}} --noCache
cp {{timeflies_src}}/erl/*.erl {{timeflies_app}}/src/
cd {{timeflies_path}} && rebar3 compile
# Run timeflies demo server on http://localhost:3000
run-timeflies: build-timeflies
cd {{timeflies_path}} && erl \
-pa _build/default/lib/*/ebin \
-noshell \
-eval "fable_actor_timeflies_app:start()" \
-eval "receive stop -> ok end"
# --- Timeflies Python example ---
timeflies_py_path := "examples/timeflies-python"
timeflies_py_src := timeflies_py_path / "src"
timeflies_py_out := timeflies_py_path / "output"
# Build timeflies-python: F# → Python via Fable
build-timeflies-python:
rm -rf {{timeflies_py_out}}
{{fable}} {{timeflies_py_src}} --lang python --outDir {{timeflies_py_out}} --exclude Fable.Core --noCache
touch {{timeflies_py_out}}/src/__init__.py
touch {{timeflies_py_out}}/src/Fable_Actor/__init__.py
# Run timeflies-python demo
run-timeflies-python: build-timeflies-python
cd {{timeflies_py_out}} && uv run --project ../pyproject.toml python program.py
# --- Timeflies JS example ---
timeflies_js_path := "examples/timeflies-js"
timeflies_js_src := timeflies_js_path / "src"
# Build timeflies-js: F# → JavaScript via Fable
build-timeflies-js:
cd {{timeflies_js_path}} && npm install
cd {{timeflies_js_path}} && {{fable}} src --noCache
# Run timeflies-js demo on http://localhost:3000
run-timeflies-js: build-timeflies-js
cd {{timeflies_js_path}} && npx vite