summaryrefslogtreecommitdiffstats
path: root/wsrep-lib/.github/workflows/build.yml
blob: 0faa76728fac357d5161c1b554761abf511a905d (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
name: Build

on:
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ${{ matrix.config.os }}
    strategy:
      fail-fast: false
      matrix:
        config:
          # GCC/G++
          - os: ubuntu-20.04
            CC: gcc
            version: "7"
            type: Debug
          - os: ubuntu-20.04
            CC: gcc
            version: "7"
            type: Release
          - os: ubuntu-20.04
            CC: gcc
            version: "8"
            type: Debug
          - os: ubuntu-20.04
            CC: gcc
            version: "8"
            type: Release
          - os: ubuntu-20.04
            CC: gcc
            version: "9"
            type: Debug
          - os: ubuntu-20.04
            CC: gcc
            version: "9"
            type: Release
          - os: ubuntu-20.04
            CC: gcc
            version: "10"
            type: Debug
          - os: ubuntu-20.04
            CC: gcc
            version: "10"
            type: Release
          - os: ubuntu-20.04
            CC: gcc
            version: "11"
            type: Debug
          - os: ubuntu-20.04
            CC: gcc
            version: "11"
            type: Release
          - os: ubuntu-22.04
            CC: gcc
            version: "12"
            type: Debug
          - os: ubuntu-22.04
            CC: gcc
            version: "12"
            type: Release
          # Clang
          - os: ubuntu-20.04
            CC: clang
            version: "6.0"
            type: Debug
          - os: ubuntu-20.04
            CC: clang
            version: "6.0"
            type: Release
          - os: ubuntu-20.04
            CC: clang
            version: "10"
            type: Debug
          - os: ubuntu-20.04
            CC: clang
            version: "10"
            type: Release
          - os: ubuntu-20.04
            CC: clang
            version: "11"
            type: Debug
          - os: ubuntu-20.04
            CC: clang
            version: "11"
            type: Release
          - os: ubuntu-20.04
            CC: clang
            version: "12"
            type: Debug
          - os: ubuntu-20.04
            CC: clang
            version: "12"
            type: Release
          - os: ubuntu-22.04
            CC: clang
            version: "13"
            type: Debug
          - os: ubuntu-22.04
            CC: clang
            version: "13"
            type: Release

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2
      with:
        submodules: "recursive"

    - name: Update packages
      run: sudo apt update

    - name: Install compiler
      run: |
        sudo apt-get install -y ${{ matrix.config.CC }}-${{ matrix.config.version }}
        if [ ${{ matrix.config.CC }} == "gcc" ]
        then
          sudo apt-get install -y g++-${{ matrix.config.version }}
        fi

    - name: Install build dependencies
      run: sudo apt-get install -y libboost-filesystem-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev ccache

    # See https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/
    - name: Prepare ccache timestamp
      id: ccache_cache_timestamp
      shell: cmake -P {0}
      run: |
        string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
        message("::set-output name=timestamp::${current_date}")

    - name: Configure ccache
      uses: actions/cache@v2
      with:
        path: ~/.ccache
        key: ${{ matrix.config.os }}-${{ matrix.config.CC }}-${{ matrix.config.version }}-${{ matrix.config.type }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
        restore-keys: ${{ matrix.config.os }}-${{ matrix.config.CC }}-${{ matrix.config.version }}-${{ matrix.config.type }}-ccache-

    - name: Create Build Environment
      run: cmake -E make_directory ${{runner.workspace}}/build

    - name: Configure CMake
      # Use a bash shell so we can use the same syntax for environment variable
      # access regardless of the host operating system
      shell: bash
      working-directory: ${{runner.workspace}}/build
      run: |
        export CC="ccache ${{ matrix.config.CC }}-${{ matrix.config.version }}"
        if [ ${{ matrix.config.CC }} == "gcc" ]
        then
          export CXX="ccache g++-${{ matrix.config.version }}"
        else
          export CXX="ccache clang++-${{ matrix.config.version }}"
        fi
        if [ ${{ matrix.config.CC }} == "gcc" ] && [ ${{ matrix.config.version }} == "4.8" ]
        then
          STRICT=OFF
          DBSIM=OFF
          TESTS_EXTRA=OFF
        elif [ ${{ matrix.config.CC }} == "gcc" ] && [ ${{ matrix.config.version }} == "5" ]
        then
          STRICT=ON
          DBSIM=ON
          TESTS_EXTRA=OFF
        else
          STRICT=ON
          DBSIM=ON
          TESTS_EXTRA=ON
        fi
        cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.config.type }} \
          -DWSREP_LIB_MAINTAINER_MODE:BOOL=ON \
          -DWSREP_LIB_STRICT_BUILD_FLAGS:BOOL=$STRICT \
          -DWSREP_LIB_WITH_DBSIM:BOOL=$DBSIM \
          -DWSREP_LIB_WITH_ASAN:BOOL=ON \
          -DWSREP_LIB_WITH_UNIT_TESTS_EXTRA:BOOL=$TESTS_EXTRA

    - name: Build
      working-directory: ${{runner.workspace}}/build
      shell: bash
      run: |
        make -j3 VERBOSE=1
        ccache -s

    - name: Test
      working-directory: ${{runner.workspace}}/build
      shell: bash
      run: ctest -C ${{ matrix.config.type }} --output-on-failure