forked from garnix-io/garn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjustfile
182 lines (142 loc) · 4.39 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# Show the available commands
list:
just --list
# Check what we can before pushing changes
pre-push: fmt github-ci
fast-pre-push: fmt update-flakefiles test check-examples typescript-check test-ts
# Run checks that we can’t yet run via the flake
github-ci: codegen test check-isolated-garn check-examples test-ts update-flakefiles check-git-is-unchanged
fmt: fmt-nix fmt-haskell fmt-typescript hpack
check: fmt-nix-check fmt-haskell-check hpack-check fmt-typescript-check
# Deploy the current website
deploy-website commit:
#!/usr/bin/env bash
set -eux
TMP_DIR=$(mktemp --directory)
DIST_DIR=$TMP_DIR/dist
mkdir -p $DIST_DIR
cd $TMP_DIR
git clone git@github.com:garnix-io/garn
cd garn
git reset --hard {{ commit }}
COMMIT=$(git rev-parse HEAD)
just build-install-script-files
(cd website2 && npm install && npm run build)
mv -v website2/out/* $DIST_DIR
git clean -dfx
git checkout gh-pages
cp -rv $DIST_DIR/* .
touch .nojekyll
git add .
git commit -m "Website update from commit $COMMIT"
git show --stat
echo "Created a new commit in $TMP_DIR/garn . It is not yet pushed."
# Push the current version of the ts files to gh-pages
release-ts commit tag:
#!/usr/bin/env bash
set -eux
TMP_DIR=$(mktemp --directory)
cd $TMP_DIR
git clone git@github.com:garnix-io/garn
cd garn
git reset --hard {{ commit }}
git tag {{ tag }}
just codegen
mkdir -p tmp-{{ tag }}
cp -r ts/* tmp-{{ tag }}
git checkout gh-pages
mkdir -p ts/{{ tag }}/
mv -v tmp-{{ tag }}/* ts/{{ tag }}/
rmdir tmp-{{ tag }}
git add ts/{{ tag }}
git commit -m "Release {{ tag }}"
git show --stat
echo "Created a new commit in $TMP_DIR/garn . It is not yet pushed."
echo "Created a new tag ({{ tag }}) too. Also not yet pushed."
fmt-nix:
nixpkgs-fmt .
fmt-nix-check:
nixpkgs-fmt --check .
fmt-haskell:
just ormolu inplace
fmt-haskell-check:
just ormolu check
ormolu mode:
#!/usr/bin/env bash
set -eux
ormolu \
--mode {{ mode }} \
$(find . -name '*.hs' | grep -v '^./dist-newstyle/')
if [[ "{{ mode }}" == inplace ]]; then
fhi $(find . -name '*.hs' | grep -v '^./dist-newstyle/')
fi
fmt-typescript:
prettier --write $(fd .ts ts | grep -v 'nixpkgs.ts\|version.ts')
fmt-typescript-check:
prettier --check $(fd .ts ts | grep -v 'nixpkgs.ts\|version.ts')
hpack:
hpack
cabal2nix . > garn.nix
nixpkgs-fmt garn.nix
hpack-check:
#!/usr/bin/env runhaskell
import Control.Monad
import System.Process
main = do
oldCabal <- readFile "garn.cabal"
newCabal <- readProcess "hpack" (words "-") ""
when (oldCabal /= newCabal) $
error "package.yaml has changed, please run hpack"
test-ts *args="":
deno test --check --parallel --allow-write --allow-read --allow-run --allow-net ts/*.test.ts ts/**/*.test.ts {{ args }}
test *args="": hpack
cabal run --test-show-details=streaming garn:spec -- {{ args }}
# Run the tests continuously as the code changes
watch *args="": hpack
ghcid --command "cabal repl test:spec" --test ':main {{ args }}' --warnings --reload=ts
fileserver *args="":
nix run .#fileserver -- {{ args }}
run-garn example *args="": hpack
#!/usr/bin/env bash
set -eux
cd examples/{{ example }}
cabal run garn:garn -- {{ args }}
check-examples:
just run-garn haskell check
just run-garn haskell run helloFromHaskell.hello
just run-garn frontend-create-react-app check
rm examples/frontend-create-react-app/result
just run-garn frontend-create-react-app build main
ls examples/frontend-create-react-app/result/index.html
just run-garn frontend-yarn-webpack check
just run-garn go-http-backend check
just run-garn monorepo check
just run-garn python check
update-flakefiles:
#!/usr/bin/env bash
for EXAMPLE in examples/* website website2; do
if [ -e "$EXAMPLE/garn.ts" ]; then
(
cd "$EXAMPLE"
cabal run garn:garn -- generate
)
fi
done
check-git-is-unchanged:
test -z "$(git status --porcelain)"
codegen: hpack && typescript-check
cabal run codegen
typescript-check *args="":
deno check ts/*.ts ts/**/*.ts {{ args }}
echo checked!
check-isolated-garn:
test/check-isolated-garn.sh
# Start the docs website server
docs-server: build-install-script-files
cd website2 && npm install
cd website2 && npm run dev
build-install-script-files:
nix build -L .#installScriptFiles
mkdir -p website2/public
cp -rv result/* website2/public/
chmod -R u+rwX website2/public