|
| 1 | +name: Compile and Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + release: |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + # The type of runner that the job will run on |
| 11 | + name: ${{ matrix.config.name }} |
| 12 | + runs-on: ${{ matrix.config.os }} |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + config: |
| 17 | + # Run Tests on Ubuntu 18.04 |
| 18 | + - name: "Ubuntu 18.04 Debug SQLite" |
| 19 | + os: ubuntu-18.04 |
| 20 | + build_type: "Debug" |
| 21 | + test_database: "sqlite" |
| 22 | + |
| 23 | + - name: "Ubuntu 18.04 Release SQLite" |
| 24 | + os: ubuntu-18.04 |
| 25 | + build_type: "Release" |
| 26 | + test_database: "sqlite" |
| 27 | + |
| 28 | + - name: "Ubuntu 18.04 Debug PostgreSQL" |
| 29 | + os: ubuntu-18.04 |
| 30 | + build_type: "Debug" |
| 31 | + test_database: "postgresql" |
| 32 | + |
| 33 | + - name: "Ubuntu 18.04 Release PostgreSQL" |
| 34 | + os: ubuntu-18.04 |
| 35 | + build_type: "Release" |
| 36 | + test_database: "postgresql" |
| 37 | + |
| 38 | + - name: "Ubuntu 18.04 Debug MySQL" |
| 39 | + os: ubuntu-18.04 |
| 40 | + build_type: "Debug" |
| 41 | + test_database: "mysql" |
| 42 | + |
| 43 | + - name: "Ubuntu 18.04 Release MySQL" |
| 44 | + os: ubuntu-18.04 |
| 45 | + build_type: "Release" |
| 46 | + test_database: "mysql" |
| 47 | + |
| 48 | + # Run Tests on Ubuntu 20.04 |
| 49 | + - name: "Ubuntu 20.04 Release SQLite" |
| 50 | + os: ubuntu-20.04 |
| 51 | + build_type: "Release" |
| 52 | + test_database: "sqlite" |
| 53 | + |
| 54 | + - name: "Ubuntu 20.04 Release PostgreSQL" |
| 55 | + os: ubuntu-20.04 |
| 56 | + build_type: "Release" |
| 57 | + test_database: "postgresql" |
| 58 | + |
| 59 | + - name: "Ubuntu 20.04 Release MySQL" |
| 60 | + os: ubuntu-20.04 |
| 61 | + build_type: "Release" |
| 62 | + test_database: "mysql" |
| 63 | + |
| 64 | + # Run Tests on Ubuntu 20.04 with newer GCC |
| 65 | + - name: "Ubuntu 20.04 gcc 11 Release SQLite" |
| 66 | + os: ubuntu-20.04 |
| 67 | + build_type: "Release" |
| 68 | + gcc_install: "11" |
| 69 | + test_database: "sqlite" |
| 70 | + |
| 71 | + # Run Tests on MacOS |
| 72 | + - name: "macOS Debug SQLite" |
| 73 | + os: macos-latest |
| 74 | + build_type: "Debug" |
| 75 | + test_database: "sqlite" |
| 76 | + |
| 77 | + - name: "macOS Release SQLite" |
| 78 | + os: macos-latest |
| 79 | + build_type: "Release" |
| 80 | + test_database: "sqlite" |
| 81 | + |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v2 |
| 84 | + |
| 85 | + - name: Install Boost |
| 86 | + if: ${{startsWith(matrix.config.os, 'ubuntu')}} |
| 87 | + run: | |
| 88 | + echo --- Installing Boost.Regex |
| 89 | + sudo apt-get update |
| 90 | + sudo apt-get install libboost-regex-dev |
| 91 | +
|
| 92 | + - name: Install Boost |
| 93 | + if: ${{startsWith(matrix.config.os, 'macos')}} |
| 94 | + run: | |
| 95 | + echo --- Installing Boost.Regex |
| 96 | + brew install boost |
| 97 | +
|
| 98 | + - name: Install gcc version |
| 99 | + if: ${{matrix.config.gcc_install}} |
| 100 | + run: | |
| 101 | + echo --- Install gcc version ${{matrix.config.gcc_install}} |
| 102 | + echo --- gcc version before |
| 103 | + gcc --version |
| 104 | + sudo add-apt-repository ppa:ubuntu-toolchain-r/test |
| 105 | + sudo apt-get update |
| 106 | + sudo apt-get install gcc-${{matrix.config.gcc_install}} g++-${{matrix.config.gcc_install}} |
| 107 | + sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{matrix.config.gcc_install}} 90 --slave /usr/bin/g++ g++ /usr/bin/g++-${{matrix.config.gcc_install}} |
| 108 | + echo --- gcc version after |
| 109 | + gcc --version |
| 110 | +
|
| 111 | + - name: Configure CMake |
| 112 | + run: > |
| 113 | + cmake -B ${{github.workspace}}/build |
| 114 | + -DCMAKE_BUILD_TYPE=${{matrix.config.build_type}} |
| 115 | + -DCMAKE_CXX_FLAGS="${{matrix.config.cxx_flags}}" |
| 116 | + -DTEST_DATABASE="${{matrix.config.test_database}}" |
| 117 | + -DBUILD_EXAMPLES=ON |
| 118 | +
|
| 119 | + - name: Build |
| 120 | + run: cmake --build ${{github.workspace}}/build --config ${{matrix.config.build_type}} |
| 121 | + |
| 122 | + - name: Set up PostgreSQL |
| 123 | + if: ${{startsWith(matrix.config.test_database, 'postgresql')}} |
| 124 | + run: | |
| 125 | + sudo /etc/init.d/postgresql start |
| 126 | + sudo -u postgres psql -c "CREATE USER $USER" |
| 127 | + sudo -u postgres psql -c "CREATE DATABASE $USER OWNER $USER;" |
| 128 | +
|
| 129 | + - name: Set up MySQL |
| 130 | + if: ${{startsWith(matrix.config.test_database, 'mysql')}} |
| 131 | + run: | |
| 132 | + sudo /etc/init.d/mysql start |
| 133 | + mysql -hlocalhost -uroot -proot -e "CREATE USER $USER" |
| 134 | + mysql -hlocalhost -uroot -proot -e "CREATE DATABASE test" |
| 135 | + mysql -hlocalhost -uroot -proot -e "GRANT ALL ON test.* TO $USER" |
| 136 | +
|
| 137 | + - name: Test |
| 138 | + working-directory: ${{github.workspace}}/build |
| 139 | + run: ctest -C ${{matrix.config.build_type}} |
0 commit comments