# To preserve CI quota, pipelines won't run on push except for # the upstream repo default branch. To force a run when pushing # to a feature branch use # # git push -o ci.variable=RUN_PIPELINEI=1 ... stages: - containers - sanity_checks .job_rules_merge_request: &job_rules_merge_request if: '$CI_PIPELINE_SOURCE == "merge_request_event"' when: on_success .job_rules_push_upstream_default_branch: &job_rules_push_upstream_default_branch if: '$CI_PIPELINE_SOURCE == "push" && $CI_PROJECT_NAMESPACE == "libvirt" && $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH' when: on_success .job_rules_opt_in: &job_rules_opt_in if: '$RUN_PIPELINE == "1"' when: on_success .job_rules_container_changes: &job_rules_container_changes changes: - .gitlab-ci.yml - containers/$NAME/* .job_rules_test_container_changes: &job_rules_test_container_changes changes: - .gitlab-ci.yml - lcitool/facts/mappings.yml # If pushing to the default branch, then publish the container # for future reuse, otherwise just discard it after testing build .build_container_template: image: docker:latest stage: containers interruptible: false services: - docker:dind before_script: - docker info - docker login registry.gitlab.com -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} script: - docker build --tag ${CI_REGISTRY_IMAGE}/${NAME}:latest containers/${NAME} - if test "${CI_COMMIT_REF_NAME}" = "${CI_DEFAULT_BRANCH}" && ( test "${CI_PIPELINE_SOURCE}" = "push" || test "${RUN_PIPELINE}" = "1" ) then docker push ${CI_REGISTRY_IMAGE}/${NAME}:latest; fi after_script: - docker logout rules: - <<: *job_rules_merge_request <<: *job_rules_container_changes - <<: *job_rules_push_upstream_default_branch <<: *job_rules_container_changes - <<: *job_rules_opt_in <<: *job_rules_container_changes - when: never .test_template: interruptible: true rules: - <<: *job_rules_merge_request - <<: *job_rules_opt_in - when: never .check_container_template: extends: .test_template image: $IMAGE stage: sanity_checks interruptible: true before_script: - ci/gitlab/all_mappings_prep_env/$NAME-prep.sh - mkdir -p /tmp/datadir/projects - cp tests/data/packages/in/packages.yml /tmp/datadir/projects/all_mappings.yml # We need to use Python virtual env because some platforms have an old # version of pip that does not have the '--dry-run' option and because # installing to system locations is broken on Debian - python3 -m venv _venv_ - _venv_/bin/pip3 install --upgrade pip - _venv_/bin/python3 -m pip install -r requirements.txt script: - source <(_venv_/bin/python3 bin/lcitool -d /tmp/datadir variables $NAME all_mappings | grep PKGS) - set +e - for pkg in $PKGS; do echo -n "Checking package '$pkg' ... "; out=$($DRY_RUN_INSTALL_COMMAND $pkg 2>&1); if [ $? -eq 0 ]; then echo "OK"; else echo "FAIL"; echo "LAST ERROR:"; echo "-----------"; echo -e "$out"; exit 1; fi; done - for pkg in $PYPI_PKGS; do echo -n "Checking PyPI package '$pkg' ... "; out=$(_venv_/bin/python3 -m pip install --dry-run $pkg 2>&1); if [ $? -eq 0 ]; then echo "OK"; else echo "FAIL"; echo "LAST ERROR:"; echo "-----------"; echo -e "$out"; exit 1; fi; done - for pkg in $CPAN_PKGS; do echo -n "Checking CPAN package '$pkg' ... "; out=$($CPAN_DRY_RUN_COMMAND $pkg 2>&1); if [ $? -eq 0 ]; then echo "OK"; else echo "FAIL"; echo "LAST ERROR:"; echo "-----------"; echo -e "$out"; exit 1; fi; done variables: CPAN_DRY_RUN_COMMAND: cpanm --scandeps rules: - if: '$LIBVIRT_CI_SKIP_TARGET && $NAME =~ $LIBVIRT_CI_SKIP_TARGET' when: never - <<: *job_rules_merge_request <<: *job_rules_test_container_changes - <<: *job_rules_opt_in <<: *job_rules_test_container_changes - when: never check-dco-container: extends: .build_container_template variables: NAME: check-dco go-fmt-container: extends: .build_container_template variables: NAME: go-fmt cargo-fmt-container: extends: .build_container_template variables: NAME: cargo-fmt clang-format-container: extends: .build_container_template variables: NAME: clang-format black-container: extends: .build_container_template variables: NAME: black flake8-container: extends: .build_container_template variables: NAME: flake8 cirrus-run-container: extends: .build_container_template variables: NAME: cirrus-run docker-dind-container: extends: .build_container_template variables: NAME: docker-dind check-dco: extends: .test_template stage: sanity_checks image: python:3.8-alpine needs: [] before_script: - apk update - apk add git script: - ./containers/check-dco/check-dco.py flake8: extends: .test_template stage: sanity_checks image: python:3.8-alpine needs: [] before_script: - apk update - python3 -m pip install tox script: - tox -e lint unittests: extends: .test_template stage: sanity_checks image: python:3.8-alpine needs: [] before_script: - apk update - apk add gcc linux-headers libffi-dev musl-dev - python3 -m pip install tox script: - tox -e py38 # DNF returns 1 when 'install --assumeno' is used which is undistinguishable # from genuine errors, let's install our DNF helper that checks whether the # failure just means that the installation was aborted or whether the package # actually doesn't exist .dnf_dry_run_command: &dnf_dry_run_command DRY_RUN_INSTALL_COMMAND: ci/gitlab/all_mappings_prep_env/dnf_install_wrapper install --assumeno .apt_dry_run_command: &apt_dry_run_command DRY_RUN_INSTALL_COMMAND: apt --dry-run install .apk_dry_run_command: &apk_dry_run_command DRY_RUN_INSTALL_COMMAND: apk add -s .zypper_dry_run_command: &zypper_dry_run_command DRY_RUN_INSTALL_COMMAND: zypper install -y --dry-run x86_64-check-almalinux-9: extends: .check_container_template variables: <<: *dnf_dry_run_command IMAGE: docker.io/library/almalinux:9 NAME: almalinux-9 x86_64-check-alpine-319: extends: .check_container_template variables: <<: *apk_dry_run_command IMAGE: docker.io/library/alpine:3.19 NAME: alpine-319 x86_64-check-alpine-320: extends: .check_container_template variables: <<: *apk_dry_run_command IMAGE: docker.io/library/alpine:3.20 NAME: alpine-320 x86_64-check-alpine-edge: extends: .check_container_template allow_failure: true variables: <<: *apk_dry_run_command IMAGE: docker.io/library/alpine:edge NAME: alpine-edge x86_64-check-centos-stream-9: extends: .check_container_template allow_failure: true variables: <<: *dnf_dry_run_command IMAGE: quay.io/centos/centos:stream9 NAME: centos-stream-9 x86_64-check-debian-11: extends: .check_container_template variables: <<: *apt_dry_run_command IMAGE: docker.io/library/debian:11-slim NAME: debian-11 x86_64-check-debian-12: extends: .check_container_template variables: <<: *apt_dry_run_command IMAGE: docker.io/library/debian:12-slim NAME: debian-12 x86_64-check-debian-sid: extends: .check_container_template allow_failure: true variables: <<: *apt_dry_run_command IMAGE: docker.io/library/debian:sid-slim NAME: debian-sid x86_64-check-fedora-39: extends: .check_container_template variables: <<: *dnf_dry_run_command IMAGE: registry.fedoraproject.org/fedora:39 NAME: fedora-39 x86_64-check-fedora-40: extends: .check_container_template variables: <<: *dnf_dry_run_command IMAGE: registry.fedoraproject.org/fedora:40 NAME: fedora-40 x86_64-check-fedora-rawhide: extends: .check_container_template allow_failure: true variables: <<: *dnf_dry_run_command IMAGE: registry.fedoraproject.org/fedora:rawhide NAME: fedora-rawhide x86_64-check-opensuse-leap-15: extends: .check_container_template variables: <<: *zypper_dry_run_command IMAGE: registry.opensuse.org/opensuse/leap:15.5 NAME: opensuse-leap-15 x86_64-check-opensuse-tumbleweed: extends: .check_container_template allow_failure: true variables: <<: *zypper_dry_run_command IMAGE: registry.opensuse.org/opensuse/tumbleweed:latest NAME: opensuse-tumbleweed x86_64-check-ubuntu-2204: extends: .check_container_template variables: <<: *apt_dry_run_command IMAGE: docker.io/library/ubuntu:22.04 NAME: ubuntu-2204 x86_64-check-ubuntu-2404: extends: .check_container_template variables: <<: *apt_dry_run_command IMAGE: docker.io/library/ubuntu:24.04 NAME: ubuntu-2404