about summary refs log tree commit diff
path: root/.gitlab-ci/ci.template
blob: 3af5cac45907e4400cce8c99b43f7076fb8acf67 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:

{# You're looking at the template here, so you can ignore the below
   warning. This is the right file to edit #}
########################################
#                                      #
# THIS FILE IS GENERATED, DO NOT EDIT  #
# Edit .gitlab-ci/ci.template instead  #
#                                      #
# Regenerate with:
#   TEMPLATE_SHA="$(sed -n 's/^.templates_sha: *\&template_sha *\([0-9a-f]\+\)$/\1/p' ./.gitlab-ci/ci.template)"
#   pip3 install "git+http://gitlab.freedesktop.org/freedesktop/ci-templates@$TEMPLATE_SHA"
#   ci-fairy generate-template
#
########################################


# see https://docs.gitlab.com/ee/ci/yaml/#includefile
.templates_sha: &template_sha 593a0a5fe35a523a646a7efae5471c9759b8fba3

{# Group distros by their common (name,) tuples.#}
{% set distro_groups = [] %}
{% for distro in distributions %}
  {% set g = {'name':distro.name} %}
  {% if g not in distro_groups %}
  {%   do distro_groups.append(g) %}
  {% endif %}
{% endfor %}

{# The "default_distro" builds our pages and is used for check-{tree,patch} tests. It is the first distro with tier 1. #}
{% set default_distro = [] %}
{% for distro in distributions %}
  {% if distro.tier == 1 and default_distro|length == 0 %}
    {% do default_distro.append(distro) %}
  {% endif %}
{% endfor %}
{% set default_distro = default_distro[0] %}

include:
{% for distro_group in distro_groups|sort(attribute='name') %}
  # {{ distro_group.name.capitalize() }} container builder template
  - project: 'freedesktop/ci-templates'
    ref: *template_sha
    file: '/templates/{{distro_group.name}}.yml'
{% endfor %}
  - project: 'freedesktop/ci-templates'
    file: '/templates/ci-fairy.yml'

stages:
  - prep
  - tier1
  - tier2
  - tier3
  - deploy
  - triage
  - coverity

variables:
  FDO_UPSTREAM_REPO: NetworkManager/NetworkManager
  GIT_DEPTH: 1
  # These tags should be updated each time the list of packages is updated
  # changing these will force rebuilding the associated image
  # Note: these tags have no meaning and are not tied to a particular NM version
  #
  # This is done by running `ci-fairy generate-template` and possibly bumping
  # ".default_tag".
{% for distro_group in distro_groups|sort(attribute='name') %}
  {{"%-13s"| format(distro_group.name.upper() + '_TAG:')}}'tag-{{
    (ci_fairy.hashfiles('./.gitlab-ci/config.yml',
                        './.gitlab-ci/ci.template',
                        './.gitlab-ci/' + base_types[distro_group.name] + '-install.sh',
                        './contrib/' + base_types[distro_group.name] + '/REQUIRED_PACKAGES'))[0:12]
  }}'
{% endfor %}

{% for distro_group in distro_groups|sort(attribute='name') %}
  {{"%-13s"| format(distro_group.name.upper() + '_EXEC:')}}'bash .gitlab-ci/{{base_types[distro_group.name]}}-install.sh'
{% endfor %}

.nm_artifacts:
  variables:
    NM_BUILD_TARBALL: 1
  artifacts:
    expire_in: 5 days
    when: always
    paths:
      - docs-html
      - NetworkManager-1*.tar.xz
      - NetworkManager-1*.src.rpm
      - nm-test.log
      - testlog.txt

.nm_artifacts_debug:
  artifacts:
    expire_in: 5 days
    when: always
    paths:
      - nm-test.log
      - testlog.txt

#################################################################
#                                                               #
# prep stage                                                    #
#                                                               #
#################################################################

# Build a container for each distribution + version. The ci-templates
# will re-use the containers if the tag doesn't change.
{% for distro in distributions %}
{% for version in distro.versions %}

tier{{distro.tier}}:{{distro.name}}:{{version}}@prep:
  extends:
    - .fdo.container-build@{{distro.name}}
  stage: prep
  variables:
    GIT_STRATEGY: none
    FDO_DISTRIBUTION_VERSION: '{{version}}'
    FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
    FDO_DISTRIBUTION_EXEC: ${{distro.name.upper()}}_EXEC
  rules:
{% if distro.tier == 1 %}
    - if: $CI_PIPELINE_SOURCE != 'schedule' || $SCHEDULED_PIPELINE_NAME == "weekly"
{% else %}
    - if: $CI_PIPELINE_SOURCE != 'schedule'
      when: manual
      allow_failure: true
{% endif %}
{% endfor %}
{% endfor %}

#################################################################
#                                                               #
# tierN stage                                                   #
#                                                               #
#################################################################

.build@template:
  script:
    - env
    - r=0
    - .gitlab-ci/run-test.sh 2>&1 | tee /tmp/nm-test.log || r=$?
    - mv /tmp/nm-test.log .
    - exit $r
  dependencies: []

{% for distro in distributions %}
{% for version in distro.versions %}

t_{{distro.name}}:{{version}}:
  extends:
    - .build@template
    - .fdo.distribution-image@{{distro.name}}
{% if distro == default_distro %}
    - .nm_artifacts
{% else %}
    - .nm_artifacts_debug
{% endif %}
  stage: tier{{distro.tier}}
{% if distro.tier <= 1 %}
  parallel:
    matrix:
      - NM_TEST_SELECT_RUN:
        - meson+gcc+docs+valgrind
        - meson+clang
        - rpm+meson
        - tarball+meson
        - tarball
        - subtree
{% endif %}
  variables:
    FDO_DISTRIBUTION_VERSION: '{{version}}'
    FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
    {# Where we have extra_variables defined, add them to the list #}
    {% if distro.build is defined and distro.build.extra_variables is defined %}
    {% for var in distro.build.extra_variables %}
    {{var}}
    {% endfor %}
    {% endif %}
  needs:
    - "tier{{distro.tier}}:{{distro.name}}:{{version}}@prep"
  rules:
    - if: $CI_PIPELINE_SOURCE != 'schedule'
{% endfor %}
{% endfor %}

#################################################################
#                                                               #
# specific jobs                                                 #
#                                                               #
#################################################################

check-patch:
  extends:
    - .fdo.distribution-image@{{default_distro.name}}
  variables:
    FDO_DISTRIBUTION_VERSION: '{{default_distro.versions[0]}}'
    FDO_DISTRIBUTION_TAG: ${{default_distro.name.upper()}}_TAG
  needs:
    - "tier{{default_distro.tier}}:{{default_distro.name}}:{{default_distro.versions[0]}}@prep"
  rules:
    - if: $CI_PIPELINE_SOURCE != 'schedule'
  stage: tier1
  script:
    - date '+%Y%m%d-%H%M%S'; NM_CHECKPATCH_FETCH_UPSTREAM=1 contrib/scripts/checkpatch-feature-branch.sh
  allow_failure: true

check-tree:
  extends:
    - .fdo.distribution-image@{{default_distro.name}}
  variables:
    FDO_DISTRIBUTION_VERSION: '{{default_distro.versions[0]}}'
    FDO_DISTRIBUTION_TAG: ${{default_distro.name.upper()}}_TAG
  needs:
    - "tier{{default_distro.tier}}:{{default_distro.name}}:{{default_distro.versions[0]}}@prep"
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME != $CI_DEFAULT_BRANCH
      allow_failure: true
    - if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      allow_failure: true
    - if: $CI_PIPELINE_SOURCE != 'schedule'
  stage: tier1
  script:
    - date '+%Y%m%d-%H%M%S'; clang-format --version
    - date '+%Y%m%d-%H%M%S'; black --version
    - date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-python-black-format.sh --check
    - date '+%Y%m%d-%H%M%S'; git ls-files -z -- 'po/*.po' | xargs -0 -n1 msgfmt -vc
    - date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-code-format.sh -n
    - date '+%Y%m%d-%H%M%S'; ci-fairy generate-template && git diff --exit-code
    - date '+%Y%m%d-%H%M%S'; meson setup build && [ "$(LANG=C ninja -C build NetworkManager-update-po 2>&1 1>/dev/null | grep -c 'warning:')" = 0 ]

pages:
  stage: deploy
  script:
    - mv docs-html public
  artifacts:
    expire_in: 20 days
    paths:
      - public
  rules:
    - if: $CI_PIPELINE_SOURCE == 'schedule'
      when: never
    - if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'main'
  dependencies:
    - "t_{{default_distro.name}}:{{default_distro.versions[0]}}: [meson+gcc+docs+valgrind]"
  needs:
    - "t_{{default_distro.name}}:{{default_distro.versions[0]}}: [meson+gcc+docs+valgrind]"

triage:issues:
  stage: triage
  image: ruby:3
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE_NAME == "daily"
  tags:
    - placeholder-job  # The job mostly waits on network requests, so use only one CPU: https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/1358#note_2457416
  script:
    - gem install gitlab-triage
    - gitlab-triage --debug --token $API_TOKEN --source-id $CI_PROJECT_ID

coverity:
  extends:
    - .fdo.distribution-image@{{default_distro.name}}
  variables:
    FDO_DISTRIBUTION_VERSION: '{{default_distro.versions[0]}}'
    FDO_DISTRIBUTION_TAG: ${{default_distro.name.upper()}}_TAG
  stage: coverity
  needs:
    - "tier{{default_distro.tier}}:{{default_distro.name}}:{{default_distro.versions[0]}}@prep"
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE_NAME == "weekly"
  script:
    - dnf install -y curl
    - CC=gcc CONFIGURE_ONLY=1 contrib/scripts/nm-ci-run.sh
    - cd build
    - ../.gitlab-ci/coverity.sh download
    - cov-analysis-linux64-*/bin/cov-build --dir cov-int ninja
    - ../.gitlab-ci/coverity.sh upload

# Clean the generated images periodically to get updated snapshots of the distribution images.
# Create an scheduled pipeline to run it, passing an AUTHFILE environment variable of type
# 'File' with an authentication token with API access level.
clean-images:
  extends:
    - .fdo.ci-fairy
  stage: prep
  rules:
    - if: $CI_PIPELINE_SOURCE == "schedule" && $SCHEDULED_PIPELINE_NAME == "weekly"
  script:
    - ci-fairy -v --authfile $AUTHFILE delete-image --project NetworkManager/NetworkManager --all

# Have detached MR pipeline (https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html)
# https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/540#what-it-means-for-me-a-maintainer-of-a-project-part-of-gitlabfreedesktoporg
workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_PIPELINE_SOURCE == 'schedule'
    - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
      when: never
    - if: $CI_COMMIT_BRANCH