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
8name: Compiler Zoo CI
9
10on: [push]
11
12permissions:
13  contents: read
14
15jobs:
16  compiler:
17    strategy:
18      fail-fast: false
19      matrix:
20        zoo: [
21          {
22            cc: gcc-7,
23            distro: ubuntu-20.04
24          }, {
25            cc: gcc-8,
26            distro: ubuntu-20.04
27          }, {
28            cc: gcc-9,
29            distro: ubuntu-20.04
30          }, {
31            cc: gcc-10,
32            distro: ubuntu-20.04
33          }, {
34            cc: gcc-11,
35            distro: ubuntu-22.04
36          }, {
37            cc: gcc-12,
38            distro: ubuntu-22.04
39          }, {
40            cc: gcc-13,
41            distro: ubuntu-22.04,
42            gcc-ppa-name: ubuntu-toolchain-r/test
43          }, {
44            cc: clang-6.0,
45            distro: ubuntu-20.04
46          }, {
47            cc: clang-7,
48            distro: ubuntu-20.04
49          }, {
50            cc: clang-8,
51            distro: ubuntu-20.04
52          }, {
53            cc: clang-9,
54            distro: ubuntu-20.04
55          }, {
56            cc: clang-10,
57            distro: ubuntu-20.04
58          }, {
59            cc: clang-11,
60            distro: ubuntu-20.04
61          }, {
62            cc: clang-12,
63            distro: ubuntu-20.04
64          }, {
65            cc: clang-13,
66            distro: ubuntu-22.04
67          }, {
68            cc: clang-14,
69            distro: ubuntu-22.04
70          }, {
71            cc: clang-15,
72            distro: ubuntu-22.04,
73            llvm-ppa-name: jammy
74          }, {
75            cc: clang-16,
76            distro: ubuntu-22.04,
77            llvm-ppa-name: jammy
78          }, {
79            cc: clang-17,
80            distro: ubuntu-22.04,
81            llvm-ppa-name: jammy
82          }
83        ]
84    # We set per-compiler now to allow testing with both older and newer sets
85    # Often, the full range of oldest->newest compilers we want aren't available
86    # in a single version of Ubuntu.
87    runs-on: ${{ matrix.zoo.distro }}
88    steps:
89    - name: install packages
90      run: |
91        gcc_ppa_name="${{ matrix.zoo.gcc-ppa-name }}"
92        llvm_ppa_name="${{ matrix.zoo.llvm-ppa-name }}"
93
94        # In the Matrix above:
95        # - we set gcc-ppc-name if the GCC version isn't part of the Ubuntu version we're using (see https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test).
96        # - we set llvm-ppa-name if an LLVM version isn't part of the Ubuntu version we're using (see https://apt.llvm.org/).
97        # This is especially needed because even new Ubuntu LTSes aren't available
98        # until a while after release on Github Actions.
99        if [[ -n ${gcc_ppa_name} ]] ; then
100          sudo add-apt-repository ppa:ubuntu-toolchain-r/test
101          sudo apt-get update
102        elif [[ -n ${llvm_ppa_name} ]] ; then
103            wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key |\
104                gpg --dearmor |\
105                sudo tee /usr/share/keyrings/llvm-snapshot.gpg.key > /dev/null
106
107            clang_version="${{ matrix.zoo.cc }}"
108            clang_version="${clang_version/clang-}"
109
110            echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.key] http://apt.llvm.org/${{ matrix.zoo.llvm-ppa-name }}/ llvm-toolchain-${{ matrix.zoo.llvm-ppa-name }}-${clang_version} main" \
111                | sudo tee /etc/apt/sources.list.d/llvm.list
112            echo "deb-src [signed-by=/usr/share/keyrings/llvm-snapshot.gpg.key] http://apt.llvm.org/${{ matrix.zoo.llvm-ppa-name }}/ llvm-toolchain-${{ matrix.zoo.llvm-ppa-name }}-${clang_version} main" \
113                | sudo tee -a /etc/apt/sources.list.d/llvm.list
114
115            cat /etc/apt/sources.list.d/llvm.list
116        fi
117
118        sudo apt-get update
119        sudo apt-get -y install ${{ matrix.zoo.cc }}
120
121    - uses: actions/checkout@v4
122    - name: checkout fuzz/corpora submodule
123      run: git submodule update --init --depth 1 fuzz/corpora
124
125    - name: config
126      run: |
127        CC=${{ matrix.zoo.cc }} ./config --banner=Configured no-shared \
128            -Wall -Werror enable-fips --strict-warnings
129
130    - name: config dump
131      run: ./configdata.pm --dump
132    - name: make
133      run: make -s -j4
134    - name: get cpu info
135      run: |
136        cat /proc/cpuinfo
137        ./util/opensslwrap.sh version -c
138    - name: make test
139      run: make test HARNESS_JOBS=${HARNESS_JOBS:-4}
140