libvirt/ci/gitlab.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

83 lines
2.4 KiB
YAML

# THIS FILE WAS AUTO-GENERATED
#
# $ lcitool manifest ci/manifest.yml
#
# https://gitlab.com/libvirt/libvirt-ci
# Variables that can be set to control the behaviour of
# pipelines that are run
#
# - RUN_PIPELINE - force creation of a CI pipeline when
# pushing to a branch in a forked repository. Official
# CI pipelines are triggered when merge requests are
# created/updated. Setting this variable to a non-empty
# value allows CI testing prior to opening a merge request.
#
# - RUN_CONTAINER_BUILDS - CI pipelines in upstream only
# publish containers if CI file changes are detected.
# Setting this variable to a non-empty value will force
# re-publishing, even when no file changes are detected.
# Typically to use from a scheduled job once a month.
#
# - RUN_UPSTREAM_NAMESPACE - the upstream namespace is
# configured to default to 'libvirt'. When testing
# changes to CI it might be useful to use a different
# upstream. Setting this variable will override the
# namespace considered to be upstream.
#
# These can be set as git push options
#
# $ git push -o ci.variable=RUN_PIPELINE=1
#
# Aliases can be set for common usage
#
# $ git config --local alias.push-ci "push -o ci.variable=RUN_PIPELINE=1"
#
# Allowing the less verbose invocation
#
# $ git push-ci
#
# Pipeline variables can also be set in the repository
# pipeline config globally, or set against scheduled pipelines
variables:
RUN_UPSTREAM_NAMESPACE: libvirt
workflow:
rules:
# upstream+forks: Avoid duplicate pipelines on pushes, if a MR is open
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_OPEN_MERGE_REQUESTS'
when: never
# upstream+forks: Avoid pipelines on tag pushes
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_TAG'
when: never
# upstream+forks: Allow pipelines in scenarios we've figured out job rules
- if: '$CI_PIPELINE_SOURCE =~ /^(push|merge_request_event|api|web|schedule)$/'
when: always
# upstream+forks: Avoid all other pipelines
- when: never
debug:
image: docker.io/library/alpine:3
stage: sanity_checks
needs: []
script:
- printenv | sort
rules:
- if: '$RUN_DEBUG'
when: always
include:
- local: '/ci/gitlab/container-templates.yml'
- local: '/ci/gitlab/build-templates.yml'
- local: '/ci/gitlab/sanity-checks.yml'
- local: '/ci/gitlab/containers.yml'
- local: '/ci/gitlab/builds.yml'