summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: dfb22fb3d0dff615ec492c9b4a6d5e4027668428 (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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
image: buildstream/buildstream-fedora:latest

variables:
  # Store everything under the /builds directory. This is a separate Docker
  # volume. Note that GitLab CI will only cache stuff inside the build
  # directory. Note also that YBD recursively scans the current directory
  # to find what definitions to build -- that's why we put the cache in a
  # hidden directory.
  XDG_CACHE_HOME: "${CI_PROJECT_DIR}/.cache"
  YBD_base: "/cache/ybd_base"
  YBD_gits: "${CI_PROJECT_DIR}/.cache/ybd_base/gits"
  YBD_SHA: '157986cb2f7c0b95e0e4e0bf3a39547f548a298d'
  SPEC_SHA: '715023f3cf6e714839fb56236ade20de40855bd4'
  BST_SHA: 'b14a0c575991f3b75aa15b21b2652186b62d0a09'
  DEFS2BST_SHA: '1dc5c0719de9357470b29ad4adc9b63f7012db86'
  GET_SOURCES_ATTEMPTS: 3

# Store all the downloaded git and ostree repos in the distributed cache.
# This saves us fetching them from git.baserock.org and further afield
# on every build.
.ybd_cache: &ybd_cache
  cache:
    # GitLab defined default key is "default". Reuse this for ybd.
    key: default
    paths:
      - "${YBD_gits}/"
.bst_cache: &bst_cache
  cache:
    key: bst
    paths:
      - "${XDG_CACHE_HOME}/buildstream/sources/"

.ybd_before_script: &ybd_before_script
  before_script:
    # Install and configure YBD
    - |
      export LC_ALL="C.UTF-8"
      git clone https://gitlab.com/baserock/spec.git
      git -C spec checkout $SPEC_SHA
      git clone https://gitlab.com/baserock/ybd.git
      git -C ybd checkout $YBD_SHA
      cd ybd && ./install_dependencies.sh && cd ..
      pip install -r spec/requirements.txt

.bst_before_script: &bst_before_script
  before_script:
    # Use specific version of BuildStream
    - |
      git clone https://gitlab.com/BuildStream/buildstream.git
      cd buildstream && git checkout $BST_SHA
      pip3 install .
      cd -

    # Create ~/.ssh for storing keys
    - mkdir -p ~/.ssh

    # Private key stored as a protected variable that allows pushing to
    # ostree@ostree.baserock.org
    - |
      if [ -z "$baserock_ostree_cache_private_key" ]; then
          echo >&2 "Private key for ostree.baserock.org is not available."
      else
          echo "$baserock_ostree_cache_private_key" > ~/.ssh/id_rsa
          chmod 600 ~/.ssh/id_rsa
          ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub
      fi

    # Trust the host key of the cache server.
    - ssh-keyscan -p 22200 ostree.baserock.org >> ~/.ssh/known_hosts

    # Enable push and pull for Baserock artifact cache (default config is pull only)
    - |
      mkdir -p ~/.config
      echo "projects:" > ~/.config/buildstream.conf
      echo "  baserock:" >> ~/.config/buildstream.conf
      echo "    artifacts:" >> ~/.config/buildstream.conf
      echo "      pull-url: https://ostree.baserock.org/cache/" >> ~/.config/buildstream.conf
      if [ -n "$baserock_ostree_cache_private_key" ]; then
          echo "      push-url: ostree@ostree.baserock.org:cache" >> ~/.config/buildstream.conf
          echo "      push-port: 22200" >> ~/.config/buildstream.conf
      fi
      cat ~/.config/buildstream.conf

    # Nuke ybd cache to ensure buildstream tasks have enough disk space.
    - rm -rf "${YBD_base}"

stages:
  - preprocess
  - build-1
  - deploy-1
  - build-2
  - build-3

ybd-validate-all-definitions:
  stage: preprocess
  <<: *ybd_before_script
  script:
  - python spec/quick_check.py .
  <<: *ybd_cache

ybd-build-system-x86_64-chroot-build:
  stage: build-1
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py systems/build-system-x86_64-chroot.morph x86_64
  <<: *ybd_cache

ybd-build-system-x86_64-chroot-deploy:
  stage: deploy-1
  dependencies:
  - ybd-build-system-x86_64-chroot-build
  <<: *ybd_before_script
  script:
  - ybd/ybd.py clusters/build-system-x86_64-chroot-deploy.morph x86_64
  cache:
    # GitLab defined default key is "default". Reuse this for ybd.
    key: default
    policy: pull
    paths:
      - .cache/ybd_base/gits
  artifacts:
    name: "${CI_BUILD_NAME}-${CI_BUILD_REF}"
    paths:
    - build-system-x86_64-chroot.tar

#build-system-armv7lhf-rootfs-build:
#  stage: build-1
#  script:
#  - sudo ybd/ybd.py systems/build-system-armv7lhf-rootfs.morph armv7lhf
#  tags:
#  - armv7l
#  only:
#  - master
#  - /^staging\/.*$/

ybd-devel-build-64:
  stage: build-2
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py systems/devel-system-x86_64-generic.morph x86_64
  <<: *ybd_cache

ybd-genivi-baseline-build-64:
  stage: build-2
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py genivi/systems/genivi-baseline-system-x86_64-generic.morph x86_64
  - ybd/ybd.py systems/initramfs-x86_64.morph x86_64
  <<: *ybd_cache

ybd-genivi-demo-platform-build-64:
  stage: build-3
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py genivi/systems/genivi-demo-platform-x86_64-generic.morph x86_64
  - ybd/ybd.py systems/initramfs-x86_64.morph x86_64
  <<: *ybd_cache

ybd-ivi-build-64:
  stage: build-3
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py ivi/systems/ivi-system-x86_64.morph x86_64
  - ybd/ybd.py systems/initramfs-x86_64.morph x86_64
  <<: *ybd_cache

ybd-gnome-build-64:
  stage: build-3
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py gnome/systems/gnome-system-x86_64.morph x86_64
  - ybd/ybd.py systems/initramfs-x86_64.morph x86_64
  <<: *ybd_cache

ybd-minimal-build-64:
  stage: build-1
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py systems/minimal-system-x86_64-chroot.morph x86_64
  <<: *ybd_cache

ybd-minimal-system-x86_64-chroot-deploy:
  stage: deploy-1
  dependencies:
  - ybd-minimal-build-64
  <<: *ybd_before_script
  script:
  - ybd/ybd.py clusters/minimal-system-x86_64-chroot-deploy.morph x86_64
  cache:
    # GitLab defined default key is "default". Reuse this for ybd.
    key: default
    policy: pull
    paths:
      - .cache/ybd_base/gits
  artifacts:
    name: "${CI_BUILD_NAME}-${CI_BUILD_REF}"
    paths:
    - minimal-system-x86_64-chroot.tar

ybd-trove-build-64:
  stage: build-2
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py trove/systems/trove-system-x86_64.morph x86_64
  <<: *ybd_cache

ybd-weston-build-64:
  stage: build-2
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py weston/systems/weston-system-x86_64-generic.morph x86_64
  - ybd/ybd.py systems/initramfs-x86_64.morph x86_64
  <<: *ybd_cache

ybd-weston-qt-build-64:
  stage: build-3
  dependencies: []
  <<: *ybd_before_script
  script:
  - ybd/ybd.py weston/systems/weston-qt5-system-x86_64.morph x86_64
  - ybd/ybd.py systems/initramfs-x86_64.morph x86_64
  <<: *ybd_cache


##########################################
# BuildStream conversions and tests      #
##########################################

# Convert the Baserock definitions to BuildStream format
bst-convert:
  stage: preprocess
  <<: *bst_before_script
  script:
  # Install YBD and defs2bst
  - |
    if [ ! -d ./ybd ]; then
      git clone https://gitlab.com/baserock/ybd.git
      git -C ybd checkout $YBD_SHA
      cd ybd && ./install_dependencies.sh && cd -
    fi
    git clone https://gitlab.com/BuildStream/defs2bst.git
    git -C defs2bst checkout $DEFS2BST_SHA
    echo "defs2bst version: $(git -C ./defs2bst rev-parse HEAD)"
  - ./convert
  artifacts:
    paths:
    - elements/
  <<: *ybd_cache

# Test building a common Baserock system
bst-build-build-system:
  stage: build-1
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/build-system-content.bst
  <<: *bst_cache

# Test building all converted Baserock systems
bst-build-base-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/base-system-content.bst
  <<: *bst_cache

bst-build-devel-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/devel-system-content.bst
  <<: *bst_cache

bst-build-genivi-demo-platform-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/genivi-demo-platform-content.bst
  <<: *bst_cache

bst-build-gnome-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/gnome-system-content.bst
  <<: *bst_cache

bst-build-ivi-demo-platform-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/ivi-system-content.bst
  <<: *bst_cache

bst-build-minimal-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/minimal-system-content.bst
  <<: *bst_cache

bst-build-openstack-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/openstack-system-content.bst
  <<: *bst_cache

bst-build-trove-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/trove-system-content.bst
  <<: *bst_cache

bst-build-weston-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/weston-system-content.bst
  <<: *bst_cache

bst-build-weston-qt5-system:
  stage: build-2
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-build-or-show systems/weston-qt5-system-content.bst
  <<: *bst_cache

# Test cross building a toolchain and sysroot for each supported non-x86_64
# architecture.
bst-build-sysroot-armv8b64:
  stage: build-3
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-cross-build-or-show armv8b64 gnu-toolchain/stage2.bst
  <<: *bst_cache

bst-build-sysroot-armv8l64:
  stage: build-3
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-cross-build-or-show armv8l64 gnu-toolchain/stage2.bst
  <<: *bst_cache

bst-build-sysroot-ppc64b:
  stage: build-3
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-cross-build-or-show ppc64b gnu-toolchain/stage2.bst
  <<: *bst_cache

bst-build-sysroot-ppc64l:
  stage: build-3
  dependencies:
    - bst-convert
  <<: *bst_before_script
  script:
  - scripts/bst-cross-build-or-show ppc64l gnu-toolchain/stage2.bst
  <<: *bst_cache