self cache #68
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_DEFAULT_BINARY_CACHE: ${{github.workspace}}\vcpkg\binary-cache | |
| VCPKG_BINARY_SOURCES: clear;file,${{github.workspace}}\vcpkg\binary-cache,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: Create vcpkg cache dir | |
| run: mkdir ${{env.VCPKG_DEFAULT_BINARY_CACHE}} | |
| - name: Setup Visual Studio Developer Command Prompt | |
| uses: ilammy/msvc-dev-cmd@v1 | |
| - name: Install CMake and Ninja | |
| uses: lukka/get-cmake@latest | |
| - name: Setup vcpkg | |
| uses: lukka/run-vcpkg@v11 | |
| # lukka/run-vcpkg@v11 does not have a working cache implementation. | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ${{env.VCPKG_DEFAULT_BINARY_CACHE}} | |
| key: vcpkg-cache-${{hashFiles('vcpkg.json', 'vcpkg\vcpkgLastBuiltCommitId')}} | |
| - name: Configure application (Debug, Release | |
| uses: lukka/run-cmake@v10 | |
| with: | |
| configurePreset: 'x64-windows' | |
| - name: Build application (Debug) | |
| uses: lukka/run-cmake@v10 | |
| with: | |
| buildPreset: 'x64-windows-dbg' | |
| - name: Build application (Release) | |
| uses: lukka/run-cmake@v10 | |
| with: | |
| buildPreset: 'x64-windows-rel' | |
| - 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: 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=build\_deps ^ | |
| --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}} | |