xref: /openbmc/qemu/scripts/ci/gitlab-ci-section (revision 7d87775f)
1# Copyright (c) 2024 Linaro Ltd
2# SPDX-License-Identifier: GPL-2.0-or-later
3
4# gitlab-ci-section: This is a shell script fragment which defines
5# functions section_start and section_end which will emit marker lines
6# that GitLab will interpret as the beginning or end of a "collapsible
7# section" in a CI job log. See
8# https://docs.gitlab.com/ee/ci/yaml/script.html#expand-and-collapse-job-log-sections
9#
10# This is intended to be sourced in the before_script section of
11# a CI config; the section_start and section_end functions will
12# then be available for use in the before_script and script sections.
13
14# Section names are [-_.A-Za-z0-9] and the section_start pairs with
15# a section_end with the same section name.
16# The description can be any printable text without newlines; this is
17# what will appear in the log.
18
19# Usage:
20# section_start section_name "Description of the section"
21section_start () {
22    printf "section_start:%s:%s\r\e[0K%s\n" "$(date +%s)" "$1" "$2"
23}
24
25# Usage:
26# section_end section_name
27section_end () {
28    printf "section_end:%s:%s\r\e[0K\n" "$(date +%s)" "$1"
29}
30