-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
119 lines (99 loc) · 3.29 KB
/
Makefile
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
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
# SPDX-License-Identifier: MIT
.ONESHELL:
.PHONY: clean all assets install rake
.SILENT:
.SECONDARY:
.SHELLFLAGS := -x -e -o pipefail -c
SHELL := bash
YAMLS = $(wildcard tests/*.yml)
FBS = $(subst tests/,target/fb/,${YAMLS:.yml=.fb})
HTMLS = $(subst fb/,html/,${FBS:.fb=.html})
XSLS = $(subst xsl/,target/xsl/,$(wildcard xsl/*.xsl))
JUDGES = bundle exec judges
DIRS = target target/html target/fb target/xsl target/css target/js
CSS = target/css/main.css
JS = target/js/main.js
SAXON = target/saxon.jar
export
all: assets $(HTMLS) rake entry rmi verify
assets: $(XSLS) $(JS) $(CSS)
target/xsl/%.xsl: xsl/%.xsl | target/xsl
cp "$<" "$@"
target/output/%: target/fb/%.fb entry.sh Makefile $(XSLS) $(CSS) $(JS) $(SAXON) | target/html
export INPUT_VERBOSE=yes
export INPUT_OPTIONS=testing=yes
export GITHUB_WORKSPACE=.
export INPUT_FACTBASE=$<
export INPUT_COLUMNS=what,when,who
export INPUT_HIDDEN=_id,_time,_version
export INPUT_TODAY='2024-07-05T00:00:00Z'
fb=$$(basename $<)
fb=$${fb%.*}
export INPUT_OUTPUT=target/output/$${fb}
./entry.sh
target/html/%.html: target/output/%
n=$$(basename "$@")
n=$${n%.*}
cp "$$(dirname "$<")/$${n}/$${n}.html" "$$(dirname "$@")/$${n}.html"
cp "$$(dirname "$<")/$${n}/$${n}-vitals.html" "$$(dirname "$@")/$${n}-vitals.html"
xpaths=$$( ruby -e 'require "yaml"; YAML.load_file(ARGV[0], permitted_classes: [Time])[0]["xpaths"].split("\n").each { |x| puts x }' "tests/$${n}.yml" )
while IFS= read -r xpath; do
xmllint --xpath "$${xpath}" "$$(dirname "$@")/$${n}-vitals.html" > /dev/null
done <<< "$${xpaths}"
target/fb/%.fb: tests/%.yml Makefile | target/fb
if [ -e "$@" ]; then $(JUDGES) trim --query='(always)' "$@"; fi
$(JUDGES) import "$<" "$@"
rake: $(SAXON)
bundle exec rake
$(CSS): sass/*.scss Makefile | target/css
sass --no-source-map --style=compressed --no-quiet --stop-on-error sass/main.scss "$@"
$(JS): js/*.js Makefile | target/js
uglifyjs js/*.js > "$@"
clean:
rm -rf target
$(SAXON): | target
p=net/sf/saxon/Saxon-HE/9.8.0-5/Saxon-HE-9.8.0-5.jar
m2=$${HOME}/.m2/repository/$${p}
if [ -e "$${m2}" ]; then
cp "$${m2}" "$(SAXON)"
else
wget --no-verbose -O "$(SAXON)" "https://repo.maven.apache.org/maven2/$${p}"
fi
install: $(SAXON) | target
bundle install
npm --no-color install -g uglify-js
npm --no-color install -g [email protected]
entry: target/docker-image.txt target/fb/simple.fb
img=$$(cat target/docker-image.txt)
test -e target/fb/simple.fb
docker run --rm \
"--user=$$(id -u):$$(id -g)" \
-v "$$(realpath $$(pwd))/target/fb/:/work" \
-e GITHUB_WORKSPACE=/work \
-e INPUT_FACTBASE=simple.fb \
-e INPUT_VERBOSE=true \
-e INPUT_OUTPUT=pages \
-e INPUT_COLUMNS=what,when,who \
-e INPUT_HIDDEN=_id \
"$${img}"
echo "$$?" > target/entry.exit
rmi: target/docker-image.txt
img=$$(cat $<)
docker rmi "$${img}"
rm "$<"
verify:
e2=$$(cat target/entry.exit)
test "$${e2}" = "0"
tree target/fb/
test -e target/fb/pages/simple-vitals.html
test -e target/fb/pages/simple.html
test -e target/fb/pages/simple.xml
test -e target/fb/pages/simple.json
test -e target/fb/pages/simple.yaml
target/docker-image.txt: Makefile Dockerfile entry.sh
mkdir -p "$$(dirname $@)"
docker build -t pages-action "$$(pwd)"
docker build -t pages-action -q "$$(pwd)" > "$@"
$(DIRS):
mkdir -p "$@"