ci: Fix date parsing with BusyBox on Alpine

This fixes the timestamps in Alpine containers.

Signed-off-by: Valentine Burley <valentine.burley@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35051>
This commit is contained in:
Valentine Burley 2025-05-19 09:11:22 +02:00 committed by Marge Bot
parent cc83b3db5f
commit a6e1926a8e

View file

@ -33,7 +33,13 @@ function _error_msg() (
echo -e "${RED}$*${ENDCOLOR}"
)
export JOB_START_S=$(date -u +"%s" -d "${CI_JOB_STARTED_AT:?}")
# Some date binaries (like the BusyBox one) use -D instead of -d for date parsing.
# This fallback handles both cases: try GNU coreutils-style first, then fallback to BusyBox if it fails.
# The BusyBox fallback needs '|| true' because it returns an error status even when it outputs the time.
export JOB_START_S=$(
date -u +"%s" -d "$CI_JOB_STARTED_AT" 2>/dev/null ||
{ date -u +"%s" -D "%Y-%m-%dT%H:%M:%SZ" "$CI_JOB_STARTED_AT" 2>/dev/null || true; }
)
function get_current_minsec {
DATE_S=$(date -u +"%s")