summaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: efb81ee0b98e96c7fd610549bd5995985045a469 (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
# Copyright 2021 The LevelDB Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. See the AUTHORS file for names of contributors.

name: ci
on: [push, pull_request]

permissions:
  contents: read

jobs:
  build-and-test:
    name:  >-
      CI
      ${{ matrix.os }}
      ${{ matrix.compiler }}
      ${{ matrix.optimized && 'release' || 'debug' }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        compiler: [clang, gcc, msvc]
        os: [ubuntu-latest, macos-latest, windows-latest]
        optimized: [true, false]
        exclude:
        # MSVC only works on Windows.
        - os: ubuntu-latest
          compiler: msvc
        - os: macos-latest
          compiler: msvc
        # Not testing with GCC on macOS.
        - os: macos-latest
          compiler: gcc
        # Only testing with MSVC on Windows.
        - os: windows-latest
          compiler: clang
        - os: windows-latest
          compiler: gcc
        include:
        - compiler: clang
          CC: clang
          CXX: clang++
        - compiler: gcc
          CC: gcc
          CXX: g++
        - compiler: msvc
          CC:
          CXX:

    env:
      CMAKE_BUILD_DIR: ${{ github.workspace }}/build
      CMAKE_BUILD_TYPE: ${{ matrix.optimized && 'RelWithDebInfo' || 'Debug' }}
      CC: ${{ matrix.CC }}
      CXX: ${{ matrix.CXX }}
      BINARY_SUFFIX: ${{ startsWith(matrix.os, 'windows') && '.exe' || '' }}
      BINARY_PATH: >-
        ${{ format(
        startsWith(matrix.os, 'windows') && '{0}\build\{1}\' || '{0}/build/',
        github.workspace,
        matrix.optimized && 'RelWithDebInfo' || 'Debug') }}

    steps:
    - uses: actions/checkout@v2
      with:
        submodules: true

    - name: Install dependencies on Linux
      if: ${{ runner.os == 'Linux' }}
      run: |
        sudo apt-get update
        sudo apt-get install libgoogle-perftools-dev libkyotocabinet-dev \
            libsnappy-dev libsqlite3-dev

    - name: Generate build config
      run: >-
        cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}"
        -DCMAKE_BUILD_TYPE=${{ env.CMAKE_BUILD_TYPE }}
        -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/install_test/

    - name: Build
      run: >-
        cmake --build "${{ env.CMAKE_BUILD_DIR }}"
        --config "${{ env.CMAKE_BUILD_TYPE }}"

    - name: Run Tests
      working-directory: ${{ github.workspace }}/build
      run: ctest -C "${{ env.CMAKE_BUILD_TYPE }}" --verbose

    - name: Run LevelDB Benchmarks
      run: ${{ env.BINARY_PATH }}db_bench${{ env.BINARY_SUFFIX }}

    - name: Run SQLite Benchmarks
      if: ${{ runner.os != 'Windows' }}
      run: ${{ env.BINARY_PATH }}db_bench_sqlite3${{ env.BINARY_SUFFIX }}

    - name: Run Kyoto Cabinet Benchmarks
      if: ${{ runner.os == 'Linux' && matrix.compiler == 'clang' }}
      run: ${{ env.BINARY_PATH }}db_bench_tree_db${{ env.BINARY_SUFFIX }}

    - name: Test CMake installation
      run: cmake --build "${{ env.CMAKE_BUILD_DIR }}" --target install