File: .gitlab-ci.yml

package info (click to toggle)
conky 1.11.6-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 11,824 kB
  • sloc: xml: 89,480; cpp: 39,856; ansic: 2,340; python: 714; sh: 194; makefile: 130
file content (795 lines) | stat: -rw-r--r-- 18,942 bytes parent folder | download
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
---
stages:
  - pull
  - base
  - dependencies
  - build
  - test
  - deploy

variables:
  SCCACHE_GCS_BUCKET: btm-build-cache
  SCCACHE_GCS_RW_MODE: READ_WRITE
  SCCACHE_GCS_KEY_PATH: /tmp/storage-key.json
  DOCKER_DRIVER: overlay2

before_script:
  - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

.pull_images: &pull_images
  stage: pull
  allow_failure: true
  image: docker:stable
  services:
    - docker:dind
  script:
    - set -- $CI_JOB_NAME
    - export DISTRO=$2
    - export COMPILER=$3
    - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\""
    - export DOCKER_HOST="${DOCKER_HOST:-tcp://localhost:2375/}"
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    # Pull either the last ref slug, or latest, depending on which exists
    - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG || docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest
    # If ref slug exists, use that, otherwise fallback to latest tag
    - >
      docker tag
      $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG
      $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA ||
      docker tag
      $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest
      $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
    - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA

pull ubuntu clang-7: *pull_images
pull ubuntu clang-8: *pull_images
pull ubuntu gcc-5: *pull_images
pull ubuntu gcc-6: *pull_images
pull ubuntu gcc-7: *pull_images
pull ubuntu gcc-8: *pull_images
pull fedora-29 gcc-8: *pull_images
pull fedora-29 clang-7: *pull_images
pull fedora-31 clang-8: *pull_images
pull centos6 gcc-7: *pull_images
pull centos7 gcc-7: *pull_images
pull centos7 gcc-8: *pull_images
pull centos7 clang-5: *pull_images

.docker_base_builder: &docker_base_builder
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure
      - unknown_failure
      - api_failure
  stage: base
  image: docker:stable
  only:
    changes:
      - tests/dockerfiles/*
  services:
    - docker:dind
  before_script:
    - set -- $CI_JOB_NAME
    - export DISTRO=$2
    - "echo \"Distro: ${DISTRO}\nDocker base: ${DOCKER_BASE_IMAGE}\""
    - export DOCKER_HOST="${DOCKER_HOST:-tcp://localhost:2375/}"
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
    - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest || true
    - >
      docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG
      || true
    - >
      docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA
      || true
  script:
    - cd tests/dockerfiles
    - docker pull $DOCKER_BASE_IMAGE || true
    - >
      docker build -f Dockerfile.$DISTRO-base
      --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest
      --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG
      --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest
      --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA
      --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG .
    - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA
    - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_REF_SLUG

builder ubuntu base:
  <<: *docker_base_builder
  variables:
    DOCKER_BASE_IMAGE: ubuntu:bionic

builder fedora-29 base:
  <<: *docker_base_builder
  variables:
    DOCKER_BASE_IMAGE: fedora:29

builder fedora-31 base:
  <<: *docker_base_builder
  variables:
    DOCKER_BASE_IMAGE: fedora:31

builder centos6 base:
  <<: *docker_base_builder
  variables:
    DOCKER_BASE_IMAGE: centos:6

builder centos7 base:
  <<: *docker_base_builder
  variables:
    DOCKER_BASE_IMAGE: centos:7

.docker_builder: &docker_builder
  <<: *docker_base_builder
  stage: dependencies
  script:
    - set -- $CI_JOB_NAME
    - export DISTRO=$2
    - export COMPILER=$3
    - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\""
    - cd tests/dockerfiles
    - >
      docker tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA
      $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest
    - >
      docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
      || true
    - >
      docker build -f Dockerfile.$DISTRO-$COMPILER
      --build-arg IMAGE=$CI_REGISTRY_IMAGE
      --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest
      --cache-from $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
      --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
      --tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG .
    - docker push ${CI_REGISTRY_IMAGE}/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
    - >
      docker push
      ${CI_REGISTRY_IMAGE}/builder/$DISTRO-$COMPILER:$CI_COMMIT_REF_SLUG

builder ubuntu clang-7: *docker_builder
builder ubuntu clang-8: *docker_builder
builder ubuntu gcc-5: *docker_builder
builder ubuntu gcc-6: *docker_builder
builder ubuntu gcc-7: *docker_builder
builder ubuntu gcc-8: *docker_builder
builder fedora-29 gcc-8: *docker_builder
builder fedora-29 clang-7: *docker_builder
builder fedora-31 clang-8: *docker_builder
builder centos6 gcc-7: *docker_builder
builder centos7 gcc-7: *docker_builder
builder centos7 gcc-8: *docker_builder
builder centos7 clang-5: *docker_builder

.build_stages: &build_stages
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure
      - unknown_failure
      - api_failure
  image: $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
  stage: build
  script:
    - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\nCC: $CC\nCXX: $CXX\""
    - mkdir build
    - cd build
    - >
      cmake
      -DCMAKE_EXE_LINKER_FLAGS=$LINKER_FLAGS
      -DCMAKE_C_COMPILER_LAUNCHER=sccache
      -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
      -DMAINTAINER_MODE=ON
      -DBUILD_AUDACIOUS=$BUILD_AUDACIOUS
      -DBUILD_MYSQL=ON
      -DBUILD_LUA_IMLIB2=ON
      -DBUILD_LUA_RSVG=$BUILD_LUA_RSVG
      -DBUILD_LUA_CAIRO=$BUILD_LUA_CAIRO
      -DBUILD_XMMS2=$BUILD_XMMS2
      -DBUILD_ICAL=ON
      -DBUILD_IRC=ON
      -DBUILD_HTTP=ON
      -DBUILD_ICONV=ON
      -DBUILD_PULSEAUDIO=ON
      -DBUILD_JOURNAL=$BUILD_JOURNAL
      -DBUILD_RSS=ON
      -DBUILD_IRC=ON
      -DBUILD_NVIDIA=$BUILD_NVIDIA
      ..
    - make -j4

.build_variables: &build_variables
  LINKER_FLAGS: ""
  BUILD_AUDACIOUS: "ON"
  BUILD_XMMS2: "ON"
  BUILD_NVIDIA: "ON"
  BUILD_JOURNAL: "ON"
  BUILD_LUA_CAIRO: "ON"
  BUILD_LUA_RSVG: "ON"

ubuntu clang-7:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: ubuntu
    COMPILER: clang-7
    CC: clang-7
    CXX: clang++-7

ubuntu clang-8:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: ubuntu
    COMPILER: clang-8
    CC: clang-8
    CXX: clang++-8

ubuntu gcc-5:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: ubuntu
    COMPILER: gcc-5
    CC: gcc-5
    CXX: g++-5

ubuntu gcc-6:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: ubuntu
    COMPILER: gcc-6
    CC: gcc-6
    CXX: g++-6

ubuntu gcc-7:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: ubuntu
    COMPILER: gcc-7
    CC: gcc-7
    CXX: g++-7

ubuntu gcc-8:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: ubuntu
    COMPILER: gcc-8
    CC: gcc-8
    CXX: g++-8

fedora-29 gcc-8:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: fedora-29
    COMPILER: gcc-8
    CC: gcc
    CXX: g++
    BUILD_AUDACIOUS: "OFF"

fedora-29 clang-7:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: fedora-29
    COMPILER: clang-7
    CC: clang
    CXX: clang++
    BUILD_AUDACIOUS: "OFF"

fedora-31 clang-8:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: fedora-31
    COMPILER: clang-8
    CC: clang
    CXX: clang++
    BUILD_AUDACIOUS: "OFF"

centos6 gcc-7:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: centos6
    COMPILER: gcc-7
    CC: gcc
    CXX: g++
    CMAKE: cmake3
    BUILD_AUDACIOUS: "OFF"
    BUILD_XMMS2: "OFF"
    BUILD_NVIDIA: "OFF"
    BUILD_JOURNAL: "OFF"
    BUILD_LUA_CAIRO: "OFF"
    BUILD_LUA_RSVG: "OFF"
    # required because centos6 separates tinfo from ncurses
    LINKER_FLAGS: "-ltinfo"
  before_script:
    - source /opt/rh/devtoolset-7/enable
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

centos7 gcc-7:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: centos7
    COMPILER: gcc-7
    CC: gcc
    CXX: g++
    CMAKE: cmake3
    BUILD_AUDACIOUS: "OFF"
    BUILD_XMMS2: "OFF"
    BUILD_NVIDIA: "OFF"
    BUILD_JOURNAL: "OFF"
  before_script:
    - source /opt/rh/devtoolset-7/enable
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

centos7 gcc-8:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: centos7
    COMPILER: gcc-8
    CC: gcc
    CXX: g++
    CMAKE: cmake3
    BUILD_AUDACIOUS: "OFF"
    BUILD_XMMS2: "OFF"
    BUILD_NVIDIA: "OFF"
    BUILD_JOURNAL: "OFF"
  before_script:
    - source /opt/rh/devtoolset-8/enable
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

centos7 clang-5:
  <<: *build_stages
  variables:
    <<: *build_variables
    DISTRO: centos7
    COMPILER: clang-5
    CC: clang
    CXX: clang++
    BUILD_AUDACIOUS: "OFF"
    BUILD_XMMS2: "OFF"
    BUILD_NVIDIA: "OFF"
    BUILD_JOURNAL: "OFF"
  before_script:
    - source /opt/rh/llvm-toolset-7/enable
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

.freebsd_deps: &freebsd_deps
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure
      - unknown_failure
      - api_failure
  tags:
    - freebsd12
  before_script:
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH
    - 'echo "COMPILER_PACKAGE: $COMPILER_PACKAGE"'
    # Try up to 7 times until installation succeeds. It may be locked.
    - >
      (
      flock -x -w 600 9 || exit 1;
      sudo pkg update;
      sudo pkg install -y -q
      cairo
      cmake
      docbook-xsl
      docbook2X
      gettext-runtime
      imlib2
      lcov
      libical
      libiconv
      libinotify
      libircclient
      libmicrohttpd
      librsvg2
      libX11
      libXdamage
      libXext
      libXfixes
      libXft
      libXinerama
      libxslt
      lua53
      mysql80-client
      pkgconf
      xmms2
      $COMPILER_PACKAGE
      ) 9>/var/lock/pkg

.freebsd_build_script: &freebsd_build_script
  script:
    - mkdir build
    - cd build
    - >
      cmake
      -DCMAKE_REQUIRED_INCLUDES="/usr/include;/usr/local/include"
      -DCMAKE_EXE_LINKER_FLAGS=$LINKER_FLAGS
      -DMAINTAINER_MODE=ON
      -DBUILD_MYSQL=ON
      -DBUILD_LUA_IMLIB2=ON
      -DBUILD_LUA_RSVG=ON
      -DBUILD_LUA_CAIRO=ON
      -DBUILD_XMMS2=ON
      -DBUILD_ICAL=ON
      -DBUILD_IRC=ON
      -DBUILD_HTTP=ON
      -DBUILD_ICONV=ON
      -DBUILD_RSS=ON
      -DBUILD_IRC=ON
      ..
    - make -j4

freebsd12 gcc-8:
  <<: *freebsd_deps
  stage: build
  variables:
    DISTRO: freebsd12
    CC: gcc
    CXX: g++
    COMPILER_PACKAGE: gcc
  <<: *freebsd_build_script

freebsd12 clang-7:
  <<: *freebsd_deps
  stage: build
  variables:
    DISTRO: freebsd12
    CC: clang70
    CXX: clang++70
    COMPILER_PACKAGE: llvm70
  <<: *freebsd_build_script

freebsd12 clang-8:
  <<: *freebsd_deps
  stage: build
  variables:
    DISTRO: freebsd12
    CC: clang80
    CXX: clang++80
    COMPILER_PACKAGE: llvm80
  <<: *freebsd_build_script

.test_stages: &test_stages
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure
      - unknown_failure
      - api_failure
  image: $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
  stage: test

.test_run: &test_run
  script:
    - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\nCC: $CC\nCXX: $CXX\""
    - mkdir build
    - cd build
    - |
      if [[ "$DISTRO" == "freebsd12" ]] ; then
        cmake \
        -DBUILD_TESTS=ON \
        -DMAINTAINER_MODE=ON \
        ..
      else
        cmake \
        -DCMAKE_C_COMPILER_LAUNCHER=sccache \
        -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
        -DBUILD_TESTS=ON \
        -DMAINTAINER_MODE=ON \
        ..
      fi
    - make -j4
    - make -j4 test
    - if [ "$COMPILER" == "clang-7" ] ; then make -j4 test-conky-coverage-txt ; fi
    - if [ "$COMPILER" == "clang-7" ] ; then make -j4 test-conky-coverage-html ; fi
    - if [ "$COMPILER" == "clang-7" ] ; then lcov-summary test-conky-coverage-html.info.cleaned ; fi
    - make -j4
    - if [[ "$DISTRO" == "freebsd12" ]] ; then sudo make install ; else make install ; fi
    - conky -v
    - find . -iname '*.gcda' -delete
    - |
      if [[ "$DISTRO" == "freebsd12" ]] ; then
        cmake \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DRELEASE=ON \
        ..
      else
        cmake \
        -DCMAKE_C_COMPILER_LAUNCHER=sccache \
        -DCMAKE_CXX_COMPILER_LAUNCHER=sccache \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DRELEASE=ON \
        ..
      fi
    - make -j4
    - if [[ "$DISTRO" == "freebsd12" ]] ; then sudo make install ; else make install ; fi
    - conky -v
  coverage: '/Total Coverage:\s+(\d+\.\d+)%/'
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME-coverage-report"
    paths:
      - build/test-conky-coverage-html/

test ubuntu clang-7:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: ubuntu
    COMPILER: clang-7
    CC: clang-7
    CXX: clang++-7

test ubuntu clang-8:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: ubuntu
    COMPILER: clang-8
    CC: clang-8
    CXX: clang++-8

test ubuntu gcc-5:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: ubuntu
    COMPILER: gcc-5
    CC: gcc-5
    CXX: g++-5

test ubuntu gcc-6:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: ubuntu
    COMPILER: gcc-6
    CC: gcc-6
    CXX: g++-6

test ubuntu gcc-7:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: ubuntu
    COMPILER: gcc-7
    CC: gcc-7
    CXX: g++-7

test ubuntu gcc-8:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: ubuntu
    COMPILER: gcc-8
    CC: gcc-8
    CXX: g++-8


test fedora-29 gcc-8:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: fedora-29
    COMPILER: gcc-8
    CC: gcc
    CXX: g++

test fedora-29 clang-7:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: fedora-29
    COMPILER: clang-7
    CC: clang
    CXX: clang++

test fedora-31 clang-8:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: fedora-31
    COMPILER: clang-8
    CC: clang
    CXX: clang++

test centos6 gcc-7:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: centos7
    COMPILER: gcc-7
    CC: gcc
    CXX: g++
  before_script:
    - source /opt/rh/devtoolset-7/enable
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

test centos7 clang-5:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: centos7
    COMPILER: clang-5
    CC: clang
    CXX: clang++
  before_script:
    - source /opt/rh/llvm-toolset-7/enable
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

test centos7 gcc-7:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: centos7
    COMPILER: gcc-7
    CC: gcc
    CXX: g++
  before_script:
    - source /opt/rh/devtoolset-7/enable
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

test centos7 gcc-8:
  <<: *test_stages
  <<: *test_run
  variables:
    DISTRO: centos7
    COMPILER: gcc-8
    CC: gcc
    CXX: g++
  before_script:
    - source /opt/rh/devtoolset-8/enable
    - echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH

test freebsd12 clang-7:
  <<: *freebsd_deps
  <<: *test_run
  variables:
    DISTRO: freebsd12
    COMPILER: clang-7
    COMPILER_PACKAGE: llvm70
    CC: clang70
    CXX: clang++70

test freebsd12 clang-8:
  <<: *freebsd_deps
  <<: *test_run
  variables:
    DISTRO: freebsd12
    COMPILER: clang-8
    COMPILER_PACKAGE: llvm80
    CC: clang80
    CXX: clang++80

test freebsd12 gcc-8:
  <<: *freebsd_deps
  <<: *test_run
  variables:
    DISTRO: freebsd12
    COMPILER: gcc-8
    COMPILER_PACKAGE: gcc
    CC: gcc
    CXX: g++

check clang-tidy:
  <<: *test_stages
  variables:
    COMPILER: clang-8
    DISTRO: ubuntu
    CC: clang-8
    CXX: clang++-8
  script:
    - mkdir build
    - cd build
    - >
      cmake
      -DCMAKE_C_COMPILER_LAUNCHER=sccache
      -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
      -DMAINTAINER_MODE=ON
      -DCHECK_CODE_QUALITY=ON
      ..
    - make -j4
    - make -j4 check-clang-tidy

check clang-format:
  <<: *test_stages
  variables:
    COMPILER: clang-8
    DISTRO: ubuntu
    CC: clang-8
    CXX: clang++-8
  script:
    - mkdir build
    - cd build
    - >
      cmake
      -DCMAKE_C_COMPILER_LAUNCHER=sccache
      -DCMAKE_CXX_COMPILER_LAUNCHER=sccache
      -DMAINTAINER_MODE=ON
      -DCHECK_CODE_QUALITY=ON
      ..
    - make -j4 check-clang-format

.push_base_images: &push_base_images
  retry:
    max: 2
    when:
      - runner_system_failure
      - stuck_or_timeout_failure
      - unknown_failure
      - api_failure
  stage: deploy
  image: docker:stable
  services:
    - docker:dind
  only:
    changes:
      - tests/dockerfiles/*
    refs:
      - master
      - tags
  before_script:
    - export DOCKER_HOST="${DOCKER_HOST:-tcp://localhost:2375/}"
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  script:
    - set -- $CI_JOB_NAME
    - export DISTRO=$2
    - 'echo "Distro: ${DISTRO}"'
    - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA
    - >
      docker tag $CI_REGISTRY_IMAGE/builder/$DISTRO-base:$CI_COMMIT_SHA
      $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest
    - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-base:latest

push ubuntu base: *push_base_images
push centos6 base: *push_base_images
push centos7 base: *push_base_images
push fedora-29 base: *push_base_images
push fedora-31 base: *push_base_images

.push_images: &push_images
  <<: *push_base_images
  only:
    changes:
      - tests/dockerfiles/*
    refs:
      - master
      - tags
  script:
    - set -- $CI_JOB_NAME
    - export DISTRO=$2
    - export COMPILER=$3
    - "echo \"Distro: ${DISTRO}\nCompiler: ${COMPILER}\""
    - docker pull $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
    - >
      docker tag $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:$CI_COMMIT_SHA
      $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest
    - docker push $CI_REGISTRY_IMAGE/builder/$DISTRO-$COMPILER:latest

push ubuntu clang-7: *push_images
push ubuntu clang-8: *push_images
push ubuntu gcc-5: *push_images
push ubuntu gcc-6: *push_images
push ubuntu gcc-7: *push_images
push ubuntu gcc-8: *push_images
push fedora-29 gcc-8: *push_images
push fedora-29 clang-7: *push_images
push fedora-31 clang-8: *push_images
push centos6 gcc-7: *push_images
push centos7 gcc-7: *push_images
push centos7 gcc-8: *push_images
push centos7 clang-5: *push_images