summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: e6a0635e83ec8c0a9c47d96023c25d50cd1eb224 (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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0:

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


include:
  # Arch container builder template
  - project: 'freedesktop/ci-templates'
    ref: *template_sha
    file: '/templates/arch.yml'
  - project: 'freedesktop/ci-templates'
    ref: *template_sha
    file: '/templates/ci-fairy.yml'


workflow:
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
    - if: $CI_PIPELINE_SOURCE == 'push'


# global variables to be used by most/all jobs.
variables:
  FDO_UPSTREAM_REPO: 'xkeyboard-config/xkeyboard-config'

  BUILDDIR: '_build'
  # installation directory must be inside $CI_PROJECT_DIR to allow for artifact caching
  INSTDIR: '$CI_PROJECT_DIR/_inst'
  # Override these in the jobs to pass commands to configure/make
  CONFIGURE_ARGS: ''
  MAKE_EXTRA_ARG: ''

  # Changing the tag will rebuild the container images. The value is just a
  # string, but we use the date for human benefits.
  FDO_DISTRIBUTION_TAG: '2022-01-20.0'

  # xkbcommon: needed to share artifacts between jobs
  XKBCOMMON_DIR: 'libxkbcommon'
  XKBCOMMON_INST_DIR: $CI_PROJECT_DIR/$XKBCOMMON_DIR/_inst


stages:
  - sanity
  - prep
  - build
  - dist
  - test
  - gitlab


container-prep:
  extends:
    - .fdo.container-build@arch
  stage: prep
  variables:
    GIT_STRATEGY: none
    # minimal set of packages required to build xkeyboard-config.
    BASE_PACKAGES: 'xorg-util-macros gettext pkg-config gcc grep m4 python meson ninja git diffutils'
    # extra packages we need for various tests
    EXTRA_PACKAGES: 'tree libxml2 bison xorg-xkbcomp python-pytest python-libevdev python-yaml yq libxkbcommon libxslt python-pycountry'
    FDO_DISTRIBUTION_PACKAGES: $BASE_PACKAGES $EXTRA_PACKAGES


.default_setup:
  extends:
    - .fdo.distribution-image@arch



.meson_build:
  extends: .default_setup
  script:
    - if [ x"$TARBALL" != "x" ]; then
        mkdir tarball;
        tar xf "$BUILDDIR/$TARBALL" -C tarball/ --strip-components=1;
        pushd tarball > /dev/null;
      fi
    - meson "$BUILDDIR" -Dprefix="$INSTDIR"
    - meson configure "$BUILDDIR"
    - ninja -C "$BUILDDIR"
    - if test x"$NINJA_EXTRA_COMMAND" != "x"; then ninja -C "$BUILDDIR" $NINJA_EXTRA_COMMAND; fi

#
# Verify that the merge request has the allow-collaboration checkbox ticked
#

check-merge-request:
  extends:
    - .fdo.ci-fairy
  stage: gitlab
  script:
    - ci-fairy check-merge-request --require-allow-collaboration --junit-xml=results.xml
  artifacts:
    when: on_failure
    reports:
      junit: results.xml
  allow_failure: true
  dependencies: []

#
# Verify that commit messages are as expected
#

check-commit:
  extends:
    - .fdo.ci-fairy
  stage: sanity
  script:
    - ci-fairy -vv check-commits --junit-xml=results.xml
  except:
    - master@$FDO_UPSTREAM_REPO
  variables:
    GIT_DEPTH: 100
  artifacts:
    reports:
      junit: results.xml

#
# Format Python code with python-black
#
python-black:
  extends:
    - .fdo.ci-fairy
  stage: sanity
  before_script:
    - python3 -m venv venv
    - source venv/bin/activate
    - pip3 install black
  script:
    - black --check --diff .

meson_install:
  extends: .meson_build
  stage: build
  variables:
      NINJA_EXTRA_COMMAND: "install"
  after_script:
    - tree $INSTDIR
  artifacts:
    name: installed files
    expire_in: 2 weeks
    paths:
      - $INSTDIR/

meson_test:
  extends: .meson_build
  stage: build
  variables:
      NINJA_EXTRA_COMMAND: "test"

meson_dist:
  extends: .meson_build
  stage: build
  variables:
      NINJA_EXTRA_COMMAND: "dist"
  artifacts:
    name: tarball
    expire_in: 2 weeks
    paths:
      - $BUILDDIR/meson-dist/xkeyboard-config-*.tar.xz


# Download and build xkbcommon
xkbcommon build:
  extends: .default_setup
  stage: build
  script:
    # Ensure there are no leftovers
    - rm -rf xorgproto libxkbcommon
    # Get latest xorgproto so we definitely have all keysyms
    - git clone --depth=1 https://gitlab.freedesktop.org/xorg/proto/xorgproto
    - export X11_HEADERS_PREFIX="$PWD/xorgproto/"
    # Get latest xkbcommon
    - git clone --depth=1 https://github.com/xkbcommon/libxkbcommon "$XKBCOMMON_DIR"
    - pushd "$XKBCOMMON_DIR" > /dev/null
    - ./scripts/update-keysyms
    # Setup meson for minimal xkbcommon build with explicit paths.
    # NOTE: we set the library directory as it may depend on the host architecture.
    - >
      meson setup "$BUILDDIR" \
        -Denable-wayland=false \
        -Denable-x11=false \
        -Denable-docs=false \
        -Dxkb-config-root="$INSTDIR/share/X11/xkb" \
        -Dxkb-config-extra-path="$INSTDIR/share/X11/xkb" \
        -Dprefix="$XKBCOMMON_INST_DIR" \
        -Dlibdir="lib"
    - meson compile -C "$BUILDDIR"
    - meson install -C "$BUILDDIR"
    # We want also the test script. It requires "xkbcli-compile-keymap".
    - cp "$BUILDDIR/xkeyboard-config-test" "$XKBCOMMON_INST_DIR/bin"
  artifacts:
    when: on_success
    name: xkbcommon build
    expire_in: 3 hours
    paths:
      # Keep artifact as small as possible.
      # At the moment only "layout_tests" and "keymap_tests" require our build.
      # The other jobs use the distro xkbcommon.
      - $XKBCOMMON_INST_DIR/bin
      - $XKBCOMMON_INST_DIR/lib/libxkbcommon.so*
      - $XKBCOMMON_INST_DIR/libexec/xkbcommon/xkbcli-compile-keymap


# Checks for new evdev keycodes to be added to keycodes/evdev
evdev keycode check:
  extends:
    - .default_setup
  stage: test
  script:
    - .gitlab-ci/generate-evdev-keycodes.py --verbose || (echo "keycodes/evdev file needs to be updated" && false)
  allow_failure: true
  artifacts:
    when: on_failure
    name: Updated evdev keycodes
    expire_in: 2 weeks
    paths:
      - keycodes/evdev
  needs: ['container-prep']


# Checks for new keysyms to be added to symbols/inet (using xorgproto master)
evdev keysym check (xorgproto master):
  extends:
    - .default_setup
  stage: test
  script:
    # Check out the latest xorgproto tag
    - git clone https://gitlab.freedesktop.org/xorg/proto/xorgproto
    - .gitlab-ci/generate-evdev-keysyms.py --header xorgproto/include/X11/XF86keysym.h
    - git diff --exit-code || (echo "New keysyms available, please update symbols/inet" && false)
  allow_failure: true
  artifacts:
    when: on_failure
    name: Updated inet keysyms
    expire_in: 2 weeks
    paths:
      - symbols/inet
  needs: ['container-prep']


xmllint:
  extends:
    - .default_setup
  dependencies: ['meson_install']
  needs: ['meson_install']
  stage: test
  script:
    - xmllint --dtdvalid "$INSTDIR/share/X11/xkb/rules/xkb.dtd" $INSTDIR/share/X11/xkb/rules/*.xml > /dev/null


match group names to registry:
  extends:
    - .default_setup
  needs: ['container-prep']
  stage: test
  script:
    - "./tests/verify-group-names.sh"


# libxkbcommon's xkbcli list prints out YAML-like format, if yq cannot parse it, our
# evdev.xml file is off
xkbcli list check:
  extends:
    - .default_setup
  dependencies: ['meson_install']
  needs: ['meson_install']
  stage: test
  script:
    - xkbcli list --skip-default-paths --load-exotic "$INSTDIR/share/X11/xkb" > rmlvo.yaml
    - head -n20 rmlvo.yaml
    - yq . rmlvo.yaml > /dev/null
  artifacts:
    when: on_failure
    name: xbkcli list output
    expire_in: 2 weeks
    paths:
      - rmlvo.yaml


# Run the libxkbcommon layout test program. This will
# run a basic keymap compile test against every combination of
# layout/variant/option. Syntax errors will fail the test, check the
# archived file for details.
layout_tests:
  extends: .default_setup
  stage: test
  needs:
    - job: meson_install
      artifacts: true
    - job: xkbcommon build
      artifacts: true
  script:
    # make sure the custom layout resolves to something
    - ln -s "$INSTDIR/share/X11/xkb/symbols/us" "$INSTDIR/share/X11/xkb/symbols/custom"
    # make sure the custom types resolves to something
    - ln -s "$INSTDIR/share/X11/xkb/types/basic" "$INSTDIR/share/X11/xkb/types/custom"
    # run xkbcommon test
    - echo Running test script - this will take several minutes
    # Ensure we use our local version of xkbcommon
    - export LD_LIBRARY_PATH="$XKBCOMMON_INST_DIR/lib:$LD_LIBRARY_PATH"
    # Ensure xkeyboard-config-test and xkbcli-compile-keymap are in the PATH
    - export PATH="$XKBCOMMON_INST_DIR/bin:$XKBCOMMON_INST_DIR/libexec/xkbcommon:$PATH"
    # For debugging: check if executable is working and output its XKB_CONFIG_ROOT
    - xkbcli-compile-keymap --layout pc --verbose > /dev/null
    - >
      xkeyboard-config-test --verbose \
          "$INSTDIR/share/X11/xkb/rules/evdev.xml" \
          >  $INSTDIR/keymaps-success.yaml \
          2> $INSTDIR/keymaps-failed.yaml
    - >
      xkeyboard-config-test --verbose \
          "$INSTDIR/share/X11/xkb/rules/evdev.extras.xml" \
          >>  $INSTDIR/keymaps-success.yaml \
          2>> $INSTDIR/keymaps-failed.yaml
  after_script:
    - echo "Failed keymap compilations:"
    - yq -c ".[] | select(.status != 0) | .cmd, .error" $INSTDIR/keymaps-failed.yaml
    - successful_tests=$(yq ". | length" "$INSTDIR/keymaps-success.yaml")
    - >
      .gitlab-ci/yaml-to-junit-xml.py \
        --additional-successful-tests $successful_tests \
        "$INSTDIR/keymaps-failed.yaml" \
        > junit-results.xml
    - xz -z "$INSTDIR/keymaps-success.yaml"
    - xz -z "$INSTDIR/keymaps-failed.yaml"
  variables:
    GIT_DEPTH: 1
  artifacts:
    when: on_failure
    name: xkeyboard-config test output
    expire_in: 2 weeks
    paths:
    - $INSTDIR/keymaps-success.yaml.xz
    - $INSTDIR/keymaps-failed.yaml.xz
    reports:
      junit: junit-results.xml

keymap_tests:
  extends: .default_setup
  stage: test
  needs:
    # use the installed tree from the meson_install job
    - job: meson_install
      artifacts: true
    - job: xkbcommon build
      artifacts: true
  script:
    # Configure the environment for our local xkbcommon build & Python bindings.
    - export XKB_CONFIG_ROOT="$INSTDIR/share/X11/xkb"
    - export XKBCOMMON_LIB_PATH="$XKBCOMMON_INST_DIR/lib/libxkbcommon.so"
    - export PYTHONPATH="$PWD/tests:$PYTHONPATH"
    # Run the tests
    - pytest --junitxml=results.xml
  artifacts:
    reports:
      junit: results.xml