Allow configuring pre-collapsed sections in job logs at the end of the section
This issue is a followup to #198413 (closed) and !42231 (merged) and tries to address the following two comments:
Problem to solve
Currently to have a pre-collapsed section in a job log, one has to print out a special magic code at the beginning of the section. This is problematic because sometimes only at the end of the section you know if it should be collapsed (e.g., collapsed if there was no error, otherwise shown; or, collapsed initially, but shown if there was an error).
Proposal
It should be possible to issue [collapsed=true]
and section header in the section_end
print out. The behavior would be changed so that any configuration in section_start
sets the default/initial collapsed state, an then section_end
can override it/change it (or keep it).
The following (this is currently the way to do it) would start collapsed during CI job run and stay collapsed afterwards:
job1:
script:
- echo -e "section_start:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section"
- echo 'this line should be hidden automatically after loading the job log'
- echo -e "section_end:`date +%s`:my_first_section\r\e[0K"
The following would start collapsed during CI job run and then show in full afterwards:
job1:
script:
- echo -e "section_start:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section"
- echo 'this line should be hidden automatically after loading the job log'
- echo -e "section_end:`date +%s`:my_first_section[collapsed=false]\r\e[0K"
The following would start be shown in full during CI job run and then be collapsed afterwards:
job1:
script:
- echo -e "section_start:`date +%s`:my_first_section\r\e[0K"
- echo 'this line should be hidden automatically after loading the job log'
- echo -e "section_end:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section"
Same for:
job1:
script:
- echo -e "section_start:`date +%s`:my_first_section[collapsed=false]\r\e[0K"
- echo 'this line should be hidden automatically after loading the job log'
- echo -e "section_end:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section"
Or start with one header and collapsed, and change just header afterwards:
job1:
script:
- echo -e "section_start:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section"
- echo 'this line should be hidden automatically after loading the job log'
- echo -e "section_end:`date +%s`:my_first_section[collapsed=true]\r\e[0KHeader of the 1st collapsible section (FAILED)"