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