• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: ubuntu-cmake
2
3on: [push, pull_request]
4
5env:
6  BUILD_TYPE: Release
7
8jobs:
9  build:
10    strategy:
11      fail-fast: false
12      matrix:
13        include:
14          # Ubuntu 22.04: Use preinstalled Clang 12.0.1, 13.0.1 and 14.0.0
15          - os: ubuntu-22.04
16            compiler: clang
17            compiler-version: 14
18            libclang-version: 14
19            pip-clang-version: "14.0"
20            ignore-errors: false
21          - os: ubuntu-22.04
22            compiler: clang
23            compiler-version: 13
24            libclang-version: 13
25            pip-clang-version: "13.0.1"
26            ignore-errors: false
27          - os: ubuntu-22.04
28            compiler: clang
29            compiler-version: 12
30            libclang-version: 12
31            pip-clang-version: "12.0.1"
32            ignore-errors: false
33          # Ubuntu 22.04: Use preinstalled GCC 9.5.0, 10.4.0, 11.3.0, 12.1.0
34          - os: ubuntu-22.04
35            compiler: gcc
36            compiler-version: 12
37            libclang-version: 14
38            pip-clang-version: "14.0"
39            ignore-errors: false
40          - os: ubuntu-22.04
41            compiler: gcc
42            compiler-version: 11
43            libclang-version: 14
44            pip-clang-version: "14.0"
45            ignore-errors: false
46          - os: ubuntu-22.04
47            compiler: gcc
48            compiler-version: 10
49            libclang-version: 14
50            pip-clang-version: "14.0"
51            ignore-errors: false
52          - os: ubuntu-22.04
53            compiler: gcc
54            compiler-version: 9
55            libclang-version: 14
56            pip-clang-version: "14.0"
57            ignore-errors: false
58          # Ubuntu 20.04
59          - os: ubuntu-20.04
60            compiler: gcc
61            compiler-version: 8
62            libclang-version: 12
63            pip-clang-version: "12.0.1"
64            ignore-errors: false
65          - os: ubuntu-20.04
66            compiler: gcc
67            compiler-version: 7
68            libclang-version: 12
69            pip-clang-version: "12.0.1"
70            ignore-errors: true  # GCC 7 is best effort
71    runs-on: ${{ matrix.os }}
72    continue-on-error: ${{ matrix.ignore-errors }}
73
74    steps:
75    - uses: actions/checkout@v3
76
77    - name: Cache dependencies
78      uses: actions/cache@v3
79      with:
80        key: ${{matrix.os}}-${{matrix.compiler}}${{matrix.compiler-version}}
81        path: |
82          ${{github.workspace}}/build/_deps
83
84    - name: Install ninja-build tool
85      uses: turtlesec-no/get-ninja@1.1.0
86
87    - name: Install/configure Clang compiler toolchain
88      if: matrix.compiler == 'clang'
89      run: |
90        sudo apt-get install -qy \
91          clang-${{matrix.compiler-version}} \
92          libclang1-${{matrix.libclang-version}}
93        echo "CXX=clang++-${{matrix.compiler-version}}" >> $GITHUB_ENV
94        echo "CC=clang-${{matrix.compiler-version}}" >> $GITHUB_ENV
95
96    - name: Install/configure GCC compiler toolchain
97      if: matrix.compiler == 'gcc'
98      run: |
99        sudo apt-get install -qy \
100          g++-${{matrix.compiler-version}} \
101          libclang1-${{matrix.libclang-version}}
102        echo "CXX=g++-${{matrix.compiler-version}}" >> $GITHUB_ENV
103        echo "CC=gcc-${{matrix.compiler-version}}" >> $GITHUB_ENV
104
105    - name: Create Build Environment
106      run: |
107        pip3 install absl-py clang==${{matrix.pip-clang-version}}
108        mkdir -p "$GITHUB_WORKSPACE/build"
109
110    - name: Configure CMake
111      run: |
112        cmake \
113          -S $GITHUB_WORKSPACE \
114          -B $GITHUB_WORKSPACE/build \
115          -G Ninja \
116          -DCMAKE_BUILD_TYPE=$BUILD_TYPE
117
118    - name: Build
119      run: |
120        cmake \
121          --build $GITHUB_WORKSPACE/build \
122          --config $BUILD_TYPE
123
124    - name: Test
125      run: |
126        ctest \
127          --test-dir $GITHUB_WORKSPACE/build \
128          -C $BUILD_TYPE \
129          --output-on-failure \
130          -R SapiTest
131