.templates_sha: &templates_sha 0a0c8db6589472e3ff58e8c3feec518a43167286

include:
  - project: 'freedesktop/ci-templates'
    ref: *templates_sha
    file: '/templates/ci-fairy.yml'
  - project: 'freedesktop/ci-templates'
    ref: *templates_sha
    file: '/templates/alpine.yml'

variables:
  FDO_UPSTREAM_REPO: 'wayland/wayland-utils'
  FDO_DISTRIBUTION_TAG: '2022-05-26.0'
  #FDO_FORCE_REBUILD: 1

stages:
  - "Contribution checks"
  - "Prepare container"
  - "Build and test"

check-mr:
  extends: .fdo.ci-fairy
  stage: "Contribution checks"
  script:
   - ci-fairy check-commits --signed-off-by
   - ci-fairy check-merge-request --require-allow-collaboration
  rules:
    - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
      when: always
    - when: never

prepare-container:
  extends: .fdo.container-build@alpine
  stage: "Prepare container"
  variables:
    FDO_DISTRIBUTION_PACKAGES: 'build-base meson libdrm-dev wayland-protocols git libffi-dev expat-dev'
    FDO_DISTRIBUTION_EXEC: |
      git clone https://gitlab.freedesktop.org/wayland/wayland.git --depth 1 --branch=1.20.0
      cd wayland
      meson build/ -Dtests=false -Ddocumentation=false -Ddtd_validation=false
      ninja -C build/ install
      cd ..
      rm -rf wayland

      git clone https://gitlab.freedesktop.org/wayland/wayland-protocols
      cd wayland-protocols
      git checkout -q 1.24
      meson build/ -Dtests=false
      ninja -C build/ install
      cd ..
      rm -rf wayland-protocols
  rules:
    - when: on_success

build:
  extends: .fdo.distribution-image@alpine
  stage: "Build and test"
  script:
    - meson build/ -Dwerror=true
    - ninja -C build/
    - ninja -C build/ test
  artifacts:
    paths:
      - build/meson-logs/
  rules:
    - when: on_success
