2021-01-14 16:51:39 +01:00
# https://taskfile.dev
version : '3'
output : prefixed
includes :
siegen : ./tasks/siegen.yml
2021-01-15 17:01:48 +01:00
wuppertal : ./tasks/wuppertal.yml
2021-01-14 16:51:39 +01:00
vars :
DATE : '{{ now | date "2006-01-02"}}'
env :
OPENREFINE :
sh : readlink -e openrefine/refine
OPENREFINE_CLIENT :
sh : readlink -e openrefine/openrefine-client
tasks :
default :
2021-01-19 12:30:46 +01:00
desc : alle Datenquellen (parallel)
2021-01-14 16:51:39 +01:00
preconditions :
- sh : test -n "$(command -v metha-sync)"
msg : "requirement metha missing"
- sh : test -n "$(command -v java)"
msg : "requirement JAVA runtime environment (jre) missing"
- sh : test -x "$OPENREFINE"
msg : "requirement OpenRefine missing"
- sh : test -x "$OPENREFINE_CLIENT"
msg : "requirement openrefine-client missing"
2021-01-19 10:50:55 +01:00
- sh : test -n "$(command -v curl)"
msg : "requirement curl missing"
- sh : test -n "$(command -v xmllint)"
msg : "requirement xmllint missing"
2021-01-14 16:51:39 +01:00
deps :
2021-01-15 17:01:48 +01:00
- task : wuppertal:default
2021-01-14 16:51:39 +01:00
- task : siegen:default
2021-01-19 12:30:46 +01:00
check :
dir : data/{{.PROJECT}}/refine
cmds :
# Logdatei von OpenRefine auf Warnungen und Fehlermeldungen prüfen
- if grep -i 'exception\|error' openrefine.log; then echo 1>&2 "Logdatei $PWD/openrefine.log enthält Warnungen!" && exit 1; fi
# Prüfen, ob Mindestanzahl von 1250 Datensätzen generiert wurde
- if (( {{.MINIMUM}} > $(grep -c recordIdentifier {{.PROJECT}}.txt) )); then echo 1>&2 "Unerwartet geringe Anzahl an Datensätzen in $PWD/{{.PROJECT}}.txt!" && exit 1; fi
preconditions :
- test -n "{{.PROJECT}}"
- test -n "{{.MINIMUM}}"
split :
dir : data/{{.PROJECT}}/split
cmds :
# in Einzeldateien aufteilen
- csplit -q ../refine/{{.PROJECT}}.txt --suppress-matched '/<!-- SPLIT -->/' "{*}"
# ggf. vorhandene XML-Dateien löschen
- rm -f *.xml
# Identifier als Dateinamen
- for f in xx*; do mv "$f" "$(xmllint --xpath "//*[local-name(.) = 'recordIdentifier']/text()" "$f").xml"; done
preconditions :
- test -n "{{.PROJECT}}"
validate :
dir : data/{{.PROJECT}}
cmds :
# Validierung gegen METS Schema
- wget -q -nc https://www.loc.gov/standards/mets/mets.xsd
- xmllint --schema mets.xsd --noout split/*.xml > validate.log 2>&1
preconditions :
- test -n "{{.PROJECT}}"
zip :
dir : data/{{.PROJECT}}
cmds :
# ZIP-Archiv mit Zeitstempel erstellen
- zip -q -FS -j {{.PROJECT}}_{{.DATE}}.zip split/*.xml
preconditions :
- test -n "{{.PROJECT}}"
diff :
dir : data/{{.PROJECT}}
cmds :
# Inhalt der beiden letzten ZIP-Archive vergleichen
- unzip -q -d old $(ls -t *.zip | sed -n 2p)
- unzip -q -d new $(ls -t *.zip | sed -n 1p)
- diff -d old new > diff.log || exit 0
- rm -rf old new
# Diff prüfen, ob es weniger als 500 Zeilen enthält
- if (( 500 < $(wc -l <diff.log) )); then echo 1>&2 "Unerwartet große Änderungen in $PWD/diff.log!" && exit 1; fi
status :
# Task nicht ausführen, wenn weniger als zwei ZIP-Archive vorhanden
- test -z $(ls -t *.zip | sed -n 2p)
preconditions :
- test -n "{{.PROJECT}}"
linkcheck :
dir : data/{{.PROJECT}}
cmds :
# Links extrahieren
- xmllint --xpath '//@*[local-name(.) = "href"]' split/*.xml | cut -d '"' -f2 > links.txt
# http status code aller Links ermitteln
- curl --silent --head --write-out "%{http_code} %{url_effective}\n" $(while read line; do echo "-o /dev/null $line"; done < links.txt) > linkcheck.log
- rm -rf links.txt
# Logdatei auf status code != 2XX prüfen
- if grep '^[^2]' linkcheck.log; then echo 1>&2 "Logdatei $PWD/linkcheck.log enthält problematische status codes!" && exit 1; fi
preconditions :
- test -n "{{.PROJECT}}"
delete :
dir : data/{{.PROJECT}}
cmds :
- rm -rf harvest
- rm -rf refine
- rm -rf split
preconditions :
- test -n "{{.PROJECT}}"