# 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 allows CI
#    testing prior to opening a merge request. A value
#    of "0" will create the pipeline but leave all jobs
#    to be manually started, while "1" will immediately
#    run all default jobs.
#
#  - RUN_PIPELINE_UPSTREAM_ENV - same semantics as RUN_PIPELINE,
#    but uses the CI environment (containers) from the upstream project
#    rather than creating and updating a throwaway environment
#    Should not be used if the pushed branch includes CI container
#    changes.
#
#  - 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=0"
#  $ git config --local alias.push-ci-now "push -o ci.variable=RUN_PIPELINE=1"
#
# Allowing the less verbose invocation
#
#  $ git push-ci     (create pipeline but don't start jobs)
#  $ git push-ci-now (create pipeline and start default jobs)
#
# Pipeline variables can also be set in the repository
# pipeline config globally, or set against scheduled pipelines


variables:
  RUN_UPSTREAM_NAMESPACE: libvirt
  FF_SCRIPT_SECTIONS: 1


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
  interruptible: true
  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'
