libvirt/.gitlab-ci.yml
Daniel P. Berrangé 491d918502 ci: refresh with latest lcitool manifest
This refresh switches the CI for contributors to be triggered by merge
requests. Pushing to a branch in a fork will no longer run CI pipelines,
in order to avoid consuming CI minutes. To regain the original behaviour
contributors can opt-in to a pipeline on push

   git push <remote> -o ci.variable=RUN_PIPELINE=1

This variable can also be set globally on the repository, through the
web UI options Settings -> CI/CD -> Variables, though this is not
recommended. Upstream repo pushes to branches will run CI.

The use of containers has changed in this update, with only the upstream
repo creating containers, in order to avoid consuming contributors'
limited storage quotas. A fork with existing container images may delete
them. Containers will be rebuilt upstream when pushing commits with CI
changes to the default branch. Any other scenario with CI changes will
simply install build pre-requisite packages in a throaway environment,
using the ci/buildenv/ scripts. These scripts may also be used on a
contributor's local machines.

With pipelines triggered by merge requests, it is also now possible to
workaround the inability of contributors to run pipelines if they have
run out of CI quota. A project member can trigger a pipeline from the
merge request, which will run in context of upstream, however, note
this should only be done after reviewing the code for any malicious
CI changes.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2022-10-06 05:15:54 -04:00

189 lines
5.6 KiB
YAML

variables:
GIT_DEPTH: 100
stages:
- containers
- builds
- integration_tests
- sanity_checks
.script_variables: &script_variables |
export CCACHE_BASEDIR="$(pwd)"
export CCACHE_DIR="$CCACHE_BASEDIR/ccache"
export CCACHE_MAXSIZE="500M"
export PATH="$CCACHE_WRAPPERSDIR:$PATH"
export VIR_TEST_VERBOSE="1"
export VIR_TEST_DEBUG="1"
include:
- '/ci/gitlab.yml'
- '/ci/integration.yml'
.native_build_job:
cache:
paths:
- ccache/
key: "$CI_JOB_NAME"
script:
- *script_variables
- meson setup build --werror $MESON_ARGS || (cat build/meson-logs/meson-log.txt && exit 1)
- meson dist -C build --no-tests
- if test -x /usr/bin/rpmbuild && test "$RPM" != "skip";
then
rpmbuild --clean --nodeps --define "_without_mingw 1" --define "_topdir $PWD/rpmbuild/" -ta build/meson-dist/libvirt-*.tar.xz;
mv rpmbuild/RPMS/x86_64/ libvirt-rpms/;
else
meson compile -C build;
meson test -C build --no-suite syntax-check --print-errorlogs;
fi
.native_build_job_prebuilt_env:
extends:
- .native_build_job
- .gitlab_native_build_job_prebuilt_env
.native_build_job_local_env:
extends:
- .native_build_job
- .gitlab_native_build_job_local_env
.cross_build_job:
cache:
paths:
- ccache/
key: "$CI_JOB_NAME"
script:
- *script_variables
- meson setup build --werror $MESON_OPTS || (cat build/meson-logs/meson-log.txt && exit 1)
- meson compile -C build
- if test "$CROSS" = "i686" ; then meson test -C build --no-suite syntax-check --print-errorlogs ; fi
.cross_build_job_prebuilt_env:
extends:
- .cross_build_job
- .gitlab_cross_build_job_prebuilt_env
.cross_build_job_local_env:
extends:
- .cross_build_job
- .gitlab_cross_build_job_local_env
# This artifact published by this job is downloaded by libvirt.org to
# be deployed to the web root:
# https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=website
.website_job:
script:
- *script_variables
- meson setup build --werror -Dsystem=true || (cat build/meson-logs/meson-log.txt && exit 1)
- DESTDIR=$(pwd)/install ninja -C build install-web
- mv install/usr/share/doc/libvirt/html/ website
artifacts:
expose_as: 'Website'
name: 'website'
when: on_success
expire_in: 30 days
paths:
- website
website_prebuilt_env:
extends:
- .website_job
- .gitlab_native_build_job_prebuilt_env
needs:
- job: x86_64-almalinux-8-container
optional: true
variables:
NAME: almalinux-8
website_local_env:
extends:
- .website_job
- .gitlab_native_build_job_local_env
variables:
IMAGE: docker.io/library/almalinux:8
NAME: almalinux-8
.codestyle_job:
stage: sanity_checks
script:
- *script_variables
- meson setup build --werror || (cat build/meson-logs/meson-log.txt && exit 1)
- ninja -C build libvirt-pot-dep
- meson test -C build --suite syntax-check --no-rebuild --print-errorlogs
codestyle_prebuilt_env:
extends:
- .codestyle_job
- .gitlab_native_build_job_prebuilt_env
needs:
- job: x86_64-opensuse-leap-153-container
optional: true
variables:
NAME: opensuse-leap-153
codestyle_local_env:
extends:
- .codestyle_job
- .gitlab_native_build_job_local_env
variables:
IMAGE: registry.opensuse.org/opensuse/leap:15.3
NAME: opensuse-leap-153
# This artifact published by this job is downloaded to push to Weblate
# for translation usage:
# https://gitlab.com/libvirt/libvirt/-/jobs/artifacts/master/download?job=potfile
potfile:
image: $CI_REGISTRY/$RUN_UPSTREAM_NAMESPACE/libvirt/ci-$NAME:latest
stage: builds
before_script:
- cat /packages.txt
needs:
- job: x86_64-almalinux-8-container
optional: true
rules:
- if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: on_success
- when: never
before_script:
- *script_variables
script:
- meson setup build --werror || (cat build/meson-logs/meson-log.txt && exit 1)
- ninja -C build libvirt-pot-dep
- ninja -C build libvirt-pot
- cp po/libvirt.pot libvirt.pot
artifacts:
expose_as: 'Potfile'
name: 'potfile'
when: on_success
expire_in: 30 days
paths:
- libvirt.pot
# Coverity job that is run only by schedules
coverity:
image: $CI_REGISTRY/$RUN_UPSTREAM_NAMESPACE/libvirt/ci-$NAME:latest
stage: builds
needs:
- job: x86_64-almalinux-8-container
optional: true
before_script:
- cat /packages.txt
script:
- curl https://scan.coverity.com/download/linux64 --form project=$COVERITY_SCAN_PROJECT_NAME --form token=$COVERITY_SCAN_TOKEN -o /tmp/cov-analysis-linux64.tgz
- tar xfz /tmp/cov-analysis-linux64.tgz
- meson setup build --werror || (cat build/meson-logs/meson-log.txt && exit 1)
- cov-analysis-linux64-*/bin/cov-build --dir cov-int meson compile -C build
- tar cfz cov-int.tar.gz cov-int
- curl https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME --form token=$COVERITY_SCAN_TOKEN --form email=$GITLAB_USER_EMAIL --form file=@cov-int.tar.gz --form version="$(git describe --tags)" --form description="$(git describe --tags) / $CI_COMMIT_TITLE / $CI_COMMIT_REF_NAME:$CI_PIPELINE_ID"
variables:
NAME: almalinux-8
rules:
- if: '$COVERITY_SCAN_PROJECT_NAME == null || $COVERITY_SCAN_TOKEN == null'
when: never
- if: '$CI_PROJECT_NAMESPACE == $RUN_UPSTREAM_NAMESPACE && $CI_PIPELINE_SOURCE == "schedule" && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH'
when: on_success
- when: never