check for cache hit #76
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # .github/workflows/build-on-windows.yml | |
| # | |
| # Copyright 2021 Jens A. Koch. | |
| # SPDX-License-Identifier: BSL-1.0 | |
| # This file is part of hikogui. | |
| # | |
| name: "Build on Windows" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| # improve CI concurrency by automatically cancelling outdated jobs | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| # --------------------------------------------------------------------------------------- | |
| build-and-test: | |
| name: x64-windows | |
| # https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md | |
| runs-on: windows-2022 | |
| env: | |
| DEBUG_BUILD_DIR: ${{github.workspace}}\out\build\x64-windows\Debug | |
| RELEASE_BUILD_DIR: ${{github.workspace}}\out\build\x64-windows\Release | |
| INSTALL_DIR: ${{github.workspace}}\out\install | |
| VCPKG_ROOT: ${{github.workspace}}\vcpkg | |
| VCPKG_DEFAULT_BINARY_CACHE: ${{github.workspace}}\vcpkg\binary-sources | |
| VCPKG_BINARY_SOURCES: clear;file,${{github.workspace}}\vcpkg\binary-sources,readwrite | |
| VCPKG_FEATURE_FLAGS: binarycaching | |
| defaults: | |
| run: | |
| shell: cmd | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 # https://github.com/actions/checkout | |
| with: | |
| submodules: recursive | |
| - name: Setup Visual Studio Developer Command Prompt | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Create vcpkg cache dir | |
| run: mkdir ${{env.VCPKG_DEFAULT_BINARY_CACHE}} | |
| - name: Get vcpkg commit id | |
| working-directory: vcpkg | |
| run: git rev-parse HEAD >commit.txt | |
| - name: Install vcpkg | |
| working-directory: vcpkg | |
| run: .\bootstrap-vcpkg.bat | |
| # lukka/run-vcpkg@v11 does not have a working cache implementation. | |
| - name: Restore vcpkg binary-cache | |
| id: restore-vcpkg-cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: vcpkg\binary-sources\**\*.zip | |
| key: vcpkg-cache-${{hashFiles('vcpkg.json', 'vcpkg\commit.txt')}} | |
| - name: CMake - Configure | |
| run: cmake --preset=x64-windows . | |
| # Always save, so that even a partial builded cache get saved for the next time. | |
| - name: Save vcpkg binary-cache | |
| uses: actions/cache/save@v4 | |
| id: save-vcpkg-cache | |
| if: always() && steps.restore-vcpkg-cache.outputs.cache-hit != 'true' | |
| with: | |
| path: vcpkg\binary-sources\**\*.zip | |
| key: ${{steps.restore-vcpkg-cache.outputs.cache-primary-key}} | |
| - name: CMake - Build (Debug) | |
| run: cmake --build --preset=x64-windows-dbg --parallel 1 . | |
| - name: CMake - Build (Release) | |
| run: cmake --build --preset=x64-windows-rel --parallel 1 . | |
| - name: Run tests (Debug) | |
| working-directory: ${{env.DEBUG_BUILD_DIR}} | |
| run: .\hktests-dbg.exe --gtest_output=xml:hktests-dbg.xml | |
| - name: Run tests (Release) | |
| working-directory: ${{env.RELEASE_BUILD_DIR}} | |
| run: .\hktests-rel.exe --gtest_output=xml:hktests-rel.xml | |
| - name: Publish Test Results | |
| uses: EnricoMi/publish-unit-test-result-action/windows@v2 # https://github.com/EnricoMi/publish-unit-test-result-action | |
| if: always() && github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| with: | |
| files: | | |
| ${{env.DEBUG_BUILD_DIR}}\hktests-dbg.xml | |
| ${{env.RELEASE_BUILD_DIR}}\hktests-rel.xml | |
| - name: Generate CodeCoverage Report (Debug) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| run: | | |
| curl -L -O https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverageSetup-x64-0.9.9.0.exe | |
| OpenCppCoverageSetup-x64-0.9.9.0.exe /VERYSILENT /DIR=.\bin\coverage | |
| .\bin\coverage\OpenCppCoverage.exe ^ | |
| --sources=src ^ | |
| --excluded_sources=src\*_tests.cpp ^ | |
| --excluded_sources=src\*\*_tests.cpp ^ | |
| --excluded_sources=out ^ | |
| --export_type=cobertura:hikolang_coverage.xml ^ | |
| --working_dir=${{env.DEBUG_BUILD_DIR}} ^ | |
| -- ${{env.DEBUG_BUILD_DIR}}\hktests-dbg | |
| # retry uploading to codecov with limit to workaround flaky upload issue | |
| - name: Upload CodeCoverage Report to codecov.io (Debug) | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: ./hikolang_coverage.xml | |
| token: ${{secrets.CODECOV_TOKEN}} | |