Skip to content

Commit

Permalink
[CI] Timestamps POC
Browse files Browse the repository at this point in the history
  • Loading branch information
amenasria committed Dec 19, 2024
1 parent 2b67f9f commit 0b4e3d8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ variables:
# Feature flags
FF_SCRIPT_SECTIONS: 1 # Prevent multiline scripts log collapsing, see https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3392
FF_KUBERNETES_HONOR_ENTRYPOINT: true # Honor the entrypoint in the Docker image when running Kubernetes jobs
FF_TIMESTAMPS: true

#
# Condition mixins for simplification of rules
Expand Down
1 change: 1 addition & 0 deletions .gitlab/source_test/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include:
variables:
TEST_OUTPUT_FILE: test_output.json
script:
- source timestamp.sh
- !reference [.retrieve_linux_go_deps]
- !reference [.retrieve_linux_go_tools_deps]
- inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH
Expand Down
21 changes: 21 additions & 0 deletions timestamp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Original script from: https://gist.github.com/jstine35/e0fc0e06ec06d74bc3ebd67585bf2a1d
# By @jstine35 on GitHub

s_datestamp() {
while read -r line; do
timestamp=$(date -u '+%Y-%m-%d %H:%M:%S')

# by nature BASH might run process subst twice when using >&2 pipes. This is a lazy
# way to avoid dumping two timestamps on the same line:
if [[ "$line" != \[${timestamp%% *}* ]]; then
echo "[$timestamp] $line"
else
echo "$line"
fi
done
}

exec 1> >(s_datestamp)
exec 2> >(s_datestamp)

0 comments on commit 0b4e3d8

Please sign in to comment.