|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + schedule: |
| 7 | + - cron: '0 0 1 * *' # This line schedules the workflow to run at 00:00 on the first day of every month |
| 8 | + |
| 9 | +defaults: |
| 10 | + run: |
| 11 | + shell: bash |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - os: ubuntu-latest |
| 20 | + compiler: gcc |
| 21 | + - os: ubuntu-latest |
| 22 | + compiler: clang |
| 23 | + - os: windows-latest |
| 24 | + compiler: msvc |
| 25 | + - os: macos-latest |
| 26 | + compiler: |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + submodules: true |
| 33 | + |
| 34 | + - name: Cache |
| 35 | + uses: actions/cache@v4 |
| 36 | + with: |
| 37 | + path: | |
| 38 | + ~/vcpkg |
| 39 | + ~/vcpkg_installed |
| 40 | + ${{ env.HOME }}/.cache/vcpkg/archives |
| 41 | + ${{ env.XDG_CACHE_HOME }}/vcpkg/archives |
| 42 | + ${{ env.LOCALAPPDATA }}\vcpkg\archives |
| 43 | + ${{ env.APPDATA }}\vcpkg\archives |
| 44 | + key: ${{ runner.os }}-${{ matrix.compiler }}-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}} |
| 45 | + restore-keys: | |
| 46 | + ${{ runner.os }}-${{ env.BUILD_TYPE }}- |
| 47 | +
|
| 48 | + - name: Setup Cpp |
| 49 | + uses: aminya/setup-cpp@v1 |
| 50 | + with: |
| 51 | + compiler: ${{ matrix.compiler }} |
| 52 | + vcvarsall: ${{ contains(matrix.os, 'windows') }} |
| 53 | + cmake: true |
| 54 | + ninja: true |
| 55 | + vcpkg: true |
| 56 | + cppcheck: false |
| 57 | + |
| 58 | + - name: Install compiler for Macos |
| 59 | + if: startsWith(matrix.os, 'macos') |
| 60 | + run: | |
| 61 | + brew install llvm |
| 62 | +
|
| 63 | + - name: Prepare the PATH |
| 64 | + run: | |
| 65 | + if [[ "${{ runner.os }}" == "Windows" ]]; then |
| 66 | + echo "$env:USERPROFILE\vcpkg" >> $GITHUB_PATH |
| 67 | + echo "$env:USERPROFILE\ninja" >> $GITHUB_PATH |
| 68 | + else |
| 69 | + echo "$HOME/vcpkg" >> $GITHUB_PATH |
| 70 | + echo "$HOME/ninja" >> $GITHUB_PATH |
| 71 | + fi |
| 72 | +
|
| 73 | + - name: Install dependencies |
| 74 | + run: | |
| 75 | + cp -v ci/vcpkg/vcpkg.json . |
| 76 | + vcpkg install |
| 77 | +
|
| 78 | + - name: Build project |
| 79 | + run: | |
| 80 | + pushd ~ |
| 81 | + if [ -d build ]; then |
| 82 | + echo "Build dir exists" |
| 83 | + ls -la build |
| 84 | + else |
| 85 | + mkdir -v build |
| 86 | + fi |
| 87 | + cd build |
| 88 | + pwd |
| 89 | + set -x |
| 90 | + cmake -DVCPKG_INSTALLED_DIR=~/vcpkg_installed -DVCPKG_VERBOSE=ON -DRESTC_CPP_THREADED_CTX=ON -DCMAKE_BUILD_TYPE=Release -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake ${GITHUB_WORKSPACE} |
| 91 | + cmake --build . |
| 92 | + popd |
| 93 | + continue-on-error: true |
| 94 | + |
| 95 | + - name: Dump diagnostics |
| 96 | + if: failure() |
| 97 | + run: | |
| 98 | + cd ~/build |
| 99 | + echo "---------------------------------" |
| 100 | + cat build.ninja |
| 101 | + echo "---------------------------------" |
| 102 | +
|
| 103 | + - name: Run Unit Tests |
| 104 | + run: | |
| 105 | + pushd ~/build |
| 106 | + ctest -R UNITTESTS . -C Release |
| 107 | + popd |
0 commit comments