build.yml raw
1 # Copyright 2021 The CRC32C Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. See the AUTHORS file for names of contributors.
4
5 name: ci
6 on: [push, pull_request]
7
8 permissions:
9 contents: read
10
11 jobs:
12 build-and-test:
13 name: >-
14 CI
15 ${{ matrix.os }}
16 ${{ matrix.compiler }}
17 ${{ matrix.optimized && 'release' || 'debug' }}
18 ${{ matrix.shared_lib && 'shared' || 'static' }}
19 ${{ matrix.use_glog && 'glog' || 'no-glog' }}
20 runs-on: ${{ matrix.os }}
21 strategy:
22 fail-fast: false
23 matrix:
24 compiler: [clang, gcc, msvc]
25 os: [ubuntu-latest, macos-latest, windows-latest]
26 optimized: [true, false]
27 shared_lib: [true, false]
28 use_glog: [true, false]
29 exclude:
30 # Our glog config doesn't work with shared libraries.
31 - use_glog: true
32 shared_lib: true
33 # MSVC only works on Windows.
34 - os: ubuntu-latest
35 compiler: msvc
36 - os: macos-latest
37 compiler: msvc
38 # Not testing with GCC on macOS.
39 - os: macos-latest
40 compiler: gcc
41 # Only testing with MSVC on Windows.
42 - os: windows-latest
43 compiler: clang
44 - os: windows-latest
45 compiler: gcc
46 # Not testing fringe configurations (glog, shared libraries) on Windows.
47 - os: windows-latest
48 use_glog: true
49 - os: windows-latest
50 shared_lib: true
51 include:
52 - compiler: clang
53 CC: clang
54 CXX: clang++
55 - compiler: gcc
56 CC: gcc
57 CXX: g++
58 - compiler: msvc
59 CC:
60 CXX:
61
62 env:
63 CMAKE_BUILD_DIR: ${{ github.workspace }}/build
64 CMAKE_BUILD_TYPE: ${{ matrix.optimized && 'RelWithDebInfo' || 'Debug' }}
65 CC: ${{ matrix.CC }}
66 CXX: ${{ matrix.CXX }}
67 BINARY_SUFFIX: ${{ startsWith(matrix.os, 'windows') && '.exe' || '' }}
68 BINARY_PATH: >-
69 ${{ format(
70 startsWith(matrix.os, 'windows') && '{0}\build\{1}\' || '{0}/build/',
71 github.workspace,
72 matrix.optimized && 'RelWithDebInfo' || 'Debug') }}
73
74 steps:
75 - uses: actions/checkout@v2
76 with:
77 submodules: true
78
79 - name: Generate build config
80 run: >-
81 cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}"
82 -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }}
83 -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/install_test/
84 -DBUILD_SHARED_LIBS=${{ matrix.shared_lib && '1' || '0' }}
85 -DCRC32C_USE_GLOG=${{ matrix.use_glog && '1' || '0' }}
86
87 - name: Build
88 run: >-
89 cmake --build "${{ env.CMAKE_BUILD_DIR }}"
90 --config "${{ env.CMAKE_BUILD_TYPE }}"
91
92 - name: Run C++ API Tests
93 run: ${{ env.BINARY_PATH }}crc32c_tests${{ env.BINARY_SUFFIX }}
94
95 - name: Run C API Tests
96 run: ${{ env.BINARY_PATH }}crc32c_capi_tests${{ env.BINARY_SUFFIX }}
97
98 - name: Run Benchmarks
99 run: ${{ env.BINARY_PATH }}crc32c_bench${{ env.BINARY_SUFFIX }}
100
101 - name: Test CMake installation
102 run: cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install
103