[libvirt PATCH 0/2] gitlab: Improve make handling

Andrea Bolognani (2): gitlab: Add and use 'environment' template gitlab: Define $MAKEFLAGS in environment .gitlab-ci.yml | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) -- 2.25.1

This template provides a standardized place where environment variables, which might not be static but depend on the output of some shell command, can be defined for later use. It's not very interesting right now, but we'll put it to good use in a second. This pattern is already used in libosinfo's GitLab CI integration. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- .gitlab-ci.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e3675ace0..eeeff7ed48 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,4 @@ variables: - MAKE: make GIT_DEPTH: 100 stages: @@ -7,6 +6,8 @@ stages: - native_build - cross_build +.environment: &environment | + export MAKE="make" # Common templates @@ -18,6 +19,7 @@ stages: - ccache/ key: "$CI_JOB_NAME" before_script: + - *environment - mkdir -p ccache - export CC="ccache gcc" - export CCACHE_BASEDIR=${PWD} @@ -45,6 +47,7 @@ stages: - ccache/ key: "$CI_JOB_NAME" before_script: + - *environment - mkdir -p ccache - export CC="ccache ${ABI}-gcc" - export CCACHE_BASEDIR=${PWD} @@ -163,6 +166,8 @@ mingw64-fedora-30: # https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=webs... website: stage: prebuild + before_script: + - *environment script: - mkdir build - cd build @@ -183,6 +188,8 @@ website: codestyle: stage: prebuild + before_script: + - *environment script: - mkdir build - cd build @@ -198,6 +205,8 @@ potfile: stage: prebuild only: - master + before_script: + - *environment script: - mkdir build - cd build @@ -222,6 +231,8 @@ potfile: dco: stage: prebuild image: quay.io/libvirt/buildenv-libvirt-fedora-31:latest + before_script: + - *environment script: - ./scripts/require-dco.py only: -- 2.25.1

On Fri, Mar 27, 2020 at 06:15:58PM +0100, Andrea Bolognani wrote:
This template provides a standardized place where environment variables, which might not be static but depend on the output of some shell command, can be defined for later use. It's not very interesting right now, but we'll put it to good use in a second.
This pattern is already used in libosinfo's GitLab CI integration.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- .gitlab-ci.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e3675ace0..eeeff7ed48 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,4 @@ variables: - MAKE: make GIT_DEPTH: 100
stages: @@ -7,6 +6,8 @@ stages: - native_build - cross_build
+.environment: &environment |
Use of the name ".environment" is undesirable as there's a standard key called "environment" already that has completely different semantics. ".script_variables" is a better choice to align with the normal naming. That said, I don't think we should be moving the MAKE variable definition. IMHO we should stick with the standard "variables" block, except in case where we need to dynamically set a value based on some live shell expansion, as is done in the variables in the before_script
+ export MAKE="make"
# Common templates
@@ -18,6 +19,7 @@ stages: - ccache/ key: "$CI_JOB_NAME" before_script: + - *environment - mkdir -p ccache - export CC="ccache gcc" - export CCACHE_BASEDIR=${PWD} @@ -45,6 +47,7 @@ stages: - ccache/ key: "$CI_JOB_NAME" before_script: + - *environment - mkdir -p ccache - export CC="ccache ${ABI}-gcc" - export CCACHE_BASEDIR=${PWD} @@ -163,6 +166,8 @@ mingw64-fedora-30: # https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=webs... website: stage: prebuild + before_script: + - *environment script: - mkdir build - cd build @@ -183,6 +188,8 @@ website:
codestyle: stage: prebuild + before_script: + - *environment script: - mkdir build - cd build @@ -198,6 +205,8 @@ potfile: stage: prebuild only: - master + before_script: + - *environment script: - mkdir build - cd build @@ -222,6 +231,8 @@ potfile: dco: stage: prebuild image: quay.io/libvirt/buildenv-libvirt-fedora-31:latest + before_script: + - *environment script: - ./scripts/require-dco.py only: -- 2.25.1
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

This way we don't need to call getconf over and over, and the actual build steps don't end up drowned in the noise. Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- .gitlab-ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eeeff7ed48..a5c5dfc52f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ stages: .environment: &environment | export MAKE="make" + export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)" # Common templates @@ -28,7 +29,7 @@ stages: - mkdir build - cd build - ../autogen.sh || (cat config.log && exit 1) - - $MAKE -j $(getconf _NPROCESSORS_ONLN) distcheck + - $MAKE distcheck # Extra native build jobs that are only run post-merge, or # when code is pushed to a branch with "ci-full-" name prefix @@ -56,7 +57,7 @@ stages: - mkdir build - cd build - ../autogen.sh $CONFIGURE_OPTS || (cat config.log && exit 1) - - $MAKE -j $(getconf _NPROCESSORS_ONLN) + - $MAKE # Extra cross build jobs that are only run post-merge, or # when code is pushed to a branch with "ci-full-" name prefix @@ -172,8 +173,8 @@ website: - mkdir build - cd build - ../autogen.sh --prefix=$(pwd)/../vroot || (cat config.log && exit 1) - - $MAKE -j $(getconf _NPROCESSORS_ONLN) -C docs - - $MAKE -j $(getconf _NPROCESSORS_ONLN) -C docs install + - $MAKE -C docs + - $MAKE -C docs install - cd .. - mv vroot/share/doc/libvirt/html/ website image: quay.io/libvirt/buildenv-libvirt-fedora-31:latest @@ -194,7 +195,7 @@ codestyle: - mkdir build - cd build - ../autogen.sh || (cat config.log && exit 1) - - $MAKE -j $(getconf _NPROCESSORS_ONLN) syntax-check + - $MAKE syntax-check image: quay.io/libvirt/buildenv-libvirt-fedora-31:latest @@ -211,8 +212,8 @@ potfile: - mkdir build - cd build - ../autogen.sh || (cat config.log && exit 1) - - $MAKE -j $(getconf _NPROCESSORS_ONLN) -C src generated-sources - - $MAKE -j $(getconf _NPROCESSORS_ONLN) -C po libvirt.pot + - $MAKE -C src generated-sources + - $MAKE -C po libvirt.pot - cd .. - mv build/po/libvirt.pot libvirt.pot image: quay.io/libvirt/buildenv-libvirt-fedora-31:latest -- 2.25.1

On Fri, Mar 27, 2020 at 06:15:59PM +0100, Andrea Bolognani wrote:
This way we don't need to call getconf over and over, and the actual build steps don't end up drowned in the noise.
Signed-off-by: Andrea Bolognani <abologna@redhat.com> --- .gitlab-ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eeeff7ed48..a5c5dfc52f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ stages:
.environment: &environment | export MAKE="make" + export MAKEFLAGS="-j$(getconf _NPROCESSORS_ONLN)"
Assuming .environment is renamed to .script_variables or similar Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Andrea Bolognani
-
Daniel P. Berrangé