summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 0ef643cf2aa7fa5300484387ce3e1bd11b17f792 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# This file uses the freedesktop ci-templates to build shared-mime-info and
# run our tests in CI.
#
# ci-templates uses a multi-stage build process. First, the base container
# image is built which contains the core distribution, the toolchain, and
# all our build dependencies. This container is aggressively cached; if a
# container image matching $FDO_DISTRIBUTION_TAG is found in either the
# upstream repo (wayland/weston) or the user's downstream repo, it is
# reused for the build. This gives us predictability of build and far
# quicker runtimes, however it means that any changes to the base container
# must also change $FDO_DISTRIBUTION_TAG. When changing this, please use
# the current date as well as a unique build identifier.
#
# After the container is either rebuilt (tag mismatch) or reused (tag
# previously used), the build stage executes within this container.
#
# Apart from the 'variables', 'include', and 'stages' top-level anchors,
# everything not beginning with a dot ('.') is the name of a job which will
# be executed as part of CI, unless the rules specify that it should not be
# run.
#
# Variables prefixed with CI_ are generally provided by GitLab itself;
# variables prefixed with FDO_ and templates prefixed by .fdo are provided
# by the ci-templates.
#
# For more information on GitLab CI, including the YAML syntax, see:
#   https://docs.gitlab.com/ee/ci/yaml/README.html
#
# Note that freedesktop.org uses the 'Community Edition' of GitLab, so features
# marked as 'premium' or 'ultimate' are not available to us.
#
# For more information on ci-templates, see:
#   - documentation at https://freedesktop.pages.freedesktop.org/ci-templates/
#   - repo at https://gitlab.freedesktop.org/freedesktop/ci-templates/

# These are used to make sure that we execute 'detached pipelines' on merge
# requests.
workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_PIPELINE_SOURCE == 'push'

stages:
  - "Base container"
  - "Build and test"

# Here we use a fixed ref in order to isolate ourselves from ci-templates
# API changes. If you need new features from ci-templates you must bump
# this to the current SHA you require from the ci-templates repo, however
# be aware that you may need to account for API changes when doing so.
.templates_sha: &template_sha b791bd48996e3ced9ca13f1c5ee82be8540b8adb # see https://docs.gitlab.com/ee/ci/yaml/#includefile

include:
  - project: 'freedesktop/ci-templates'
    ref: *template_sha
    file:
      - '/templates/fedora.yml'

variables:
  FDO_UPSTREAM_REPO: "xdg/shared-mime-info"
  FDO_REPO_SUFFIX: "$BUILD_OS/$BUILD_ARCH"
  GIT_SUBMODULE_STRATEGY: normal


# Per-OS environment definitions
.os-fedora:
  variables:
    # bump this tag every time you change something which requires rebuilding
    # the base image (e.g. changing dependencies)
    FDO_DISTRIBUTION_TAG: "2022-08-15.0"
    BUILD_OS: fedora
    FDO_DISTRIBUTION_VERSION: 38
    FDO_DISTRIBUTION_PACKAGES: "gcc gcc-c++ glibc-devel make libxml2-devel glib2-devel gettext git xmlto findutils gettext-devel meson"
  
.fedora-x86_64:
  extends:
    - .os-fedora
  variables:
    BUILD_ARCH: "x86-64"

.build-env-fedora-x86_64:
  extends:
    - .fdo.suffixed-image@fedora
    - .fedora-x86_64
  needs:
    - job: fedora-x86_64-container_prep
      artifacts: false

# Real container build job (mostly a no-op)
fedora-x86_64-container_prep:
  extends:
    - .fedora-x86_64
    - .fdo.container-build@fedora
  stage: "Base container"
  variables:
    GIT_STRATEGY: none


# Build job template
.do-build:
  stage: "Build and test"
  script:
    # Compile xdgmime
    - make -C xdgmime

    # Compile and test shared-mime-info
    - meson _build
    - ninja -C _build
    - ninja -C _build test
    - ninja -C _build dist
  artifacts:
    when: always
    paths:
      - _build/meson-logs/*.txt
      - _build/meson-dist/*.*

# Real build job
fedora-x86_64-build:
  extends:
    - .build-env-fedora-x86_64
    - .do-build