2024-07-01 14:17:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-07-04 14:16:28 +00:00
|
|
|
function log() {
|
|
|
|
local timestamp=$(date +"%Y-%m-%d %H:%M:%S")
|
|
|
|
echo "$1 at $timestamp: $2"
|
|
|
|
}
|
|
|
|
|
2024-07-01 14:17:54 +00:00
|
|
|
function abort() {
|
2024-07-04 14:16:28 +00:00
|
|
|
log "ERROR" "test case $1 has failed"
|
2024-07-01 14:17:54 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2024-07-04 14:16:28 +00:00
|
|
|
function print-box() {
|
|
|
|
printf "\\n"
|
|
|
|
echo ".----------------------------------------------------------------."
|
|
|
|
printf "| %-62s |\\n" "$1"
|
|
|
|
echo "'----------------------------------------------------------------'"
|
|
|
|
}
|
2024-07-01 14:17:54 +00:00
|
|
|
|
2024-07-04 14:16:28 +00:00
|
|
|
function enter-section() {
|
|
|
|
print-box "$1"
|
2024-07-02 09:11:33 +00:00
|
|
|
|
2024-07-04 14:16:28 +00:00
|
|
|
log "INFO" "running task in section $1: $2"
|
|
|
|
log "INFO" "section output following..."
|
|
|
|
printf "\\n"
|
2024-07-02 09:11:33 +00:00
|
|
|
|
2024-07-04 14:16:28 +00:00
|
|
|
eval "$2"
|
2024-08-27 17:50:09 +00:00
|
|
|
exit_status=$?
|
2024-08-27 18:54:33 +00:00
|
|
|
|
|
|
|
if [ "$3" == "should fail" ]; then
|
|
|
|
log "INFO" "expected to fail..."
|
|
|
|
if [ $exit_status -eq 0 ]; then
|
|
|
|
abort "command: $2 failed in section: $1 with: $exit_status"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
log "INFO" "expected to pass..."
|
|
|
|
if [ ! $exit_status -eq 0 ]; then
|
|
|
|
abort "command: $2 failed in section: $1 with: $exit_status"
|
|
|
|
fi
|
2024-07-04 14:16:28 +00:00
|
|
|
fi
|
2024-07-02 09:11:33 +00:00
|
|
|
|
2024-07-04 14:16:28 +00:00
|
|
|
printf "\\n"
|
|
|
|
log "INFO" "section $1 completed successfully"
|
|
|
|
}
|
2024-07-02 09:11:33 +00:00
|
|
|
|
2024-08-27 17:50:31 +00:00
|
|
|
enter-section "Typstyle checking" "./run-fmt.sh --check src/lib.typ" 0
|
2024-09-27 15:47:08 +00:00
|
|
|
enter-section "Compiling template..." "typst compile template/main.typ --root . --font-path fonts example.pdf"
|
2024-07-02 09:11:33 +00:00
|
|
|
|
2024-07-04 14:16:28 +00:00
|
|
|
log "INFO" "CI completed successfully"
|