|
| 1 | +# Taken and modified from here: |
| 2 | +# https://github.com/lukka/CppBuildTasks-Validation/blob/master/.github/workflows/hosted-pure-workflow.yml |
| 3 | + |
| 4 | +name: Run build and tests |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - master |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + |
| 14 | +jobs: |
| 15 | + job: |
| 16 | + name: ${{matrix.os}} |
| 17 | + runs-on: ${{matrix.os}} |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + os: [ubuntu-latest, windows-latest] |
| 22 | + include: |
| 23 | + - os: windows-latest |
| 24 | + triplet: x64-windows |
| 25 | + - os: ubuntu-latest |
| 26 | + triplet: x64-linux |
| 27 | + |
| 28 | + env: |
| 29 | + CMAKE_BUILD_DIR: ${{github.workspace}}/build/ |
| 30 | + VCPKG_ROOT: ${{github.workspace}}/vcpkg |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout repository |
| 34 | + uses: actions/checkout@v2 |
| 35 | + with: |
| 36 | + submodules: recursive |
| 37 | + |
| 38 | + - name: Install CMake and Ninja |
| 39 | + uses: lukka/get-cmake@latest |
| 40 | + |
| 41 | + - name: Restore vcpkg and its artifacts |
| 42 | + uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + # The first path is where vcpkg generates artifacts while consuming the vcpkg.json manifest file. |
| 45 | + # The second path is the location of vcpkg (it contains the vcpkg executable and data files). |
| 46 | + # The other paths starting with '!' are exclusions: they contain temporary files generated during the build of the installed packages. |
| 47 | + path: | |
| 48 | + ${{env.CMAKE_BUILD_DIR}}/vcpkg_installed/ |
| 49 | + ${{env.VCPKG_ROOT}} |
| 50 | + !${{env.VCPKG_ROOT}}/buildtrees |
| 51 | + !${{env.VCPKG_ROOT}}/packages |
| 52 | + !${{env.VCPKG_ROOT}}/downloads |
| 53 | + # The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. |
| 54 | + # In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service. |
| 55 | + # The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. |
| 56 | + # The vcpkg's commit id would suffice, but computing an hash out it does not harm. |
| 57 | + # Note: given a key, the cache content is immutable. |
| 58 | + # If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already). |
| 59 | + key: | |
| 60 | + ${{hashFiles('vcpkg.json')}}-${{hashFiles('.git/modules/vcpkg/HEAD')}}-${{matrix.triplet}}-invalidate |
| 61 | +
|
| 62 | + - name: (Linux) Install required tools for glfw |
| 63 | + if: runner.os == 'Linux' |
| 64 | + run: sudo apt-get install libxinerama-dev libxcursor-dev xorg-dev libglu1-mesa-dev |
| 65 | + |
| 66 | + - name: (Windows) Ensure the Developer Command Prompt is setup correctly |
| 67 | + if: runner.os == 'Windows' |
| 68 | + uses: ilammy/msvc-dev-cmd@v1 |
| 69 | + |
| 70 | + - name: Install dependencies and generate project files |
| 71 | + run: cmake -S "${{github.workspace}}" -B "${{env.CMAKE_BUILD_DIR}}" -GNinja -DCMAKE_TOOLCHAIN_FILE="${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake" |
| 72 | + |
| 73 | + - name: Build all |
| 74 | + run: cmake --build "${{env.CMAKE_BUILD_DIR}}" |
| 75 | + |
| 76 | + - name: Build dmath |
| 77 | + run: cmake --build "${{env.CMAKE_BUILD_DIR}}" --target dmath |
| 78 | + |
| 79 | + - name: Run tests |
| 80 | + run: | |
| 81 | + cd "${{env.CMAKE_BUILD_DIR}}" |
| 82 | + ctest |
0 commit comments