Add CI-only tests to workflow files
[openssl.git] / .github / workflows / ci.yml
1 # Copyright 2021-2023 The OpenSSL Project Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License 2.0 (the "License").  You may not use
4 # this file except in compliance with the License.  You can obtain a copy
5 # in the file LICENSE in the source distribution or at
6 # https://www.openssl.org/source/license.html
7
8 name: GitHub CI
9
10 on: [pull_request, push]
11
12 # for some reason, this does not work:
13 # variables:
14 #   BUILDOPTS: "-j4"
15 #   HARNESS_JOBS: "${HARNESS_JOBS:-4}"
16
17 # for some reason, this does not work:
18 # before_script:
19 #     - make="make -s"
20
21 permissions:
22   contents: read
23
24 env:
25   RUN_CI_TESTS: 1
26
27 jobs:
28   check_update:
29     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
30     steps:
31     - name: install unifdef
32       run: |
33         sudo apt-get update
34         sudo apt-get -yq --no-install-suggests --no-install-recommends --force-yes install unifdef
35     - uses: actions/checkout@v4
36       with:
37         fetch-depth: 0
38     - name: config
39       run: ./config --banner=Configured --strict-warnings enable-fips && perl configdata.pm --dump
40     - name: make build_generated
41       run: make -s build_generated
42     - name: make update
43       run: make update
44     - name: git diff
45       run: git diff --exit-code
46
47   check_docs:
48     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
49     steps:
50     - uses: actions/checkout@v4
51     - name: config
52       run: ./config --banner=Configured --strict-warnings enable-fips && perl configdata.pm --dump
53     - name: make build_generated
54       run: make -s build_generated
55     - name: make doc-nits
56       run: make doc-nits
57     - name: make help
58       run: make help
59     - name: make md-nits
60       run: |
61           sudo gem install mdl
62           make md-nits
63
64   # This checks that we use ANSI C language syntax and semantics.
65   # We are not as strict with libraries, but rather adapt to what's
66   # expected to be available in a certain version of each platform.
67   check-ansi:
68     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
69     steps:
70     - uses: actions/checkout@v4
71     - name: config
72       run: CPPFLAGS=-ansi ./config --banner=Configured no-asm no-makedepend enable-buildtest-c++ enable-fips --strict-warnings -D_DEFAULT_SOURCE && perl configdata.pm --dump
73     - name: make
74       run: make -s -j4
75
76   basic_gcc:
77     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
78     steps:
79     - uses: actions/checkout@v4
80     - name: checkout fuzz/corpora submodule
81       run: git submodule update --init --depth 1 fuzz/corpora
82     - name: localegen
83       run: sudo locale-gen tr_TR.UTF-8
84     - name: config
85       # enable-quic is on by default, but we leave it here to check we're testing the explicit enable somewhere
86       run: CC=gcc ./config --banner=Configured enable-fips enable-quic enable-unstable-qlog --strict-warnings && perl configdata.pm --dump
87     - name: make
88       run: make -s -j4
89     - name: get cpu info
90       run: |
91         cat /proc/cpuinfo
92         ./util/opensslwrap.sh version -c
93     - name: make test
94       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
95
96   basic_clang:
97     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
98     steps:
99     - uses: actions/checkout@v4
100     - name: checkout fuzz/corpora submodule
101       run: git submodule update --init --depth 1 fuzz/corpora
102     - name: config
103       run: CC=clang ./config --banner=Configured no-fips enable-unstable-qlog --strict-warnings && perl configdata.pm --dump
104     - name: make
105       run: make -s -j4
106     - name: get cpu info
107       run: |
108         cat /proc/cpuinfo
109         ./util/opensslwrap.sh version -c
110     - name: make test
111       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
112
113   self-hosted:
114     strategy:
115       matrix:
116         os: [freebsd-13.2, ubuntu-arm64-22.04]
117     runs-on: ${{ matrix.os }}-self-hosted
118     continue-on-error: true
119     steps:
120     - uses: actions/checkout@v4
121     - name: config
122       run: ./config enable-fips enable-ec_nistp_64_gcc_128 enable-md2 enable-rc5 enable-ssl3 enable-ssl3-method enable-trace enable-unstable-qlog
123     - name: config dump
124       run: ./configdata.pm --dump
125     - name: make
126       run: make -j4
127     - name: get cpu info
128       run: ./util/opensslwrap.sh version -c
129     - name: make test
130       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
131
132   minimal:
133     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
134     steps:
135     - uses: actions/checkout@v4
136     - name: checkout fuzz/corpora submodule
137       run: git submodule update --init --depth 1 fuzz/corpora
138     - name: config
139       run: ./config --banner=Configured --strict-warnings no-bulk no-pic no-asm enable-unstable-qlog -DOPENSSL_NO_SECURE_MEMORY -DOPENSSL_SMALL_FOOTPRINT && perl configdata.pm --dump
140     - name: make
141       run: make -j4 # verbose, so no -s here
142     - name: get cpu info
143       run: |
144         cat /proc/cpuinfo
145         ./util/opensslwrap.sh version -c
146     - name: make test
147       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
148
149   no-deprecated:
150     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
151     steps:
152     - uses: actions/checkout@v4
153     - name: checkout fuzz/corpora submodule
154       run: git submodule update --init --depth 1 fuzz/corpora
155     - name: config
156       run: ./config --banner=Configured --strict-warnings no-deprecated enable-fips enable-unstable-qlog && perl configdata.pm --dump
157     - name: make
158       run: make -s -j4
159     - name: get cpu info
160       run: |
161         cat /proc/cpuinfo
162         ./util/opensslwrap.sh version -c
163     - name: make test
164       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
165
166   no-shared-ubuntu:
167     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
168     steps:
169     - uses: actions/checkout@v4
170     - name: checkout fuzz/corpora submodule
171       run: git submodule update --init --depth 1 fuzz/corpora
172     - name: config
173       run: ./config --banner=Configured --strict-warnings no-shared no-fips enable-unstable-qlog && perl configdata.pm --dump
174     - name: make
175       run: make -s -j4
176     - name: get cpu info
177       run: |
178         cat /proc/cpuinfo
179         ./util/opensslwrap.sh version -c
180     - name: make test
181       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
182
183   no-shared-macos:
184     runs-on: macos-latest
185     if: github.server_url == 'https://github.com'
186     steps:
187     - uses: actions/checkout@v4
188     - name: checkout fuzz/corpora submodule
189       run: git submodule update --init --depth 1 fuzz/corpora
190     - name: config
191       run: ./config --banner=Configured --strict-warnings no-shared no-fips enable-unstable-qlog && perl configdata.pm --dump
192     - name: make
193       run: make -s -j4
194     - name: get cpu info
195       run: |
196         sysctl machdep.cpu
197         ./util/opensslwrap.sh version -c
198     - name: make test
199       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
200
201   non-caching:
202     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
203     steps:
204     - uses: actions/checkout@v4
205     - name: checkout fuzz/corpora submodule
206       run: git submodule update --init --depth 1 fuzz/corpora
207     - name: config
208       run: ./config --banner=Configured --debug enable-asan enable-ubsan no-cached-fetch no-fips no-dtls no-tls1 no-tls1-method no-tls1_1 no-tls1_1-method no-async enable-unstable-qlog && perl configdata.pm --dump
209     - name: make
210       run: make -s -j4
211     - name: get cpu info
212       run: |
213         cat /proc/cpuinfo
214         ./util/opensslwrap.sh version -c
215     - name: make test
216       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4} OPENSSL_TEST_RAND_ORDER=0 TESTS="-test_fuzz* -test_ssl_* -test_sslapi -test_evp -test_cmp_http -test_verify -test_cms -test_store -test_enc -[01][0-9]"
217
218   address_ub_sanitizer:
219     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
220     steps:
221     - uses: actions/checkout@v4
222     - name: checkout fuzz/corpora submodule
223       run: git submodule update --init --depth 1 fuzz/corpora
224     - name: config
225       run: ./config --banner=Configured --debug enable-asan enable-ubsan enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-fips enable-unstable-qlog && perl configdata.pm --dump
226     - name: make
227       run: make -s -j4
228     - name: get cpu info
229       run: |
230         cat /proc/cpuinfo
231         ./util/opensslwrap.sh version -c
232     - name: make test
233       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4} OPENSSL_TEST_RAND_ORDER=0
234
235   fuzz_tests:
236     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
237     steps:
238     - uses: actions/checkout@v4
239     - name: checkout fuzz/corpora submodule
240       run: git submodule update --init --depth 1 fuzz/corpora
241     - name: config
242       run: ./config --banner=Configured --debug -DPEDANTIC -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION enable-asan enable-ubsan enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-weak-ssl-ciphers enable-ssl3 enable-ssl3-method enable-nextprotoneg enable-unstable-qlog && perl configdata.pm --dump
243     - name: make
244       run: make -s -j4
245     - name: get cpu info
246       run: |
247         cat /proc/cpuinfo
248         ./util/opensslwrap.sh version -c
249     - name: make test
250       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4} OPENSSL_TEST_RAND_ORDER=0 TESTS="test_fuzz*"
251
252   memory_sanitizer:
253     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
254     steps:
255     - uses: actions/checkout@v4
256     - name: checkout fuzz/corpora submodule
257       run: git submodule update --init --depth 1 fuzz/corpora
258     - name: config
259       # --debug -O1 is to produce a debug build that runs in a reasonable amount of time
260       run: CC=clang ./config --banner=Configured --debug -O1 -fsanitize=memory -DOSSL_SANITIZE_MEMORY -fno-optimize-sibling-calls enable-rc5 enable-md2 enable-ec_nistp_64_gcc_128 enable-fips enable-unstable-qlog && perl configdata.pm --dump
261     - name: make
262       run: make -s -j4
263     - name: get cpu info
264       run: |
265         cat /proc/cpuinfo
266         ./util/opensslwrap.sh version -c
267     - name: make test
268       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4} OPENSSL_TEST_RAND_ORDER=0
269
270   threads_sanitizer:
271     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
272     steps:
273     - uses: actions/checkout@v4
274     - name: checkout fuzz/corpora submodule
275       run: git submodule update --init --depth 1 fuzz/corpora
276     - name: config
277       run: CC=clang ./config --banner=Configured no-fips enable-unstable-qlog --strict-warnings -fsanitize=thread && perl configdata.pm --dump
278     - name: make
279       run: make -s -j4
280     - name: get cpu info
281       run: |
282         cat /proc/cpuinfo
283         ./util/opensslwrap.sh version -c
284     - name: make test
285       run: make V=1 TESTS="test_threads test_internal_provider test_provfetch test_provider test_pbe test_evp_kdf test_pkcs12 test_store test_evp test_quic*" test HARNESS_JOBS=${HARNESS_JOBS:-4}
286
287   enable_non-default_options:
288     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
289     steps:
290     - uses: actions/checkout@v4
291     - name: checkout fuzz/corpora submodule
292       run: git submodule update --init --depth 1 fuzz/corpora
293     - name: modprobe tls
294       run: sudo modprobe tls
295     - name: config
296       run: ./config --banner=Configured --strict-warnings no-ec enable-ssl-trace enable-zlib enable-zlib-dynamic enable-crypto-mdebug enable-egd enable-ktls enable-fips no-threads enable-unstable-qlog && perl configdata.pm --dump
297     - name: make
298       run: make -s -j4
299     - name: get cpu info
300       run: |
301         cat /proc/cpuinfo
302         ./util/opensslwrap.sh version -c
303     - name: make test
304       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
305
306   full_featured:
307     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
308     steps:
309     - uses: actions/checkout@v4
310     - name: checkout fuzz/corpora submodule
311       run: git submodule update --init --depth 1 fuzz/corpora
312     - name: modprobe tls
313       run: sudo modprobe tls
314     - name: Enable sctp
315       run: sudo modprobe sctp
316     - name: Enable auth in sctp
317       run: sudo sysctl -w net.sctp.auth_enable=1 
318     - name: install extra config support
319       run: sudo apt-get -y install libsctp-dev abigail-tools libzstd-dev zstd
320     - name: config
321       run: ./config --banner=Configured --strict-warnings enable-ktls enable-fips enable-egd enable-ec_nistp_64_gcc_128 enable-md2 enable-rc5 enable-sctp enable-ssl3 enable-ssl3-method enable-trace enable-zlib enable-zstd enable-unstable-qlog && perl configdata.pm --dump
322     - name: make
323       run: make -s -j4
324     - name: get cpu info
325       run: |
326         cat /proc/cpuinfo
327         ./util/opensslwrap.sh version -c
328     - name: make test
329       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
330
331   no-legacy:
332     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
333     steps:
334     - uses: actions/checkout@v4
335     - name: checkout fuzz/corpora submodule
336       run: git submodule update --init --depth 1 fuzz/corpora
337     - name: config
338       run: ./config --banner=Configured --strict-warnings no-legacy enable-fips enable-unstable-qlog && perl configdata.pm --dump
339     - name: make
340       run: make -s -j4
341     - name: get cpu info
342       run: |
343         cat /proc/cpuinfo
344         ./util/opensslwrap.sh version -c
345     - name: make test
346       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
347
348   legacy:
349     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
350     steps:
351     - uses: actions/checkout@v4
352     - name: checkout fuzz/corpora submodule
353       run: git submodule update --init --depth 1 fuzz/corpora
354     - name: config
355       run: ./config --banner=Configured -Werror --debug no-afalgeng no-shared enable-crypto-mdebug enable-rc5 enable-md2 enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers enable-zlib enable-ec_nistp_64_gcc_128 no-fips enable-unstable-qlog && perl configdata.pm --dump
356     - name: make
357       run: make -s -j4
358     - name: get cpu info
359       run: |
360         cat /proc/cpuinfo
361         ./util/opensslwrap.sh version -c
362     - name: make test
363       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
364
365   # out-of-source-and-install checks multiple things at the same time:
366   # - That building, testing and installing works from an out-of-source
367   #   build tree
368   # - That building, testing and installing works with a read-only source
369   #   tree
370   out-of-readonly-source-and-install-ubuntu:
371     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
372     steps:
373     - uses: actions/checkout@v4
374       with:
375         path: ./source
376     - name: checkout fuzz/corpora submodule
377       run: git submodule update --init --depth 1 fuzz/corpora
378       working-directory: ./source
379     - name: make source read-only
380       run: chmod -R a-w ./source
381     - name: create build and install directories
382       run: |
383         mkdir ./build
384         mkdir ./install
385     - name: config
386       run: |
387         ../source/config --banner=Configured enable-fips enable-quic enable-unstable-qlog enable-acvp-tests --strict-warnings --prefix=$(cd ../install; pwd)
388         perl configdata.pm --dump
389       working-directory: ./build
390     - name: make
391       run: make -s -j4
392       working-directory: ./build
393     - name: get cpu info
394       run: |
395         cat /proc/cpuinfo
396         ./util/opensslwrap.sh version -c
397       working-directory: ./build
398     - name: make test
399       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
400       working-directory: ./build
401     - name: make install
402       run: make install
403       working-directory: ./build
404
405   out-of-readonly-source-and-install-macos:
406     runs-on: macos-latest
407     if: github.server_url == 'https://github.com'
408     steps:
409     - uses: actions/checkout@v4
410       with:
411         path: ./source
412     - name: checkout fuzz/corpora submodule
413       run: git submodule update --init --depth 1 fuzz/corpora
414       working-directory: ./source
415     - name: make source read-only
416       run: chmod -R a-w ./source
417     - name: create build and install directories
418       run: |
419         mkdir ./build
420         mkdir ./install
421     - name: config
422       run: |
423         ../source/config --banner=Configured enable-fips enable-quic enable-unstable-qlog enable-acvp-tests --strict-warnings --prefix=$(cd ../install; pwd)
424         perl configdata.pm --dump
425       working-directory: ./build
426     - name: make
427       run: make -s -j4
428       working-directory: ./build
429     - name: get cpu info
430       run: |
431         sysctl machdep.cpu
432         ./util/opensslwrap.sh version -c
433       working-directory: ./build
434     - name: make test
435       run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
436       working-directory: ./build
437     - name: make install
438       run: make install
439       working-directory: ./build
440
441   external-tests:
442     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
443     steps:
444     - uses: actions/checkout@v4
445       with:
446         submodules: recursive
447     - name: package installs
448       run: |
449         sudo apt-get update
450         sudo apt-get -yq install bison gettext keyutils ldap-utils libldap2-dev libkeyutils-dev python3 python3-paste python3-pyrad slapd tcsh python3-virtualenv virtualenv python3-kdcproxy
451     - name: install cpanm and Test2::V0 for gost_engine testing
452       uses: perl-actions/install-with-cpanm@v1
453       with:
454         install: Test2::V0
455     - name: setup hostname workaround
456       run: sudo hostname localhost
457     - name: config
458       run: ./config --banner=Configured --strict-warnings --debug no-afalgeng enable-rc5 enable-md2 enable-ssl3 enable-ssl3-method enable-weak-ssl-ciphers enable-zlib enable-ec_nistp_64_gcc_128 enable-external-tests no-fips && perl configdata.pm --dump
459     - name: make
460       run: make -s -j4
461     - name: get cpu info
462       run: |
463         cat /proc/cpuinfo
464         ./util/opensslwrap.sh version -c
465     - name: test external gost-engine
466       run: make test TESTS="test_external_gost_engine"
467     - name: test external krb5
468       run: make test TESTS="test_external_krb5"
469     - name: test external_tlsfuzzer
470       run: make test TESTS="test_external_tlsfuzzer"
471     - name: test external oqs-provider
472       run: make test TESTS="test_external_oqsprovider"
473
474   external-test-pyca:
475     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
476     strategy:
477       matrix:
478         RUST:
479           - 1.51.0
480         PYTHON:
481           - 3.9
482     steps:
483     - uses: actions/checkout@v4
484       with:
485         submodules: recursive
486     - name: Configure OpenSSL
487       run: ./config --banner=Configured --strict-warnings --debug enable-external-tests && perl configdata.pm --dump
488     - name: make
489       run: make -s -j4
490     - name: Setup Python
491       uses: actions/setup-python@v5.0.0
492       with:
493         python-version: ${{ matrix.PYTHON }}
494     - uses: dtolnay/rust-toolchain@master
495       with:
496         toolchain: ${{ matrix.RUST }}
497     - name: get cpu info
498       run: |
499         cat /proc/cpuinfo
500         ./util/opensslwrap.sh version -c
501     - name: test external pyca
502       run: make test TESTS="test_external_pyca" VERBOSE=1
503
504   external-test-cf-quiche:
505     runs-on: ${{ github.server_url == 'https://github.com' && 'ubuntu-latest' || 'ubuntu-22.04-self-hosted' }}
506     steps:
507     - uses: actions/checkout@v4
508       with:
509         submodules: recursive
510     - name: Configure OpenSSL
511       run: ./config --banner=Configured --strict-warnings enable-external-tests && perl configdata.pm --dump
512     - name: make
513       run: make -s -j4
514     - uses: dtolnay/rust-toolchain@stable
515     - name: get cpu info
516       run: |
517         cat /proc/cpuinfo
518         ./util/opensslwrap.sh version -c
519     - name: test external Cloudflare quiche
520       run: make test TESTS="test_external_cf_quiche" VERBOSE=1