|
| 1 | +--- |
| 2 | +name: CI |
| 3 | +permissions: {} |
| 4 | + |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Build (${{ matrix.name }}) |
| 18 | + permissions: |
| 19 | + contents: read |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + defaults: |
| 22 | + run: |
| 23 | + shell: ${{ matrix.shell }} |
| 24 | + strategy: |
| 25 | + fail-fast: false |
| 26 | + matrix: |
| 27 | + include: |
| 28 | + - name: Linux-GCC |
| 29 | + os: ubuntu-latest |
| 30 | + shell: bash |
| 31 | + kind: unix |
| 32 | + cc: gcc |
| 33 | + cxx: g++ |
| 34 | + - name: Linux-Clang |
| 35 | + os: ubuntu-latest |
| 36 | + shell: bash |
| 37 | + kind: unix |
| 38 | + cc: clang |
| 39 | + cxx: clang++ |
| 40 | + - name: macOS |
| 41 | + os: macos-latest |
| 42 | + shell: bash |
| 43 | + kind: unix |
| 44 | + cc: clang |
| 45 | + cxx: clang++ |
| 46 | + - name: Windows-MinGW-UCRT64 |
| 47 | + os: windows-latest |
| 48 | + shell: msys2 {0} |
| 49 | + kind: msys2 |
| 50 | + cc: gcc |
| 51 | + cxx: g++ |
| 52 | + msystem: ucrt64 |
| 53 | + toolchain: ucrt-x86_64 |
| 54 | + - name: Windows-MSVC |
| 55 | + os: windows-latest |
| 56 | + shell: pwsh |
| 57 | + kind: msvc |
| 58 | + steps: |
| 59 | + - name: Checkout |
| 60 | + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
| 61 | + with: |
| 62 | + submodules: recursive |
| 63 | + |
| 64 | + - name: Setup Dependencies Linux |
| 65 | + if: runner.os == 'Linux' |
| 66 | + run: | |
| 67 | + sudo apt-get update |
| 68 | + sudo apt-get install -y \ |
| 69 | + build-essential \ |
| 70 | + clang \ |
| 71 | + cmake \ |
| 72 | + ninja-build |
| 73 | +
|
| 74 | + - name: Setup Dependencies macOS |
| 75 | + if: runner.os == 'macOS' |
| 76 | + run: | |
| 77 | + brew install \ |
| 78 | + cmake \ |
| 79 | + ninja |
| 80 | +
|
| 81 | + - name: Setup Dependencies Windows MinGW |
| 82 | + if: matrix.kind == 'msys2' |
| 83 | + uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2.32.0 |
| 84 | + with: |
| 85 | + msystem: ${{ matrix.msystem }} |
| 86 | + update: true |
| 87 | + install: >- |
| 88 | + mingw-w64-${{ matrix.toolchain }}-cmake |
| 89 | + mingw-w64-${{ matrix.toolchain }}-ninja |
| 90 | + mingw-w64-${{ matrix.toolchain }}-toolchain |
| 91 | +
|
| 92 | + - name: Configure |
| 93 | + if: matrix.kind != 'msvc' |
| 94 | + env: |
| 95 | + CC: ${{ matrix.cc }} |
| 96 | + CXX: ${{ matrix.cxx }} |
| 97 | + run: | |
| 98 | + cmake \ |
| 99 | + -DBUILD_DOCS=OFF \ |
| 100 | + -DBUILD_EXAMPLES=ON \ |
| 101 | + -DBUILD_TESTS=ON \ |
| 102 | + -DCMAKE_BUILD_TYPE:STRING=Debug \ |
| 103 | + -B cmake-build-ci \ |
| 104 | + -G Ninja \ |
| 105 | + -S . |
| 106 | +
|
| 107 | + - name: Configure MSVC |
| 108 | + if: matrix.kind == 'msvc' |
| 109 | + run: | |
| 110 | + cmake ` |
| 111 | + -DBUILD_DOCS=OFF ` |
| 112 | + -DBUILD_EXAMPLES=ON ` |
| 113 | + -DBUILD_TESTS=ON ` |
| 114 | + -A x64 ` |
| 115 | + -B cmake-build-ci ` |
| 116 | + -G "Visual Studio 17 2022" ` |
| 117 | + -S . |
| 118 | +
|
| 119 | + - name: Build |
| 120 | + if: matrix.kind != 'msvc' |
| 121 | + run: cmake --build cmake-build-ci -- -j2 |
| 122 | + |
| 123 | + - name: Build MSVC |
| 124 | + if: matrix.kind == 'msvc' |
| 125 | + run: cmake --build cmake-build-ci --config Debug --parallel 2 |
| 126 | + |
| 127 | + - name: Run tests |
| 128 | + if: matrix.kind != 'msvc' |
| 129 | + run: ctest --test-dir cmake-build-ci --output-on-failure |
| 130 | + |
| 131 | + - name: Run tests MSVC |
| 132 | + if: matrix.kind == 'msvc' |
| 133 | + run: ctest --test-dir cmake-build-ci --build-config Debug --output-on-failure |
| 134 | + |
| 135 | + - name: Run Sunshine adapter example |
| 136 | + if: matrix.kind != 'msvc' |
| 137 | + run: | |
| 138 | + if [[ "${RUNNER_OS}" == "Windows" ]]; then |
| 139 | + ./cmake-build-ci/examples/sunshine_gamepad_adapter.exe |
| 140 | + else |
| 141 | + ./cmake-build-ci/examples/sunshine_gamepad_adapter |
| 142 | + fi |
| 143 | +
|
| 144 | + - name: Run Sunshine adapter example MSVC |
| 145 | + if: matrix.kind == 'msvc' |
| 146 | + run: .\cmake-build-ci\examples\Debug\sunshine_gamepad_adapter.exe |
| 147 | + |
| 148 | + - name: Install |
| 149 | + if: matrix.kind != 'msvc' |
| 150 | + run: cmake --install cmake-build-ci --prefix cmake-build-ci/install |
| 151 | + |
| 152 | + - name: Install MSVC |
| 153 | + if: matrix.kind == 'msvc' |
| 154 | + run: cmake --install cmake-build-ci --config Debug --prefix cmake-build-ci/install |
| 155 | + |
| 156 | + - name: Upload install artifact |
| 157 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 158 | + with: |
| 159 | + name: install-${{ matrix.name }} |
| 160 | + path: cmake-build-ci/install |
| 161 | + if-no-files-found: error |
0 commit comments