add codecov badge #61
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}}\bincache | |
| VCPKG_BINARY_SOURCES: clear;file,${{github.workspace}}\\bincache,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: 🔽 Install CMake and Ninja | |
| uses: lukka/get-cmake@latest | |
| - name: 🛠️ Setup vcpkg (optionally from cache) | |
| uses: lukka/run-vcpkg@v11 | |
| - 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: 🔼 Upload Test Results | |
| uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact | |
| if: always() | |
| with: | |
| name: test-results | |
| path: | | |
| ${{env.DEBUG_BUILD_DIR}}\hktests-dbg.xml | |
| ${{env.RELEASE_BUILD_DIR}}\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}} | |
| # In the future we can do this when building dynamic libraries without whole-program-optimization. | |
| # | |
| # # Double ZIP issue: https://github.com/actions/upload-artifact#zipped-artifact-downloads | |
| # # We can either zip an already zipped file; or send all files to a zip service, possibly creating a 503. | |
| # - name: 📦 Package | |
| # run: | | |
| # cd build | |
| # 7z a -tzip -mx9 "${{env.ARTIFACT_NAME}}.zip" ./hikogui-${{env.VERSION}} | |
| # | |
| # # To ensure that jobs don't overwrite existing artifacts, use a different "name" per job/run. | |
| # - name: 📦 🚀 Upload Artifact | |
| # uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact | |
| # with: | |
| # name: ${{env.ARTIFACT_NAME}} | |
| # path: build/${{env.ARTIFACT_NAME}}.zip | |