optimized events
Test and publish container images / test (push) Successful in 2m26s
Test and publish container images / publish (push) Failing after 3s

This commit is contained in:
BuTzZ
2026-07-28 14:36:47 +02:00
parent b98ec8bc6f
commit 593dbd5f85
42 changed files with 2405 additions and 283 deletions
+156
View File
@@ -33,6 +33,16 @@ wm_load_env() {
wm_require_safe_absolute_dir "$WATERMAPS_DATA_DIR"
wm_require_safe_absolute_dir "$WATERMAPS_RUNTIME_DIR"
wm_validate_postgres_password
}
wm_validate_postgres_password() {
local password="${WATERMAPS_POSTGRES_PASSWORD:-}"
[[ "${#password}" -ge 24 &&
"$password" != *[[:space:]]* &&
"$password" != *REPLACE* ]] ||
wm_die "WATERMAPS_POSTGRES_PASSWORD muss ein gesetztes Secret mit mindestens 24 Zeichen ohne Leerzeichen sein."
}
wm_require_safe_absolute_dir() {
@@ -162,6 +172,10 @@ wm_route_marker() {
printf '%s/local/.germany-netherlands-fairways.ready\n' "$WATERMAPS_DATA_DIR"
}
wm_marine_marker() {
printf '%s/local/.marine-features.ready\n' "$WATERMAPS_DATA_DIR"
}
wm_acquire_route_lock() {
install -d -m 0755 "$WATERMAPS_RUNTIME_DIR/locks"
exec 9>"$WATERMAPS_RUNTIME_DIR/locks/route-update.lock"
@@ -288,6 +302,107 @@ wm_route_data_files_ready() {
return 0
}
wm_geofabrik_checksum() {
local region="$1"
local checksum_file="$WATERMAPS_DATA_DIR/geofabrik/${region}-latest.osm.pbf.md5"
local checksum
[[ -s "$checksum_file" ]] || return 1
checksum="$(awk 'NR == 1 { print tolower($1) }' "$checksum_file")"
[[ "$checksum" =~ ^[0-9a-f]{32}$ ]] || return 1
printf '%s\n' "$checksum"
}
wm_postgres_query() {
local query="$1"
wm_compose exec --no-TTY postgres \
psql \
--no-psqlrc \
--username seacompass \
--dbname seacompass \
--tuples-only \
--no-align \
--field-separator '|' \
--set ON_ERROR_STOP=1 \
--command "$query"
}
wm_marine_features_ready() {
local marker germany_checksum netherlands_checksum database_counts
local total_count harbour_count lock_count bridge_count
local marker_format marker_source marker_germany marker_netherlands
local marker_total marker_harbours marker_locks marker_bridges
marker="$(wm_marine_marker)"
if [[ ! -s "$marker" ]]; then
wm_log "Bereitschaftsmarker für Marine-Features fehlt: $marker"
return 1
fi
germany_checksum="$(wm_geofabrik_checksum germany 2>/dev/null || true)"
netherlands_checksum="$(wm_geofabrik_checksum netherlands 2>/dev/null || true)"
if [[ -z "$germany_checksum" || -z "$netherlands_checksum" ]]; then
wm_log "Geofabrik-Prüfsummen für den Marine-Feature-Stand fehlen oder sind ungültig."
return 1
fi
marker_format="$(wm_marker_value "$marker" format_version 2>/dev/null || true)"
marker_source="$(wm_marker_value "$marker" source 2>/dev/null || true)"
marker_germany="$(wm_marker_value "$marker" germany_md5 2>/dev/null || true)"
marker_netherlands="$(wm_marker_value "$marker" netherlands_md5 2>/dev/null || true)"
marker_total="$(wm_marker_value "$marker" total_osm_features 2>/dev/null || true)"
marker_harbours="$(wm_marker_value "$marker" harbour_count 2>/dev/null || true)"
marker_locks="$(wm_marker_value "$marker" lock_count 2>/dev/null || true)"
marker_bridges="$(wm_marker_value "$marker" bridge_count 2>/dev/null || true)"
if [[ "$marker_format" != "1" ||
"$marker_source" != "germany+netherlands" ||
"$marker_germany" != "$germany_checksum" ||
"$marker_netherlands" != "$netherlands_checksum" ]]; then
wm_log "Marine-Feature-Marker passt nicht zu den aktuellen Deutschland-/Niederlande-Snapshots."
return 1
fi
if ! database_counts="$(
wm_postgres_query "
SELECT
count(*)::bigint,
count(*) FILTER (WHERE layer = 'harbours')::bigint,
count(*) FILTER (WHERE layer = 'locks')::bigint,
count(*) FILTER (WHERE layer = 'bridges')::bigint
FROM marine_features
WHERE source = 'osm';
"
)"; then
wm_log "Marine-Feature-Tabellen sind in PostGIS nicht abfragbar."
return 1
fi
database_counts="${database_counts//[[:space:]]/}"
IFS='|' read -r total_count harbour_count lock_count bridge_count <<<"$database_counts"
for count in "$total_count" "$harbour_count" "$lock_count" "$bridge_count"; do
if [[ ! "$count" =~ ^[1-9][0-9]*$ ]]; then
wm_log "PostGIS enthält keine vollständigen OSM-Hafen-/Schleusen-/Brückendaten."
return 1
fi
done
if [[ "$marker_total" != "$total_count" ||
"$marker_harbours" != "$harbour_count" ||
"$marker_locks" != "$lock_count" ||
"$marker_bridges" != "$bridge_count" ]]; then
wm_log "Marine-Feature-Marker stimmt nicht mit den OSM-Zeilen in PostGIS überein."
return 1
fi
return 0
}
wm_assert_marine_features() {
wm_marine_features_ready ||
wm_die "Marine-Features sind nicht vollständig in PostGIS bereit."
}
wm_wait_for_health() {
local service="$1"
local timeout_seconds="${2:-180}"
@@ -479,3 +594,44 @@ wm_smoke_test_route() {
}
'
}
wm_smoke_test_features() {
wm_compose exec --no-TTY watermaps node --input-type=module --eval '
const params = new URLSearchParams({
bbox: "7.118483884871649,53.302596677614666,7.543960668999219,53.50669706666667",
layers: "harbours,locks,bridges"
});
const response = await fetch(`http://127.0.0.1:5174/api/features?${params}`);
if (!response.ok) {
console.error("Feature-Smoke-Test", response.status, await response.text());
process.exit(1);
}
const collection = await response.json();
const features = Array.isArray(collection.features) ? collection.features : [];
const layers = new Set(features.map((feature) => feature?.properties?.layer));
const contactFeature = features.find((feature) =>
["harbours", "locks"].includes(feature?.properties?.layer)
&& typeof feature?.properties?.phone === "string"
&& feature.properties.phone.trim().length > 0
);
if (
collection?.metadata?.source !== "postgis"
|| !layers.has("harbours")
|| !layers.has("locks")
|| !layers.has("bridges")
|| !contactFeature
) {
console.error(
"PostGIS-Feature-Prüfung für die EmdenAurich-Teststrecke fehlgeschlagen.",
JSON.stringify({
source: collection?.metadata?.source,
featureCount: features.length,
layers: [...layers],
hasCallableHarbourOrLock: Boolean(contactFeature)
})
);
process.exit(1);
}
'
}