diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 07a3745d7..4ae1b9f49 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,68 +1,30 @@ # SPDX-License-Identifier: CC0-1.0 # SPDX-FileCopyrightText: 2018-2023 Collabora, Ltd. and the Monado contributors -###################################### -# GENERATED - DO NOT EDIT # -# see .gitlab-ci/ci.template instead # -###################################### +############################################### +# GENERATED - DO NOT EDIT +# see .gitlab-ci/ci.template, etc instead +############################################### # Detached MR pipelines, needed due to https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/438 -workflow: - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - - if: $CI_PIPELINE_SOURCE == 'push' +# workflow: +# rules: +# - if: $CI_PIPELINE_SOURCE == 'merge_request_event' +# - if: $CI_PIPELINE_SOURCE == 'push' variables: - FDO_UPSTREAM_REPO: monado/monado - -.templates_sha: &templates_sha 7811ba9814a3bad379377241c6c6b62d78b20eac + FDO_UPSTREAM_REPO: "monado/monado" include: - # Debian - project: "freedesktop/ci-templates" - ref: *templates_sha - file: "/templates/debian.yml" - # Ubuntu - - project: "freedesktop/ci-templates" - ref: *templates_sha - file: "/templates/ubuntu.yml" - # Arch - - project: "freedesktop/ci-templates" - ref: *templates_sha - file: "/templates/arch.yml" - - -# Variables for build and usage of Debian bullseye image -.monado.variables.debian:bullseye: - variables: - FDO_DISTRIBUTION_VERSION: "bullseye" - FDO_DISTRIBUTION_TAG: "2023-04-07" - -# Variables for build and usage of Debian bullseye-ndk image -.monado.variables.debian:bullseye-ndk: - variables: - FDO_DISTRIBUTION_VERSION: "bullseye" - FDO_DISTRIBUTION_TAG: "2023-04-10.1" - FDO_REPO_SUFFIX: ndk - -# Variables for build and usage of Ubuntu focal image -.monado.variables.ubuntu:focal: - variables: - FDO_DISTRIBUTION_VERSION: "20.04" - FDO_DISTRIBUTION_TAG: "2022-09-20.0" - -# Variables for build and usage of Ubuntu jammy image -.monado.variables.ubuntu:jammy: - variables: - FDO_DISTRIBUTION_VERSION: "22.04" - FDO_DISTRIBUTION_TAG: "2022-09-20.0" - -# Variables for build and usage of Arch rolling image -.monado.variables.arch:rolling: - variables: - FDO_DISTRIBUTION_VERSION: "rolling" - FDO_DISTRIBUTION_TAG: "2023-03-13.2" + ref: 7811ba9814a3bad379377241c6c6b62d78b20eac + file: + - "/templates/debian.yml" + - "/templates/ubuntu.yml" + - "/templates/arch.yml" + # - local: .gitlab-ci/containers/ci-container-prep.yml + - local: .gitlab-ci/ci-rules.yml stages: - container_prep @@ -72,133 +34,6 @@ stages: - pages - deploy -### -# Container prep jobs -# Make Debian bullseye image -debian:bullseye:container_prep: - stage: container_prep - extends: - - .monado.variables.debian:bullseye - - .fdo.container-build@debian # from ci-templates - - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - changes: - - .gitlab-ci/**/* - - if: $CI_PIPELINE_SOURCE == 'push' - changes: - - .gitlab-ci/**/* - variables: - FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates clang-format cmake codespell curl debhelper devscripts doxygen dput-ng gettext-base git glslang-tools graphviz libavcodec-dev libbluetooth-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 python3-click python3-pip unzip wget' - FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/i386_and_proclamation_container_prep.sh' - -# Make Debian bullseye-ndk image -debian:bullseye-ndk:container_prep: - stage: container_prep - extends: - - .monado.variables.debian:bullseye-ndk - - .fdo.container-build@debian # from ci-templates - - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - changes: - - .gitlab-ci/**/* - - if: $CI_PIPELINE_SOURCE == 'push' - changes: - - .gitlab-ci/**/* - variables: - FDO_DISTRIBUTION_PACKAGES: 'ca-certificates cmake default-jdk-headless git glslang-tools libeigen3-dev meson ninja-build pkg-config python3 unzip wget' - FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/android_container_prep.sh' - -# Make Ubuntu focal image -ubuntu:focal:container_prep: - stage: container_prep - extends: - - .monado.variables.ubuntu:focal - - .fdo.container-build@ubuntu # from ci-templates - - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - changes: - - .gitlab-ci/**/* - - if: $CI_PIPELINE_SOURCE == 'push' - changes: - - .gitlab-ci/**/* - variables: - FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates cmake curl debhelper devscripts dput-ng gettext-base git glslang-tools libavcodec-dev libbluetooth-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 unzip wget' - -# Make Ubuntu jammy image -ubuntu:jammy:container_prep: - stage: container_prep - extends: - - .monado.variables.ubuntu:jammy - - .fdo.container-build@ubuntu # from ci-templates - - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - changes: - - .gitlab-ci/**/* - - if: $CI_PIPELINE_SOURCE == 'push' - changes: - - .gitlab-ci/**/* - variables: - FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates cmake curl debhelper devscripts dput-ng gettext-base git glslang-tools libavcodec-dev libbluetooth-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 reprepro unzip wget' - -# Make Arch rolling image -arch:rolling:container_prep: - stage: container_prep - extends: - - .monado.variables.arch:rolling - - .fdo.container-build@arch # from ci-templates - - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - changes: - - .gitlab-ci/**/* - - if: $CI_PIPELINE_SOURCE == 'push' - changes: - - .gitlab-ci/**/* - variables: - FDO_DISTRIBUTION_PACKAGES: 'base-devel bc bluez-libs boost check clang cmake diffutils doxygen eigen ffmpeg fmt gcc git glew glfw-x11 glslang glu graphviz gtest gtk3 hidapi libbsd libusb libxrandr mesa meson ninja opencv patch pipewire-jack pkgconfig python-attrs python-setuptools python3 qt5-base v4l-utils vulkan-headers vulkan-icd-loader wayland wget wireplumber' - FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/install-arch-additional-deps.sh' - -### -# Container usage base jobs - -# Base for using Debian bullseye image -.monado.image.debian:bullseye: - extends: - - .monado.variables.debian:bullseye - - .fdo.distribution-image@debian # from ci-templates - - -# Base for using Debian bullseye-ndk image -.monado.image.debian:bullseye-ndk: - extends: - - .monado.variables.debian:bullseye-ndk - - .fdo.suffixed-image@debian # from ci-templates - - -# Base for using Ubuntu focal image -.monado.image.ubuntu:focal: - extends: - - .monado.variables.ubuntu:focal - - .fdo.distribution-image@ubuntu # from ci-templates - - -# Base for using Ubuntu jammy image -.monado.image.ubuntu:jammy: - extends: - - .monado.variables.ubuntu:jammy - - .fdo.distribution-image@ubuntu # from ci-templates - - -# Base for using Arch rolling image -.monado.image.arch:rolling: - extends: - - .monado.variables.arch:rolling - - .fdo.distribution-image@arch # from ci-templates - # # # ### @@ -234,9 +69,8 @@ arch:rolling:container_prep: - shell variables: GIT_STRATEGY: fetch - only: - changes: - - .gitlab-ci/**/* + extends: + - .container-rules stage: container_prep script: @@ -275,7 +109,145 @@ win:container_prep: - docker extends: - .monado.variables.windows:vs2022 + - .build-rules image: $MONADO_IMAGE + +# Variables for build and usage of Debian bullseye image +.monado.variables.debian:bullseye: + variables: + FDO_DISTRIBUTION_VERSION: "bullseye" + FDO_DISTRIBUTION_TAG: "2023-04-07" + +# Variables for build and usage of Debian bullseye-ndk image +.monado.variables.debian:bullseye-ndk: + variables: + FDO_DISTRIBUTION_VERSION: "bullseye" + FDO_DISTRIBUTION_TAG: "2023-04-10.1" + FDO_REPO_SUFFIX: ndk + +# Variables for build and usage of Ubuntu focal image +.monado.variables.ubuntu:focal: + variables: + FDO_DISTRIBUTION_VERSION: "20.04" + FDO_DISTRIBUTION_TAG: "2022-09-20.0" + +# Variables for build and usage of Ubuntu jammy image +.monado.variables.ubuntu:jammy: + variables: + FDO_DISTRIBUTION_VERSION: "22.04" + FDO_DISTRIBUTION_TAG: "2022-09-20.0" + +# Variables for build and usage of Arch rolling image +.monado.variables.arch:rolling: + variables: + FDO_DISTRIBUTION_VERSION: "rolling" + FDO_DISTRIBUTION_TAG: "2023-03-13.2" + +### +# Container prep jobs +# Make Debian bullseye image +debian:bullseye:container_prep: + stage: container_prep + extends: + - .container-rules + - .monado.variables.debian:bullseye + - .fdo.container-build@debian # from ci-templates + + variables: + FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates clang-format cmake codespell curl debhelper devscripts doxygen dput-ng gettext-base git glslang-tools graphviz libavcodec-dev libbluetooth-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 python3-click python3-pip unzip wget' + FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/i386_and_proclamation_container_prep.sh' + +# Make Debian bullseye-ndk image +debian:bullseye-ndk:container_prep: + stage: container_prep + extends: + - .container-rules + - .monado.variables.debian:bullseye-ndk + - .fdo.container-build@debian # from ci-templates + + variables: + FDO_DISTRIBUTION_PACKAGES: 'ca-certificates cmake default-jdk-headless git glslang-tools libeigen3-dev meson ninja-build pkg-config python3 unzip wget' + FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/android_container_prep.sh' + +# Make Ubuntu focal image +ubuntu:focal:container_prep: + stage: container_prep + extends: + - .container-rules + - .monado.variables.ubuntu:focal + - .fdo.container-build@ubuntu # from ci-templates + + variables: + FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates cmake curl debhelper devscripts dput-ng gettext-base git glslang-tools libavcodec-dev libbluetooth-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 unzip wget' + +# Make Ubuntu jammy image +ubuntu:jammy:container_prep: + stage: container_prep + extends: + - .container-rules + - .monado.variables.ubuntu:jammy + - .fdo.container-build@ubuntu # from ci-templates + + variables: + FDO_DISTRIBUTION_PACKAGES: 'build-essential ca-certificates cmake curl debhelper devscripts dput-ng gettext-base git glslang-tools libavcodec-dev libbluetooth-dev libbsd-dev libcjson-dev libdbus-1-dev libegl1-mesa-dev libeigen3-dev libgl1-mesa-dev libglvnd-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libhidapi-dev libopencv-dev libsdl2-dev libsystemd-dev libudev-dev libusb-1.0-0-dev libuvc-dev libv4l-dev libvulkan-dev libwayland-dev libx11-dev libx11-xcb-dev libxcb-randr0-dev libxrandr-dev libxxf86vm-dev ninja-build pandoc patch pkg-config python3 reprepro unzip wget' + +# Make Arch rolling image +arch:rolling:container_prep: + stage: container_prep + extends: + - .container-rules + - .monado.variables.arch:rolling + - .fdo.container-build@arch # from ci-templates + + variables: + FDO_DISTRIBUTION_PACKAGES: 'base-devel bc bluez-libs boost check clang cmake diffutils doxygen eigen ffmpeg fmt gcc git glew glfw-x11 glslang glu graphviz gtest gtk3 hidapi libbsd libusb libxrandr mesa meson ninja opencv patch pipewire-jack pkgconfig python-attrs python-setuptools python3 qt5-base v4l-utils vulkan-headers vulkan-icd-loader wayland wget wireplumber' + FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/install-arch-additional-deps.sh' + + +### +# Container usage base jobs + +# Base for using Debian bullseye image +.monado.image.debian:bullseye: + extends: + - .monado.variables.debian:bullseye + - .fdo.distribution-image@debian # from ci-templates + - .build-rules + + +# Base for using Debian bullseye-ndk image +.monado.image.debian:bullseye-ndk: + extends: + - .monado.variables.debian:bullseye-ndk + - .fdo.suffixed-image@debian # from ci-templates + - .build-rules + + +# Base for using Ubuntu focal image +.monado.image.ubuntu:focal: + extends: + - .monado.variables.ubuntu:focal + - .fdo.distribution-image@ubuntu # from ci-templates + - .build-rules + + +# Base for using Ubuntu jammy image +.monado.image.ubuntu:jammy: + extends: + - .monado.variables.ubuntu:jammy + - .fdo.distribution-image@ubuntu # from ci-templates + - .build-rules + + +# Base for using Arch rolling image +.monado.image.arch:rolling: + extends: + - .monado.variables.arch:rolling + - .fdo.distribution-image@arch # from ci-templates + - .build-rules + + + # Style check job format-and-spellcheck: extends: @@ -292,6 +264,8 @@ format-and-spellcheck: # Verify REUSE compliance reuse: + extends: + - .build-rules stage: build image: name: fsfe/reuse:latest diff --git a/.gitlab-ci/ci-containers-variables.yml.jinja b/.gitlab-ci/ci-containers-variables.yml.jinja new file mode 100644 index 000000000..c911654d0 --- /dev/null +++ b/.gitlab-ci/ci-containers-variables.yml.jinja @@ -0,0 +1,16 @@ +{# +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: 2018-2023 Collabora, Ltd. and the Monado contributors +#} + +{% for distro in distributions -%} {%- for image in distro.images %} + +# Variables for build and usage of {{ distro.name|capitalize }} {{image.codename}} image +.monado.variables.{{distro.name}}:{{image.codename}}: + variables: + FDO_DISTRIBUTION_VERSION: "{{ image["distro_version"] | default(image.codename) }}" + FDO_DISTRIBUTION_TAG: "{{image["tag"]}}" +{% if "repo_suffix" in image %} + FDO_REPO_SUFFIX: {{image["repo_suffix"]}} +{% endif %} +{% endfor -%} {%- endfor %} diff --git a/.gitlab-ci/ci-containers.yml.jinja b/.gitlab-ci/ci-containers.yml.jinja new file mode 100644 index 000000000..cf60fa420 --- /dev/null +++ b/.gitlab-ci/ci-containers.yml.jinja @@ -0,0 +1,41 @@ +{# +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: 2018-2023 Collabora, Ltd. and the Monado contributors +#} + +### +# Container prep jobs + +{%- for distro in distributions -%} {%- for image in distro.images %} + +# Make {{ distro.name|capitalize }} {{image.codename}} image +{{distro.name}}:{{image.codename}}:container_prep: + stage: container_prep + extends: + - .container-rules + - .monado.variables.{{distro.name}}:{{image.codename}} + - .fdo.container-build@{{distro.name}} # from ci-templates + + variables: + {# The packages list is actually a mapping, not an array, but the same syntax works. #} + {# Needed to be a mapping so it could be "merged" #} + FDO_DISTRIBUTION_PACKAGES: '{{image.packages | sort | join(" ")}}' +{% if "script" in image %} + FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/{{image["script"]}}' +{% endif %} +{% endfor -%} {%- endfor %} + +{% from 'functions.jinja' import base_job_to_use_image with context %} + +### +# Container usage base jobs +{% for distro in distributions -%} {%- for image in distro.images %} + +# Base for using {{ distro.name|capitalize }} {{image.codename}} image +{{base_job_to_use_image(distro, image)}}: + extends: + - .monado.variables.{{distro.name}}:{{image.codename}} + - .fdo.{{ "suffixed" if "repo_suffix" in image else "distribution" }}-image@{{distro.name}} # from ci-templates + - .build-rules + +{% endfor -%} {%- endfor %} diff --git a/.gitlab-ci/ci-rules.yml b/.gitlab-ci/ci-rules.yml new file mode 100644 index 000000000..315c2c0a9 --- /dev/null +++ b/.gitlab-ci/ci-rules.yml @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: 2018-2023 the Mesa contributors +# SPDX-FileCopyrightText: 2018-2023 Collabora, Ltd. and the Monado contributors + +# YAML anchors for rule conditions +# -------------------------------- +.rules-anchors: + rules: + # Post-merge pipeline + - if: &is-post-merge '$CI_PROJECT_NAMESPACE == "monado" && $CI_COMMIT_BRANCH' + when: on_success + # Pre-merge pipeline + - if: &is-pre-merge '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: on_success + + +# When to automatically run the CI for build jobs +.build-rules: + rules: + # If any files affecting the pipeline are changed, build/test jobs run + # automatically once all dependency jobs have passed + - changes: &all_paths + # build sys + - CMakeLists.txt + - "*.cmake" + - "**/*.gradle" + - "cmake/**/*" + - "gradle/**/*" + # GitLab CI + - ".gitlab-ci.yml" + - ".gitlab-ci/**/*" + # Source code + - "scripts/**/*" + - "src/**/*" + when: on_success + # Otherwise, build/test jobs won't run because no rule matched. + + +.container-rules: + rules: + # Run pipeline by default in the main project if any CI pipeline + # configuration files were changed, to ensure docker images are up to date + - if: *is-post-merge + changes: + - ".gitlab-ci.yml" + - ".gitlab-ci/**/*" + when: on_success + # Run pipeline by default if it is for a merge request, and any files + # affecting the pipeline were changed + - if: *is-pre-merge + changes: + *all_paths + when: on_success + # Allow triggering jobs manually in other cases if any files affecting the + # pipeline were changed + - changes: + *all_paths + when: manual + # Otherwise, container jobs won't run because no rule matched. diff --git a/.gitlab-ci/ci-scripts.mk b/.gitlab-ci/ci-scripts.mk index 95a77a266..18a339441 100644 --- a/.gitlab-ci/ci-scripts.mk +++ b/.gitlab-ci/ci-scripts.mk @@ -27,6 +27,10 @@ CI_FAIRY := ci-fairy generate-template --config=$(CONFIG_FILE) # As the default thing for ci-fairy to template, this is special cased .gitlab-ci.yml: .gitlab-ci/ci.template .gitlab-ci/win_containers.yml $(CONFIG_FILE) $(CI_FAIRY) $< > $@ +# Extra deps +.gitlab-ci.yml: .gitlab-ci/ci-containers-variables.yml.jinja +.gitlab-ci.yml: .gitlab-ci/ci-containers.yml.jinja +.gitlab-ci.yml: .gitlab-ci/functions.jinja # Everything else is structured alike $(FILES_IN_SUBDIR): %: %.jinja $(CONFIG_FILE) diff --git a/.gitlab-ci/ci.template b/.gitlab-ci/ci.template index eac29d523..2bb807f92 100644 --- a/.gitlab-ci/ci.template +++ b/.gitlab-ci/ci.template @@ -2,10 +2,11 @@ # SPDX-FileCopyrightText: 2018-2023 Collabora, Ltd. and the Monado contributors {# ignore the warning, this is actually the template to edit. #} -###################################### -# GENERATED - DO NOT EDIT # -# see .gitlab-ci/ci.template instead # -###################################### +############################################### +# GENERATED - DO NOT EDIT +# see .gitlab-ci/ci.template, etc instead +############################################### +{# See README.md for instructions to regenerate after modification. #} {# useful links: https://freedesktop.pages.freedesktop.org/ci-templates/ @@ -23,35 +24,23 @@ make -f .gitlab-ci/ci-scripts.mk # Detached MR pipelines, needed due to https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/438 -workflow: - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - - if: $CI_PIPELINE_SOURCE == 'push' +# workflow: +# rules: +# - if: $CI_PIPELINE_SOURCE == 'merge_request_event' +# - if: $CI_PIPELINE_SOURCE == 'push' variables: - FDO_UPSTREAM_REPO: monado/monado - -.templates_sha: &templates_sha {{fdo_ci_templates_sha}} + FDO_UPSTREAM_REPO: "monado/monado" include: -{% for distro in distributions %} - # {{ distro.name | capitalize }} - project: "freedesktop/ci-templates" - ref: *templates_sha - file: "/templates/{{distro.name}}.yml" + ref: {{fdo_ci_templates_sha}} + file: +{% for distro in distributions %} + - "/templates/{{distro.name}}.yml" {% endfor %} - -{% for distro in distributions -%} {%- for image in distro.images %} - -# Variables for build and usage of {{ distro.name|capitalize }} {{image.codename}} image -.monado.variables.{{distro.name}}:{{image.codename}}: - variables: - FDO_DISTRIBUTION_VERSION: "{{ image["distro_version"] | default(image.codename) }}" - FDO_DISTRIBUTION_TAG: "{{image["tag"]}}" -{% if "repo_suffix" in image %} - FDO_REPO_SUFFIX: {{image["repo_suffix"]}} -{% endif %} -{% endfor -%} {%- endfor %} + # - local: .gitlab-ci/containers/ci-container-prep.yml + - local: .gitlab-ci/ci-rules.yml stages: - container_prep @@ -61,57 +50,12 @@ stages: - pages - deploy -### -# Container prep jobs - -{%- for distro in distributions -%} {%- for image in distro.images %} - -# Make {{ distro.name|capitalize }} {{image.codename}} image -{{distro.name}}:{{image.codename}}:container_prep: - stage: container_prep - extends: - - .monado.variables.{{distro.name}}:{{image.codename}} - - .fdo.container-build@{{distro.name}} # from ci-templates - - rules: - - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - changes: - - .gitlab-ci/**/* - - if: $CI_PIPELINE_SOURCE == 'push' - changes: - - .gitlab-ci/**/* - variables: - {# The packages list is actually a mapping, not an array, but the same syntax works. #} - {# Needed to be a mapping so it could be "merged" #} - FDO_DISTRIBUTION_PACKAGES: '{{image.packages | sort | join(" ")}}' -{% if "script" in image %} - FDO_DISTRIBUTION_EXEC: 'env FDO_CI_CONCURRENT=${FDO_CI_CONCURRENT} bash .gitlab-ci/{{image["script"]}}' -{% endif %} -{% endfor -%} {%- endfor %} - -{# Macro to compute job name to extend to use image given distro and image objects#} -{% macro base_job_to_use_image(distro, image) %}.monado.image.{{distro.name}}:{{image.codename}}{% endmacro -%} - -### -# Container usage base jobs -{% for distro in distributions -%} {%- for image in distro.images %} - -# Base for using {{ distro.name|capitalize }} {{image.codename}} image -{{base_job_to_use_image(distro, image)}}: - extends: - - .monado.variables.{{distro.name}}:{{image.codename}} - - .fdo.{{ "suffixed" if "repo_suffix" in image else "distribution" }}-image@{{distro.name}} # from ci-templates - -{% endfor -%} {%- endfor %} - -{# Macro to compute job name to extend to use image given a package we want#} -{% macro base_job_to_use_image_containing(package) %} -{% for distro in distributions -%} {%- for image in distro.images if package in image.packages %} -{{ base_job_to_use_image(distro, image) if loop.first }} -{% endfor -%} {%- endfor %} -{% endmacro -%} {% include 'win_containers.yml' %} +{% include 'ci-containers-variables.yml.jinja' %} +{% include 'ci-containers.yml.jinja' %} + +{% from 'functions.jinja' import base_job_to_use_image_containing, base_job_to_use_image with context %} # Style check job format-and-spellcheck: @@ -128,6 +72,8 @@ format-and-spellcheck: # Verify REUSE compliance reuse: + extends: + - .build-rules stage: build image: name: fsfe/reuse:latest diff --git a/.gitlab-ci/functions.jinja b/.gitlab-ci/functions.jinja new file mode 100644 index 000000000..1e80a9692 --- /dev/null +++ b/.gitlab-ci/functions.jinja @@ -0,0 +1,14 @@ +{# +# SPDX-License-Identifier: CC0-1.0 +# SPDX-FileCopyrightText: 2018-2023 Collabora, Ltd. and the Monado contributors +#} + +{# Macro to compute job name to extend to use image given a package we want#} +{% macro base_job_to_use_image_containing(package) %} +{% for distro in distributions -%} {%- for image in distro.images if package in image.packages %} +{{ base_job_to_use_image(distro, image) if loop.first }} +{% endfor -%} {%- endfor %} +{% endmacro -%} + +{# Macro to compute job name to extend to use image given distro and image objects#} +{% macro base_job_to_use_image(distro, image) %}.monado.image.{{distro.name}}:{{image.codename}}{% endmacro -%} diff --git a/.gitlab-ci/win_containers.yml b/.gitlab-ci/win_containers.yml index 6d1a2a990..0ffafc01f 100644 --- a/.gitlab-ci/win_containers.yml +++ b/.gitlab-ci/win_containers.yml @@ -35,9 +35,8 @@ - shell variables: GIT_STRATEGY: fetch - only: - changes: - - .gitlab-ci/**/* + extends: + - .container-rules stage: container_prep script: @@ -76,4 +75,5 @@ win:container_prep: - docker extends: - .monado.variables.windows:vs2022 + - .build-rules image: $MONADO_IMAGE