forked from zerocracy/pages-action
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (98 loc) · 3.25 KB
/
Makefile
File metadata and controls
121 lines (98 loc) · 3.25 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
# SPDX-FileCopyrightText: Copyright (c) 2024-2026 Zerocracy
# SPDX-License-Identifier: MIT
.ONESHELL:
.PHONY: clean all assets install rake stylelint test entries
.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
JS_TEST = target/js/test.js
SAXON = target/saxon.jar
export
all: assets rake entry rmi verify entries
assets: $(XSLS) $(JS) $(CSS)
target/xsl/%.xsl: xsl/%.xsl | target/xsl
cp "$<" "$@"
target/output/%: target/fb/%.fb entry.sh Makefile $(XSLS) $(CSS) $(JS_TEST) $(SAXON) | target/html
export INPUT_VERBOSE=yes
export INPUT_OPTIONS=testing=yes
export GITHUB_WORKSPACE=.
export INPUT_FACTBASE=$<
export INPUT_ADLESS=false
export INPUT_COLUMNS=what,when,who
export INPUT_HIGHLIGHTED=stale,tombstone
export INPUT_HIDDEN=_id,_time,_version
export INPUT_TODAY='2024-07-05T00:00:00Z'
export INPUT_JS_FILE=$(JS_TEST)
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}/$${n}-vitals.html" > /dev/null
done <<< "$${xpaths}"
for f in $${n} $${n}-vitals; do
result=0
tidy -e "$$(dirname "$@")/$${f}.html" || result=$$?
if [ "$${result}" -eq 2 ]; then
echo "$$(dirname "$@")/$${f}.html has errors"
exit 1
fi
done
target/fb/%.fb: tests/%.yml Makefile | target/fb
if [ -e "$@" ]; then $(JUDGES) trim --query='(always)' "$@"; fi
$(JUDGES) import "$<" "$@"
rake: $(SAXON) $(HTMLS)
bundle exec rake
stylelint: sass/*.scss
stylelint sass/*.scss --fix
$(CSS): sass/*.scss stylelint Makefile | target/css
sass --no-source-map --style=compressed --no-quiet --stop-on-error --no-charset sass/main.scss "$@"
$(JS): js/*.js Makefile | target/js
eslint js/*.js
uglifyjs js/*.js > "$@"
$(JS_TEST): $(JS) tests/symbols.js | target/js
cat $^ > "$@"
entries: assets
./makes/entries.sh
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
./makes/install.sh
entry: target/docker-image.txt target/fb/simple.fb
./makes/entry-in-docker.sh "$$(cat target/docker-image.txt)"
echo "$$?" > target/entry.exit
rmi: target/docker-image.txt
img=$$(cat $<)
docker rmi "$${img}"
rm "$<"
verify:
./makes/verify.sh
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 "$@"