reduce multiline commands in YAML
the current (e.g. c26931f9) pipelines, contain a number of multiline YAML nodes. Eg.
- https://salsa.debian.org/salsa-ci-team/pipeline/-/blob/c26931f9ae781e947db4522b69fe39f072a764e6/salsa-ci.yml#L93
- https://salsa.debian.org/salsa-ci-team/pipeline/-/blob/c26931f9ae781e947db4522b69fe39f072a764e6/salsa-ci.yml#L132
- https://salsa.debian.org/salsa-ci-team/pipeline/-/blob/c26931f9ae781e947db4522b69fe39f072a764e6/salsa-ci.yml#L155
multiline entries are cool, as they:
- allow to write nice multiline code (rather than trying to cram everything into a single line) when doing structured programming (e.g. an
if/then/else/fi-clause just becomes much more readable when spread over multiple lines) - allow to bypass some of the gitlab-yaml escaping quirks.
the problem with multiline entries is, that the gitlab-ci collapses them into a single line: (e.g. https://salsa.debian.org/salsa-ci-team/pipeline/-/jobs/2183616#L393)
if something goes wrong within these multiple lines it is often really hard to find out where the actual problem happened.
as such i propose to replace multiline commands with single line commands whenever feasible.
example
original code
.build-before-script: &build-before-script |
# Reported in https://salsa.debian.org/salsa-ci-team/pipeline/issues/104,
# GitLab can only expand variables once. So at the beginning CCACHE_WORK_DIR
# was assigned to `${WORKING_DIR}/.ccache`, and it will be expanded as
# `$CI_PROJECT_DIR/debian/output/.ccache`, so it creates a folder named
# "\$CI_PROJECT_DIR", which is then saved as build cache. To allow smooth
# transition, that wrongly named folder has to be removed:
rm -rf '$CI_PROJECT_DIR'
# salsa-ci-team/pipeline#107
rm -rf ${CI_PROJECT_DIR}/debian/output/.ccache
mkdir -p ${WORKING_DIR} ${CCACHE_WORK_DIR}
# https://salsa.debian.org/salsa-ci-team/pipeline/-/merge_requests/230
rm -rf ${CCACHE_TMP_DIR}
mv ${CCACHE_WORK_DIR} ${CCACHE_TMP_DIR}
add_extra_repository.sh -v -e "${SALSA_CI_EXTRA_REPOSITORY}" -k "${SALSA_CI_EXTRA_REPOSITORY_KEY}"
# are we cross-compiling? if not, unset HOST_ARCH
test "${BUILD_ARCH}" != "${HOST_ARCH}" || HOST_ARCH=""
proposed change
.build-before-script: &build-before-script
# Reported in https://salsa.debian.org/salsa-ci-team/pipeline/issues/104,
# GitLab can only expand variables once. So at the beginning CCACHE_WORK_DIR
# was assigned to `${WORKING_DIR}/.ccache`, and it will be expanded as
# `$CI_PROJECT_DIR/debian/output/.ccache`, so it creates a folder named
# "\$CI_PROJECT_DIR", which is then saved as build cache. To allow smooth
# transition, that wrongly named folder has to be removed:
- rm -rf '$CI_PROJECT_DIR'
# salsa-ci-team/pipeline#107
- rm -rf ${CI_PROJECT_DIR}/debian/output/.ccache
- mkdir -p ${WORKING_DIR} ${CCACHE_WORK_DIR}
# https://salsa.debian.org/salsa-ci-team/pipeline/-/merge_requests/230
- rm -rf ${CCACHE_TMP_DIR}
- mv ${CCACHE_WORK_DIR} ${CCACHE_TMP_DIR}
- add_extra_repository.sh -v -e "${SALSA_CI_EXTRA_REPOSITORY}" -k "${SALSA_CI_EXTRA_REPOSITORY_KEY}"
# are we cross-compiling? if not, unset HOST_ARCH
- test "${BUILD_ARCH}" != "${HOST_ARCH}" || HOST_ARCH=""