• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: build-and-test
2
3on:
4  push:
5    branches: [ main ]
6  pull_request:
7    branches: [ main ]
8
9jobs:
10  # TODO: add 32-bit builds (g++ and clang++) for ubuntu
11  #   (requires g++-multilib and libc6:i386)
12  # TODO: add coverage build (requires lcov)
13  # TODO: add clang + libc++ builds for ubuntu
14  job:
15    name: ${{ matrix.os }}.${{ matrix.build_type }}.${{ matrix.lib }}.${{ matrix.compiler }}
16    runs-on: ${{ matrix.os }}
17    strategy:
18      fail-fast: false
19      matrix:
20        os: [ubuntu-22.04, ubuntu-20.04, macos-latest]
21        build_type: ['Release', 'Debug']
22        compiler: ['g++', 'clang++']
23        lib: ['shared', 'static']
24
25    steps:
26      - uses: actions/checkout@v3
27
28      - uses: lukka/get-cmake@latest
29
30      - name: create build environment
31        run: cmake -E make_directory ${{ runner.workspace }}/_build
32
33      - name: setup cmake initial cache
34        run: touch compiler-cache.cmake
35
36      - name: configure cmake
37        env:
38          CXX: ${{ matrix.compiler }}
39        shell: bash
40        working-directory: ${{ runner.workspace }}/_build
41        run: >
42          cmake -C ${{ github.workspace }}/compiler-cache.cmake
43          $GITHUB_WORKSPACE
44          -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
45          -DBUILD_SHARED_LIBS=${{ matrix.lib == 'shared' }}
46          -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
47          -DCMAKE_CXX_COMPILER=${{ env.CXX }}
48          -DCMAKE_CXX_VISIBILITY_PRESET=hidden
49          -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON
50
51      - name: build
52        shell: bash
53        working-directory: ${{ runner.workspace }}/_build
54        run: cmake --build . --config ${{ matrix.build_type }}
55
56      - name: test
57        shell: bash
58        working-directory: ${{ runner.workspace }}/_build
59        run: ctest -C ${{ matrix.build_type }} -VV
60
61  msvc:
62    name: ${{ matrix.os }}.${{ matrix.build_type }}.${{ matrix.lib }}.${{ matrix.msvc }}
63    runs-on: ${{ matrix.os }}
64    defaults:
65        run:
66            shell: powershell
67    strategy:
68      fail-fast: false
69      matrix:
70        msvc:
71          - VS-16-2019
72          - VS-17-2022
73        arch:
74          - x64
75        build_type:
76          - Debug
77          - Release
78        lib:
79          - shared
80          - static
81        include:
82          - msvc: VS-16-2019
83            os: windows-2019
84            generator: 'Visual Studio 16 2019'
85          - msvc: VS-17-2022
86            os: windows-2022
87            generator: 'Visual Studio 17 2022'
88
89    steps:
90      - uses: actions/checkout@v2
91
92      - uses: lukka/get-cmake@latest
93
94      - name: configure cmake
95        run: >
96          cmake -S . -B _build/
97          -A ${{ matrix.arch }}
98          -G "${{ matrix.generator }}"
99          -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON
100          -DBUILD_SHARED_LIBS=${{ matrix.lib == 'shared' }}
101
102      - name: build
103        run: cmake --build _build/ --config ${{ matrix.build_type }}
104
105      - name: setup test environment
106        # Make sure gmock and benchmark DLLs can be found
107        run: >
108            echo "$((Get-Item .).FullName)/_build/bin/${{ matrix.build_type }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append;
109            echo "$((Get-Item .).FullName)/_build/src/${{ matrix.build_type }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append;
110
111      - name: test
112        run: ctest --test-dir _build/ -C ${{ matrix.build_type }} -VV
113
114
115