Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Timestamps POC #32399

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading