summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 7d4b6805b6482b051d1e12a808348fd2df8c42d3 (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
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
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
stages:
  - bootstrap
  - build
  - test
  - archive

variables:
  # we utilize the images generated by the build-images project, to
  # speed up CI runs. We also use ccache and store config.cache
  # to speed up compilation. We include a version number in cache
  # name to allow expiration of old caches.
  BUILD_IMAGES_PROJECT: gnutls/build-images
  DEBIAN_BUILD: buildenv-debian-testing
  DEBIAN_CROSS_BUILD: buildenv-debian-cross-testing
  DEBIAN_X86_CROSS_BUILD: buildenv-debian-x86-cross
  FEDORA_BUILD: buildenv-fedora36
  MINGW_BUILD: buildenv-mingw-fedora36
  ALPINE_BASE_BUILD: buildenv-alpine-base
  COMPILER: gcc
  CPPCHECK_OPTIONS: "--enable=warning --enable=performance --enable=portability --std=c99 --suppressions-list=devel/cppcheck.suppressions --template='{id}:{file}:{line},{severity},{message}'"
  GET_SOURCES_ATTEMPTS: "3"
  # With just one virtual core, parallel builds only make sense when
  # I/O wait is involved. If too many parallel builds are used, the overall
  # time even increases (e.g. due to more cache misses).
  # $BUILDJOBS seems to be best with $(nproc)+1, while $CHECKJOBS can be much
  # higher because several tests have a large I/O waiting time.
  # The numbers are hard-coded for the platforms without the nproc command.
  BUILDJOBS: 2
  CHECKJOBS: 16

cache:
  key: "$CI_JOB_NAME-ver27"
  paths:
    - cache/

.prepare-ccache: &prepare-ccache
  # CCache Config
  - mkdir -p cache
  - export CCACHE_BASEDIR=${PWD}
  - export CCACHE_DIR=${PWD}/cache
  - export CCACHE_FILE=${CCACHE_DIR}/config.cache
  - export CC="ccache $COMPILER"

default:
  before_script:
    - *prepare-ccache

  after_script:
    # after_script is executed in separate shell
    - *prepare-ccache
    - ccache -s

  interruptible: true

.bootstrap:
  stage: bootstrap
  tags:
    - shared
    - linux
  script:
    - SUBMODULE_NOFETCH=1 ./bootstrap
  artifacts:
    expire_in: 1 day
    #when: on_failure
    paths:
      - ./
    exclude:
      - .git/ # passing forward .git causes warnings and possibly problems
      - ./**/.git/ # passing forward .git causes warnings and possibly problems
      - ./**/*.c
      - ./**/*.h
      - ./**/*.o

.build:
  stage: build
  tags:
    - shared
    - linux
  except:
    - tags # TODO
  artifacts:
    expire_in: 1 day
    #when: on_failure
    paths:
      - ./
    exclude:
      - .git/ # passing forward .git causes warnings and possibly problems
      - ./**/.git/ # passing forward .git causes warnings and possibly problems
      - ./**/*.c
      - ./**/*.h
      - ./**/*.o

.test:
  stage: test
  script:
    - make -j$CHECKJOBS check
  tags:
    - shared
    - linux
  except:
    - tags # TODO
  artifacts:
    expire_in: 1 week
    when: on_failure
    paths:
      - ./*.log
      - ./**/*.log

.fedora:
  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD

.fedora-nettle:
  extends:
    - .fedora
  variables:
    COMPILER: clang
    NETTLE_DIR: nettle

.debian:
  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$DEBIAN_BUILD

.debian-cross-i686:
  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$DEBIAN_X86_CROSS_BUILD

.debian-cross-other:
  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$DEBIAN_CROSS_BUILD

.mingw:
  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
  variables:
    COMPILER: "${arch_name}-w64-mingw32-gcc"
    CFLAGS: "-fstack-protector"
    CXXFLAGS: "-fstack-protector"
    LDFLAGS: "-fstack-protector"
    WINEPATH: "/usr/${arch_name}-w64-mingw32/sys-root/mingw/bin"
  before_script:
    - *prepare-ccache
    - mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
    - echo ':DOSWin:M::MZ::/usr/bin/wine:' > /proc/sys/fs/binfmt_misc/register

.mingw-vista:
  variables:
    # Target Vista instead of XP, currently the default in mingw
    CPPFLAGS: "-D_WIN32_WINNT=0x600"

.mingw32:
  extends:
    - .mingw
  variables:
    arch_bits: 32
    arch_name: i686

.mingw64:
  extends:
    - .mingw
  variables:
    arch_bits: 64
    arch_name: x86_64

##############################################################################
############# Standalone checks without dependencies #########################
##############################################################################

commit-check:
  stage: test
  image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$ALPINE_BASE_BUILD
  needs: [] # can be run immediately
  before_script: []
  after_script: []
  except:
    - master@gnutls/gnutls
  cache: {}
  script:
    # we want $ALPINE_BASE_BUILD without git, so we are adding it here
    - apk add git bash
    - devel/check_if_signed
  retry: 0

doc-dist.Fedora:
  extends:
    - .test
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - CFLAGS="-std=c99 -O2 -g" dash ./configure --disable-gcc-warnings --cache-file $CCACHE_FILE --prefix=/usr --libdir=/usr/lib64 --disable-cxx --disable-non-suiteb-curves --enable-gtk-doc --disable-maintainer-mode --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS -C doc stamp-vti
    - make -j$BUILDJOBS -C doc stamp_enums
    - make -j$BUILDJOBS
    - make -j$BUILDJOBS -C doc gnutls.html
    - texconfig rehash
    - make -j$BUILDJOBS -C doc/latex gnutls.pdf
    - DB2EPUBDIR=$(dirname $(find /usr/share/sgml/docbook/xsl-ns-stylesheets-*/epub/bin/ -name dbtoepub -print))
    - PATH="$PATH:$DB2EPUBDIR" make -C doc gnutls.epub
    - make -j$CHECKJOBS distcheck


# Two runs, one with normal backend and another with pkcs11 trust store
UB+ASAN-Werror.Fedora.x86_64.gcc:
  extends:
    - .test
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - export UBSAN_OPTIONS=print_stacktrace=1
    - export LSAN_OPTIONS=suppressions=$(pwd)/devel/lsan.supp
    - export CFLAGS="-std=c99 -O1 -g -Wno-cpp -Werror -fno-omit-frame-pointer -fsanitize=undefined,bool,alignment,null,enum,bounds-strict,address,leak,nonnull-attribute -fno-sanitize-recover=all -fsanitize-address-use-after-scope"
    - export CXXFLAGS="$CFLAGS"
    - dash ./configure --cache-file $CCACHE_FILE --disable-doc --with-pkcs12-iter-count=10000
    - sed -i 's/-fanalyzer//g' lib/Makefile
    - sed -i 's/-Werror/-Wno-parentheses -Werror/g' src/Makefile
    - make -j$BUILDJOBS
    # Use $BUILDJOBS since the fuzzers should use mainly CPU (no blocking I/O)
    - make -j$BUILDJOBS check -C fuzz
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x1
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x2
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x4
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x8
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x20
    - make -j$CHECKJOBS check -C tests
    - dash ./configure --cache-file $CCACHE_FILE --disable-doc --with-pkcs12-iter-count=10000 --with-default-trust-store-pkcs11="pkcs11:" --with-system-priority-file=/etc/crypto-policies/back-ends/gnutls.config --with-default-priority-string=@SYSTEM
    - make clean
    - sed -i 's/-fanalyzer//g' lib/Makefile
    - sed -i 's/-Werror/-Wno-parentheses -Werror/g' src/Makefile
    - make -j$BUILDJOBS
    # Use $BUILDJOBS since most of the job is building all tests, then just running 4 tests
    - make -j$BUILDJOBS check -C tests TESTS="trust-store p11-kit-load.sh priority-init2 set-default-prio" SUBDIRS=.
  tags:
    - shared
    - linux
  except:
    - tags

# Same as UB+ASAN-Werror.Fedora.x86_64.gcc, except -DAGGRESSIVE_REALLOC is set
UB+ASAN-Werror-aggressive.Fedora.x86_64.gcc:
  extends:
    - .test
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - export UBSAN_OPTIONS=print_stacktrace=1
    - export LSAN_OPTIONS=suppressions=$(pwd)/devel/lsan.supp
    - export CFLAGS="-std=c99 -O1 -g -Wno-cpp -Werror -fno-omit-frame-pointer -fsanitize=undefined,bool,alignment,null,enum,bounds-strict,address,leak,nonnull-attribute -fno-sanitize-recover=all -fsanitize-address-use-after-scope -DAGGRESSIVE_REALLOC"
    - export CXXFLAGS="$CFLAGS"
    - dash ./configure --cache-file $CCACHE_FILE --disable-doc --with-pkcs12-iter-count=10000
    - sed -i 's/-fanalyzer//g' lib/Makefile
    - sed -i 's/-Werror/-Wno-parentheses -Werror/g' src/Makefile
    - make -j$BUILDJOBS
    # Use $BUILDJOBS since the fuzzers should use mainly CPU (no blocking I/O)
    - make -j$BUILDJOBS check -C fuzz
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x1
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x2
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x4
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x8
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x20
    - make -j$CHECKJOBS check -C tests
    - dash ./configure --cache-file $CCACHE_FILE --disable-doc --with-pkcs12-iter-count=10000 --with-default-trust-store-pkcs11="pkcs11:" --with-system-priority-file=/etc/crypto-policies/back-ends/gnutls.config --with-default-priority-string=@SYSTEM
    - make clean
    - sed -i 's/-fanalyzer//g' lib/Makefile
    - sed -i 's/-Werror/-Wno-parentheses -Werror/g' src/Makefile
    - make -j$BUILDJOBS
    # Use $BUILDJOBS since most of the job is building all tests, then just running 4 tests
    - make -j$BUILDJOBS check -C tests TESTS="trust-store p11-kit-load.sh priority-init2 set-default-prio" SUBDIRS=.
  tags:
    - shared
    - linux
  except:
    - tags

# ASan with -DAGGRESSIVE_REALLOC is set
# Two runs, one with normal backend and another with pkcs11 trust store
UB+ASAN-Werror.Fedora.x86_64.gcc-aggressive:
  extends:
    - .test
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - export UBSAN_OPTIONS=print_stacktrace=1
    - export LSAN_OPTIONS=suppressions=$(pwd)/devel/lsan.supp
    - export CFLAGS="-std=c99 -O1 -g -Wno-cpp -Werror -fno-omit-frame-pointer -fsanitize=undefined,bool,alignment,null,enum,bounds-strict,address,leak,nonnull-attribute -fno-sanitize-recover=all -fsanitize-address-use-after-scope -DAGGRESSIVE_REALLOC"
    - export CXXFLAGS="$CFLAGS"
    - dash ./configure --cache-file $CCACHE_FILE --disable-doc --disable-hardware-acceleration
    - sed -i 's/-fanalyzer//g' lib/Makefile
    - sed -i 's/-Werror/-Wno-parentheses -Werror/g' src/Makefile
    - make -j$BUILDJOBS
    # Use $BUILDJOBS since the fuzzers should use mainly CPU (no blocking I/O)
    - make -j$BUILDJOBS check -C fuzz
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x1
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x2
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x4
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x8
    - make -j$BUILDJOBS check -C fuzz GNUTLS_CPUID_OVERRIDE=0x20
    - make -j$CHECKJOBS check -C tests
    - dash ./configure --cache-file $CCACHE_FILE --disable-doc --disable-hardware-acceleration --with-default-trust-store-pkcs11="pkcs11:" --with-system-priority-file=/etc/crypto-policies/back-ends/gnutls.config --with-default-priority-string=@SYSTEM
    - make clean
    - sed -i 's/-fanalyzer//g' lib/Makefile
    - sed -i 's/-Werror/-Wno-parentheses -Werror/g' src/Makefile
    - make -j$BUILDJOBS
    # Use $BUILDJOBS since most of the job is building all tests, then just running 4 tests
    - make -j$BUILDJOBS check -C tests TESTS="trust-store p11-kit-load.sh priority-init2 set-default-prio" SUBDIRS=.
  tags:
    - shared
    - linux
  except:
    - tags

##############################################################################
########################### Fedora pipelines #################################
##############################################################################

fedora/bootstrap:
  extends:
    - .bootstrap
    - .fedora

fedora-notools/build:
  extends:
    - .build
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - dash ./configure --cache-file $CCACHE_FILE --disable-gcc-warnings --disable-full-test-suite --disable-doc --disable-tools --enable-tests --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    # build tests, but don't execute them
    - make -j$BUILDJOBS check TESTS=""

fedora-notools/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-notools/build
  needs:
    - fedora-notools/build

fedora-minimal/build:
  extends:
    - .build
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - dnf remove -y libunistring-devel libtasn1-devel libidn-devel
    - dash ./configure --cache-file $CCACHE_FILE --with-included-libtasn1
      --disable-doc --disable-dtls-srtp-support --disable-alpn-support --disable-tests
      --disable-heartbeat-support --disable-srp-authentication --disable-psk-authentication
      --disable-anon-authentication --disable-dhe --disable-ecdhe
      --disable-ocsp --disable-non-suiteb-curves --with-included-unistring
      --disable-nls --disable-libdane --without-p11-kit --without-tpm --without-tpm2
      --disable-ssl3-support --disable-ssl2-support --disable-doc --enable-openssl-compatibility
      --disable-gcc-warnings --with-system-priority-file=""
      --disable-gost
      --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    # build tests, but don't execute them
    - make -j$BUILDJOBS check TESTS=""

fedora-minimal/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-minimal/build
  needs:
    - fedora-minimal/build

fedora-interop/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-minimal/build
  needs:
    - fedora-minimal/build
  parallel:
    matrix:
      - COMPONENT: openssl
        TYPE: 2way
        SLICEID: 0
        SLICES: 1
      - COMPONENT: nss
        TYPE: 2way
        SLICEID: [0, 1]
        SLICES: 2
  timeout: 45 minutes
  allow_failure: true
  script:
    - cd tests/suite/tls-interoperability/
    - echo "Tests to run:"
    - tmt run plans -n interop tests -f "tag:interop-gnutls" -f "tag:interop-$TYPE" -f "tag:interop-$COMPONENT"  discover -v
    - echo "Slicing SLICE_TOTAL=$SLICES SLICE_ID=$SLICEID"
    - echo "Run the tests:"
    - tmt run -a -e "SLICE_TOTAL=$SLICES" -e "SLICE_ID=$SLICEID" plans -n interop tests -f "tag:interop-gnutls" -f "tag:interop-$TYPE" -f "tag:interop-$COMPONENT" provision -h local execute -h tmt --interactive

fedora-SSL-3.0/build:
  extends:
    - .build
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - update-crypto-policies --set LEGACY
    - dash ./configure --disable-tls13-interop --disable-gcc-warnings --cache-file $CCACHE_FILE --enable-sha1-support --enable-ssl3-support --enable-seccomp-tests --disable-doc --disable-strict-der-time --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    # build tests, but don't execute them
    - make -j$BUILDJOBS check TESTS=""

fedora-SSL-3.0/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-SSL-3.0/build
  needs:
    - fedora-SSL-3.0/build

fedora-FIPS140-2/build:
  extends:
    - .build
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - dash ./configure --disable-gcc-warnings --cache-file $CCACHE_FILE --disable-non-suiteb-curves --enable-fips140-mode --disable-doc --disable-full-test-suite --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    # build tests, but don't execute them
    - GNUTLS_FORCE_FIPS_MODE=1 make -j$BUILDJOBS check TESTS=""

fedora-FIPS140-2/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-FIPS140-2/build
  needs:
    - fedora-FIPS140-2/build
  script:
    - GNUTLS_FORCE_FIPS_MODE=1 make -j$CHECKJOBS check

fedora-ktls/build:
  extends:
    - .build
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - dash ./configure --disable-gcc-warnings --cache-file $CCACHE_FILE --disable-non-suiteb-curves --enable-ktls --disable-doc --disable-full-test-suite --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    # build tests, but don't execute them
    - make -j$BUILDJOBS check TESTS=""

fedora-ktls/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-ktls/build
  needs:
    - fedora-ktls/build
  script:
    - |
      cat > /etc/crypto-policies/local.d/gnutls-ktls.config <<EOF
      [global]
      ktls = true
      EOF
      update-crypto-policies
    - make -j$CHECKJOBS check

.fedora-nettle/build:
  extends:
    - .build
    - .fedora-nettle
  needs:
    - fedora/bootstrap
  script:
    - git clone --depth 1 --branch master https://gitlab.com/gnutls/nettle.git nettle-git
    - pushd nettle-git
    - ./.bootstrap
    - ./configure --disable-documentation --prefix=${PWD}/$NETTLE_DIR $NETTLE_CONFIGURE_ARGS
    - make -j$BUILDJOBS
    - make -j$BUILDJOBS install
    - popd
    - PKG_CONFIG_PATH=${PWD}/nettle-git/$NETTLE_DIR/lib64/pkgconfig dash ./configure --disable-gcc-warnings --disable-full-test-suite --disable-doc --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    - make -j$BUILDJOBS check TESTS=""

.fedora-nettle/test:
  extends:
    - .test
    - .fedora-nettle

fedora-nettle/build:
  extends:
    - .fedora-nettle/build
  variables:
    NETTLE_CONFIGURE_ARGS: ""

fedora-nettle/test:
  extends:
    - .fedora-nettle/test
  dependencies:
    - fedora-nettle/build
  needs:
    - fedora-nettle/build
  script:
    - PKG_CONFIG_PATH=${PWD}/nettle-git/$NETTLE_DIR/lib64/pkgconfig LD_LIBRARY_PATH=${PWD}/nettle-git/$NETTLE_DIR/lib64 make -j$CHECKJOBS check

fedora-nettle-minigmp/build:
  extends:
    - .fedora-nettle/build
  variables:
    NETTLE_CONFIGURE_ARGS: "--enable-mini-gmp"

fedora-nettle-minigmp/test:
  extends:
    - .fedora-nettle/test
  dependencies:
    - fedora-nettle-minigmp/build
  needs:
    - fedora-nettle-minigmp/build
  script:
    # prolong timeout a bit as minigmp build is slow
    - PKG_CONFIG_PATH=${PWD}/nettle-git/$NETTLE_DIR/lib64/pkgconfig LD_LIBRARY_PATH=${PWD}/nettle-git/$NETTLE_DIR/lib64 GNUTLS_TEST_TIMEOUT=600000 make -j$CHECKJOBS check
  timeout: 3h

fedora-threadsan/build:
  extends:
    - .build
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - CFLAGS="-fsanitize=thread -g -O2" CXXFLAGS=$CFLAGS
      dash ./configure --disable-gcc-warnings --disable-doc --cache-file $CCACHE_FILE --disable-non-suiteb-curves --enable-fips140-mode --disable-full-test-suite --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    - make -j$BUILDJOBS -C tests check SUBDIRS=. TESTS="" TSAN_OPTIONS="suppressions=$(pwd)/devel/tsan.supp" GNUTLS_SKIP_FIPS_INTEGRITY_CHECKS=1 GNUTLS_FORCE_FIPS_MODE=1

fedora-threadsan/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-threadsan/build
  needs:
    - fedora-threadsan/build
  script:
    - make -j$CHECKJOBS -C tests check SUBDIRS=. TESTS="tls-pthread dtls-pthread fips-mode-pthread rng-pthread" TSAN_OPTIONS="suppressions=$(pwd)/devel/tsan.supp" GNUTLS_SKIP_FIPS_INTEGRITY_CHECKS=1 GNUTLS_FORCE_FIPS_MODE=1

fedora-static-analyzers/build:
  extends:
    - .build
    - .fedora
  needs:
    - fedora/bootstrap
  #TODO originally, before_script was set to "/bin/true".. is there a reason not to create the cache?
  script:
    - scan-build ./configure --cache-file $CCACHE_FILE --disable-doc --enable-fips140-mode --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS syntax-check gnulib_dir=$GNULIB_SRCDIR
    - make -j$BUILDJOBS -C gl
    - scan-build --status-bugs -o scan-build-lib make -j$BUILDJOBS -C lib
    - scan-build --status-bugs -o scan-build-lib make -j$BUILDJOBS -C libdane
    - make -j$BUILDJOBS -C src/gl
    - scan-build --status-bugs -o scan-build-lib make -j$BUILDJOBS -C src
  #TODO originally, after_script was set to "/bin/true".. is there a reason not to create the cache?

fedora-static-analyzers/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-static-analyzers/build
  needs:
    - fedora-static-analyzers/build
  cache:
    paths:
      - cache/cppcheck
  script:
    - mkdir -p cache/cppcheck
    - cppcheck --cppcheck-build-dir=cache/cppcheck --force -q -Ilib/includes -Igl/ -Ilib/ -I. --error-exitcode=1 lib/ -i lib/unistring -i lib/minitasn1 -i lib/nettle/backport -i lib/nettle/ecc -j2 $CPPCHECK_OPTIONS
    - cppcheck --cppcheck-build-dir=cache/cppcheck --force -q -Ilib/includes -Igl/ -Ilibdane/ -I. --error-exitcode=1 libdane/ -j2 $CPPCHECK_OPTIONS
  timeout: 3h

# TODO this does not work, so we keep using old job doc-dist.Fedora
# Keeping it here until I figure it out.
#fedora-docdist/build:
#  extends:
#    - .build
#    - .fedora
#  script:
#    - SUBMODULE_NOFETCH=1 ./bootstrap
#    - CFLAGS="-std=c99 -O2 -g" dash ./configure --disable-gcc-warnings --cache-file $CCACHE_FILE --prefix=/usr --libdir=/usr/lib64 --disable-cxx --disable-non-suiteb-curves --enable-gtk-doc --disable-maintainer-mode
#    - make -j$BUILDJOBS -C doc stamp-vti
#    - make -j$BUILDJOBS -C doc stamp_enums
#    - make -j$BUILDJOBS
#    - make -j$BUILDJOBS -C doc gnutls.html
#    - make -j$BUILDJOBS -C doc/latex gnutls.pdf
#    - DB2EPUBDIR=$(dirname $(find /usr/share/sgml/docbook/xsl-ns-stylesheets-*/epub/bin/ -name dbtoepub -print))
#    - PATH="$PATH:$DB2EPUBDIR" make -C doc gnutls.epub
#  # we don't throw away intermediate compilation results as /test job does some compiling, too
#  artifacts:
#    expire_in: 1 day
#    paths:
#      - ./
#    exclude:
#      - .git/ # passing forward .git causes warnings and possibly problems
#      - ./**/.git/ # passing forward .git causes warnings and possibly problems
#
#fedora-docdist/test:
#  extends:
#    - .test
#    - .fedora
#  dependencies:
#    - fedora-docdist/build
#  needs:
#    - fedora-docdist/build
#  script: # shall we separate it to two jobs?
#    - export CFLAGS="-std=c99 -O2 -g"
#    - DB2EPUBDIR=$(dirname $(find /usr/share/sgml/docbook/xsl-ns-stylesheets-*/epub/bin/ -name dbtoepub -print))
#    - PATH="$PATH:$DB2EPUBDIR" make -C doc gnutls.epub
#    - make -j$CHECKJOBS distcheck

fedora-abicoverage/build:
  extends:
    - .build
    - .fedora
  needs:
    - fedora/bootstrap
  script:
    - CFLAGS="-g -Og" dash ./configure --disable-gcc-warnings --cache-file $CCACHE_FILE  --prefix=/usr --libdir=/usr/lib64 --enable-code-coverage --disable-maintainer-mode --disable-doc --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    - make -j$BUILDJOBS check TESTS=""
  tags:
    - shared
    - linux
  except:
    - tags

fedora-abicoverage/test:
  extends:
    - .test
    - .fedora
  dependencies:
    - fedora-abicoverage/build
  needs:
    - fedora-abicoverage/build
  script:
    - make abi-check
    - make pic-check
    - make -j$CHECKJOBS check
    - make local-code-coverage-output || true
    - if objdump -R lib/.libs/libgnutls.so | grep INTERNAL ; then false ; fi
  artifacts:
    expire_in: 1 week
    when: on_failure
    paths:
      - ./*.xml
      - ./*.log
      - ./**/*.log
      - gnutls-prev-abi.tmp/
      - compat_reports/

##############################################################################
########################### Debian pipelines #################################
##############################################################################

debian/bootstrap:
  extends:
    - .bootstrap
    - .debian

debian/build:
  extends:
    - .build
    - .debian
  needs:
    - debian/bootstrap
  script:
    - dash ./configure --enable-oldgnutls-interop --disable-gcc-warnings --cache-file $CCACHE_FILE --disable-doc --with-pkcs12-iter-count=10000 LDFLAGS='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now'
    - make -j$BUILDJOBS
    - make -j$BUILDJOBS check TESTS=""

debian/test:
  extends:
    - .test
    - .debian
  dependencies:
    - debian/build
  needs:
    - debian/build

.debian-cross/build:
  extends:
    - .build
  script:
    - build=$(dpkg-architecture -qDEB_HOST_GNU_TYPE)
    - host=$(echo $CI_JOB_NAME |cut -d/ -f2)
    - echo "host is $host"
    # not setting CC_FOR_BUILD paired with qemu-user/binfmt somehow causes
    # config.guess to detect the target as the build platform and not activate
    # cross-compile mode even though --build is given
    - export CC_FOR_BUILD="ccache gcc"
    - export CC="ccache $host-gcc"
    # Debian's softhsm package is not multiarch yet. Missing softhsm libraries
    # for the target will cause the test suite to fail when p11-kit is enabled.
    - dash ./configure --build=$build --host=$host --disable-gcc-warnings
        --cache-file $CCACHE_FILE --disable-doc
        --without-p11-kit --disable-full-test-suite
        --with-pkcs12-iter-count=10000
    - make -j$BUILDJOBS
    # build tests, but don't execute them
    - make -j$BUILDJOBS check TESTS=""
  tags:
    - shared
    - docker
    - linux

.debian-cross/test:
  extends:
    - .test
  script:
    - make pic-check
    # Parallel tests cause random failures, likely timing errors
    - make -j1 check
  tags:
    - shared
    - docker
    - linux

debian-cross-i686/bootstrap:
  extends:
    - .bootstrap
    - .debian-cross-i686

debian-cross/i686-linux-gnu/build: # name is important, see .debian-cross/build
  extends:
    - .debian-cross/build
    - .debian-cross-i686
  needs:
    - debian-cross-i686/bootstrap

debian-cross/i686-linux-gnu/test:
  extends:
    - .debian-cross/test
    - .debian-cross-i686
  dependencies:
    - debian-cross/i686-linux-gnu/build
  needs:
    - debian-cross/i686-linux-gnu/build

debian-cross-other/bootstrap:
  extends:
    - .bootstrap
    - .debian-cross-other

debian-cross/arm-linux-gnueabihf/build: # name is important, see .debian-cross/build
  extends:
    - .debian-cross/build
    - .debian-cross-other
  needs:
    - debian-cross-other/bootstrap

debian-cross/arm-linux-gnueabihf/test:
  extends:
    - .debian-cross/test
    - .debian-cross-other
  dependencies:
    - debian-cross/arm-linux-gnueabihf/build
  needs:
    - debian-cross/arm-linux-gnueabihf/build
  timeout: 2h

debian-cross/aarch64-linux-gnu/build: # name is important, see .debian-cross/build
  extends:
    - .debian-cross/build
    - .debian-cross-other
  needs:
    - debian-cross-other/bootstrap

debian-cross/aarch64-linux-gnu/test:
  extends:
    - .debian-cross/test
    - .debian-cross-other
  dependencies:
    - debian-cross/aarch64-linux-gnu/build
  needs:
    - debian-cross/aarch64-linux-gnu/build
  timeout: 2h
  allow_failure: true

##############################################################################
########################### MinGW pipelines ##################################
##############################################################################

.mingw/build:
  extends:
    - .build
  script:
#    - mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc
#    - echo ':DOSWin:M::MZ::/usr/bin/wine:' > /proc/sys/fs/binfmt_misc/register
    - dash ./configure --disable-gcc-warnings --host=${arch_name}-w64-mingw32 --target=${arch_name}-w64-mingw32 --cache-file $CCACHE_FILE --with-included-libtasn1 --disable-nls --with-included-unistring --disable-non-suiteb-curves --disable-full-test-suite --disable-doc --with-pkcs12-iter-count=10000
    - mingw${arch_bits}-make -j$BUILDJOBS
    # https://bugzilla.redhat.com/show_bug.cgi?id=2049401
    - mingw${arch_bits}-make -j$BUILDJOBS -C $PWD/tests check TESTS=""

.mingw/test:
  extends:
    - .test
  script:
    # https://bugzilla.redhat.com/show_bug.cgi?id=2049401
    - mingw${arch_bits}-make -j$CHECKJOBS -C $PWD/tests check
  timeout: 3h

.mingw/archive:
  stage: archive
#  TODO this should be here, but I want to see if it works without tagging
#  only:
#    - tags
  script:
    # Combine generated apps and DLLs.
    #libwinpthread is required by libgcc
    #libffi is required by libp11-kit
    - mkdir -p win${arch_bits}-build/bin win${arch_bits}-build/lib/includes
    - cp lib/.libs/*.dll src/.libs/*.exe win${arch_bits}-build/bin
    - ${arch_name}-w64-mingw32-strip --strip-unneeded win${arch_bits}-build/bin/*.dll
    - ${arch_name}-w64-mingw32-strip win${arch_bits}-build/bin/*.exe
    - cp /usr/${arch_name}-w64-mingw32/sys-root/mingw/bin/libp11-*.dll win${arch_bits}-build/bin
    - cp /usr/${arch_name}-w64-mingw32/sys-root/mingw/bin/libnettle-*.dll win${arch_bits}-build/bin
    - cp /usr/${arch_name}-w64-mingw32/sys-root/mingw/bin/libhogweed-*.dll win${arch_bits}-build/bin
    - cp /usr/${arch_name}-w64-mingw32/sys-root/mingw/bin/libgmp-*.dll win${arch_bits}-build/bin
    - cp /usr/${arch_name}-w64-mingw32/sys-root/mingw/bin/libgcc*.dll win${arch_bits}-build/bin
    - cp /usr/${arch_name}-w64-mingw32/sys-root/mingw/bin/libwinpthread*.dll win${arch_bits}-build/bin
    - cp /usr/${arch_name}-w64-mingw32/sys-root/mingw/bin/libidn2-*.dll win${arch_bits}-build/bin
    - cp /usr/${arch_name}-w64-mingw32/sys-root/mingw/bin/libffi-*.dll win${arch_bits}-build/bin
    - cp lib/.libs/*.a lib/*.def lib/gnutls.pc win${arch_bits}-build/lib
    - cp lib/includes/gnutls/*.h win${arch_bits}-build/lib/includes
  artifacts:
    name: "${CI_PROJECT_NAME}-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
    paths:
      - win${arch_bits}-build/

mingw/bootstrap:
  extends:
    - .bootstrap
    - .mingw

mingw64/build:
  extends:
    - .mingw/build
    - .mingw64
  needs:
    - mingw/bootstrap

mingw64/test:
  extends:
    - .mingw/test
    - .mingw64
  dependencies:
    - mingw64/build
  needs:
    - mingw64/build

mingw64/archive:
  extends:
    - .mingw/archive
    - .mingw64
  dependencies:
    - mingw64/build
  needs: # archive only if tests successful
    - mingw64/build
    - mingw64/test

mingw64-vista/build:
  extends:
    - .mingw/build
    - .mingw64
    - .mingw-vista
  needs:
    - mingw/bootstrap

mingw64-vista/test:
  extends:
    - .mingw/test
    - .mingw64
    - .mingw-vista
  dependencies:
    - mingw64-vista/build
  needs:
    - mingw64-vista/build

mingw64-vista/archive:
  extends:
    - .mingw/archive
    - .mingw64
    - .mingw-vista
  dependencies:
    - mingw64-vista/build
  needs: # archive only if tests successful
    - mingw64-vista/build
    - mingw64-vista/test

mingw32/build:
  extends:
    - .mingw/build
    - .mingw32
  needs:
    - mingw/bootstrap

mingw32/test:
  extends:
    - .mingw/test
    - .mingw32
  dependencies:
    - mingw32/build
  needs:
    - mingw32/build

mingw32/archive:
  extends:
    - .mingw/archive
    - .mingw32
  dependencies:
    - mingw32/build
  needs: # archive only if tests successful
    - mingw32/build
    - mingw32/test

mingw32-vista/build:
  extends:
    - .mingw/build
    - .mingw32
    - .mingw-vista
  needs:
    - mingw/bootstrap

mingw32-vista/test:
  extends:
    - .mingw/test
    - .mingw32
    - .mingw-vista
  dependencies:
    - mingw32-vista/build
  needs:
    - mingw32-vista/build

mingw32-vista/archive:
  extends:
    - .mingw/archive
    - .mingw32
    - .mingw-vista
  dependencies:
    - mingw32-vista/build
  needs: # archive only if tests successful
    - mingw32-vista/build
    - mingw32-vista/test