Skip to content

Add file

Add file #1

#
# .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
defaults:
run:
shell: cmd
steps:
- name: 🤘 Checkout Code
uses: actions/checkout@v4 # https://github.com/actions/checkout
with:
submodules: true
- name: 🔽 Install CMake and Ninja
uses: lukka/get-cmake@latest
- name: 🛠️ Setup Visual Studio Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1
- 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: .\hic-tests-dbg.exe --gtest_output=xml:hic-tests-dbg.xml
- name: Run tests (Release)
working-directory: ${{env.RELEASE_BUILD_DIR}}
run: .\hic-tests-rel.exe --gtest_output=xml:hic-tests-rel.xml
# Each file is differently named by adding the job name of the matrix as a suffix.
# This enables the "Unit Test Result" display to show all individual test runs of the matrix.
# The tests are published after all matrix runs finished (from job: "publish-test-results").
- 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}}\hic-tests-dbg.xml
${{env.RELEASE_BUILD_DIR}}\hic-tests-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:hikogui_coverage.xml ^
# --working_dir=${{env.BUILD_DIR}} ^
# -- ${{env.BUILD_DIR}}\Debug\hikogui_htests-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' && env.MATRIX_ID == 'cl-x86-64'
# uses: wandalen/wretry.action@v3 # https://github.com/wandalen/wretry.action
# with:
# attempt_limit: 10
# action: codecov/codecov-action@v3 # https://github.com/codecov/codecov-action
# with: |
# files: ./hikogui_coverage.xml
#
# 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
# ---------------------------------------------------------------------------------------
# publish-test-results:
# # Only publish test results, when the action runs in your repository's context.
# # In other words: this disables publishing tests results from pull requests.
# # PR test results are published from the standalone workflow "publish-PR-test-results.yml".
#
# name: "Publish Tests Results"
# needs: build-and-test
# runs-on: windows-2022
# if: always() && ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository )
#
# steps:
# - name: 🔽 Download Artifacts
# uses: actions/download-artifact@v4 # https://github.com/actions/download-artifact
# with:
# name: test-results
# path: artifacts
#
# - name: 👌 Publish Test Results
# uses: EnricoMi/publish-unit-test-result-action/windows@v2 # https://github.com/EnricoMi/publish-unit-test-result-action
# if: (!cancelled())
# with:
# files: |
# artifacts/Debug/hic-tests-dbg.xml
# artifacts/Release/hic-tests-rel.xml