-
Notifications
You must be signed in to change notification settings - Fork 1
/
justfile
138 lines (105 loc) · 2.6 KB
/
justfile
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
set export := true
# --------------
# Internal Use
# Or
# Documentation
# --------------
# Application
database := justfile_directory() + "/database"
server := justfile_directory() + "/src"
client := justfile_directory() + "/client"
server_port := "8080"
# Utils
replace := if os() == "linux" { "sed -i" } else { "sed -i '' -e" }
# Lists all availiable targets
default:
just --list
[doc('Formats source code. Options = { "client" [Default], "server", "justfile" }')]
format source='client':
#!/usr/bin/env bash
set -euo pipefail
t=$(echo {{ source }} | cut -f2 -d=)
echo "Selected Target: $t"
if [[ $t == "client" ]]; then
zig fmt .
elif [[ $t == "justfile" ]]; then
just --fmt --unstable
elif [[ $t == "server" ]]; then
rebar3 fmt
else
echo "No formating selected, skipping step..."
fi
# ---------
# Database
# ---------
# Login into the local Database as `admin`
db:
psql -U admin mmo
# Bootstraps the local nix-based postgres server
postgres:
devenv up
# -------
# Client
# -------
client:
cd client && zig build run
client-build:
cd client && zig build
client-test:
cd client && zig build test
client-build-ci:
cd client && zig build -fsys=raylib
client-test-ci:
cd client && zig build test -fsys=raylib
client-deps:
cd client && nix run github:Cloudef/zig2nix#zon2nix -- build.zig.zon > zon-deps.nix
# --------
# Backend
# --------
build:
rebar3 compile
# Fetches rebar3 dependencies, updates both the rebar and nix lockfiles
deps:
rebar3 get-deps
rebar3 nix lock
# Runs ther erlang server (inside the rebar shell)
server: build
rebar3 shell
# Runs unit tests in the server
test:
rebar3 do eunit, ct
# Migrates the DB (up)
db-up:
./migrate_up.sh
# Nukes the DB
db-down:
./migrate_down.sh
# --------
# Releases
# --------
# Create a prod release of the server
release: deps
rebar3 as prod release
# Create a prod release (for nix) of the server
release-nix:
rebar3 as prod tar
# ----------
# Deployment
# ----------
# Builds the deployment docker image with Nix
build-docker:
nix build .#dockerImage
# Updates Heroku's registry with the new image
_update-registry:
docker load < ./result
docker tag lyceum:latest registry.heroku.com/lyceum/web
docker push registry.heroku.com/lyceum/web
update-registry: build-docker
_update-registry
update-registry-ci:
_update-registry
# Release app with the new docker image on Heroku
heroku-release: update-registry
heroku container:release -a=lyceum web
heroku-release-ci:
heroku container:release -a=lyceum web