• 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            ignore-errors: false
20          - os: ubuntu-22.04
21            compiler: clang
22            compiler-version: 13
23            libclang-version: 13
24            ignore-errors: false
25          - os: ubuntu-22.04
26            compiler: clang
27            compiler-version: 12
28            libclang-version: 12
29            ignore-errors: false
30          # Ubuntu 22.04: Use preinstalled GCC 9.5.0, 10.4.0, 11.3.0, 12.1.0
31          - os: ubuntu-22.04
32            compiler: gcc
33            compiler-version: 12
34            libclang-version: 14
35            ignore-errors: false
36          - os: ubuntu-22.04
37            compiler: gcc
38            compiler-version: 11
39            libclang-version: 14
40            ignore-errors: false
41          - os: ubuntu-22.04
42            compiler: gcc
43            compiler-version: 10
44            libclang-version: 14
45            ignore-errors: false
46          - os: ubuntu-22.04
47            compiler: gcc
48            compiler-version: 9
49            libclang-version: 14
50            ignore-errors: false
51          # Ubuntu 20.04
52          - os: ubuntu-20.04
53            compiler: gcc
54            compiler-version: 8
55            libclang-version: 12
56            ignore-errors: false
57    runs-on: ${{ matrix.os }}
58    continue-on-error: ${{ matrix.ignore-errors }}
59
60    steps:
61    - uses: actions/checkout@v3
62
63    - name: Cache dependencies
64      uses: actions/cache@v3
65      with:
66        key: ${{matrix.os}}-${{matrix.compiler}}${{matrix.compiler-version}}
67        path: |
68          ${{github.workspace}}/build/_deps
69
70    - name: Install ninja-build tool
71      uses: turtlesec-no/get-ninja@1.1.0
72
73    - name: Install/configure Clang compiler toolchain
74      if: matrix.compiler == 'clang'
75      run: |
76        sudo apt-get install -qy \
77          clang-${{matrix.compiler-version}} \
78          libclang1-${{matrix.libclang-version}} \
79          python3-clang-${{matrix.libclang-version}}
80        echo "CXX=clang++-${{matrix.compiler-version}}" >> $GITHUB_ENV
81        echo "CC=clang-${{matrix.compiler-version}}" >> $GITHUB_ENV
82
83    - name: Install/configure GCC compiler toolchain
84      if: matrix.compiler == 'gcc'
85      run: |
86        sudo apt-get install -qy \
87          g++-${{matrix.compiler-version}} \
88          libclang1-${{matrix.libclang-version}} \
89          python3-clang-${{matrix.libclang-version}}
90        echo "CXX=g++-${{matrix.compiler-version}}" >> $GITHUB_ENV
91        echo "CC=gcc-${{matrix.compiler-version}}" >> $GITHUB_ENV
92
93    - name: Create Build Environment
94      run: |
95        pip3 install absl-py
96        mkdir -p "$GITHUB_WORKSPACE/build"
97
98    - name: Configure CMake
99      run: |
100        cmake \
101          -S $GITHUB_WORKSPACE \
102          -B $GITHUB_WORKSPACE/build \
103          -G Ninja \
104          -DCMAKE_BUILD_TYPE=$BUILD_TYPE
105
106    - name: Build
107      run: |
108        cmake \
109          --build $GITHUB_WORKSPACE/build \
110          --config $BUILD_TYPE
111
112    - name: Test
113      run: |
114        ctest \
115          --test-dir $GITHUB_WORKSPACE/build \
116          -C $BUILD_TYPE \
117          --output-on-failure \
118          -R SapiTest
119