diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2024-09-18 13:54:49 +0100 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2024-09-25 09:42:06 +0200 |
commit | dc05b2628e3913e668590ba66d9c618382d351ae (patch) | |
tree | 3e95f67c9033bc45311055141209b943c6f413d8 /scripts/ci | |
parent | 1cde10ef0196497941cd481760d4ec544c37d66b (diff) |
.gitlab-ci.d: Make separate collapsible log sections for build and test
GitLab lets a CI job create its own collapsible log sections by
emitting special escape codes, as documented here:
https://docs.gitlab.com/ee/ci/yaml/script.html#expand-and-collapse-job-log-sections
Use these to make "configure", "build" and "test" separate
collapsible stages.
As recommended by the GitLab docs, we use some shell which is
sourced in the CI job to define functions to emit the magic
lines that start and end sections, to hide the ugliness of
the printf lines from the log.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20240918125449.3125571-3-peter.maydell@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'scripts/ci')
-rw-r--r-- | scripts/ci/gitlab-ci-section | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/ci/gitlab-ci-section b/scripts/ci/gitlab-ci-section new file mode 100644 index 0000000000..9bbe80420d --- /dev/null +++ b/scripts/ci/gitlab-ci-section @@ -0,0 +1,29 @@ +# Copyright (c) 2024 Linaro Ltd +# SPDX-License-Identifier: GPL-2.0-or-later + +# gitlab-ci-section: This is a shell script fragment which defines +# functions section_start and section_end which will emit marker lines +# that GitLab will interpret as the beginning or end of a "collapsible +# section" in a CI job log. See +# https://docs.gitlab.com/ee/ci/yaml/script.html#expand-and-collapse-job-log-sections +# +# This is intended to be sourced in the before_script section of +# a CI config; the section_start and section_end functions will +# then be available for use in the before_script and script sections. + +# Section names are [-_.A-Za-z0-9] and the section_start pairs with +# a section_end with the same section name. +# The description can be any printable text without newlines; this is +# what will appear in the log. + +# Usage: +# section_start section_name "Description of the section" +section_start () { + printf "section_start:%s:%s\r\e[0K%s\n" "$(date +%s)" "$1" "$2" +} + +# Usage: +# section_end section_name +section_end () { + printf "section_end:%s:%s\r\e[0K\n" "$(date +%s)" "$1" +} |