Skip to content

Removed quotes from strings #11

Removed quotes from strings

Removed quotes from strings #11

# TODO: Use Infer
# TODO: Create commit-hook for auto-formatting
# TODO: Add valgrind / etc. style of tools
# TODO: Add seahorn (export results as sarif into sonar)
# TODO: add frama-c with clang plugin (export results as sarif into sonar)
# TODO: Add formatting check
# TODO: Mixed C++ and C# projects
# TODO: Save and restore the cppcheck analysis results from cppcheck-build-dir
name: Verify and Validate
on: push
env:
# Needed by vcpkg to find the binary cache and
# restore dependencies like Boost faster.
VCPKG_BINARY_SOURCES: clear;x-gha,readwrite
jobs:
build-with-gcc:
runs-on: windows-latest
steps:
# No need to check out the submodule as Doxygen documentation is not
# built.
- name: Checkout repository
uses: actions/checkout@v4
# Rebuilding all vcpkg dependencies at each commit is time consuming,
# in particular when Boost is a dependency. So cache binaries.
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
# Module dependency scanning support in CMake requires GCC 14+
- name: Update GCC
shell: C:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64 {0}
env:
MSYSTEM: UCRT64
run: |
pacman -S --noconfirm pactoys
pacboy -S --noconfirm toolchain:p
gcc --version
# Use full path for MSYS2 to use the CMake of MSVC as MSYS2's CMake
# fails to compile sqlite3.
- name: Build (GCC)
shell: C:\msys64\msys2_shell.cmd -defterm -here -no-start -ucrt64 -use-full-path {0}
env:
MSYSTEM: UCRT64
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
run: |
cmake --workflow --preset x64-Debug-GCC
build-with-msvc-and-test:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1
- name: Install OpenCppCoverage
uses: KungFuDonkey/Install-OpenCppCoverage@v1
- name: Install behave
run: |
pip install behave
behave --version
- name: Build (MSVC)
uses: lukka/run-cmake@v10
env:
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
with:
workflowPreset: x64-Debug-MSVC
- name: Run unit tests
run: |
$dir = "${{ github.workspace }}\out\x64-Debug-MSVC"
New-Item -Path "$dir" -Name "test" -ItemType Directory
Start-Process `
-FilePath "OpenCppCoverage.exe" `
-ArgumentList `
"--working_dir", "`"$dir`"", `
"--export_type", "`"cobertura:$dir\unit-test-coverage.xml`"", `
"--cover_children", `
"--sources", "`"${{ github.workspace }}`"", `
"--excluded_sources", "`"$dir\vcpkg_installed\*`"", `
"--", `
"ctest", `
"-j", `
"--verbose", `
"-T", "Test", `
"--output-junit", "$dir/TESTS-ctest.xml" `
-NoNewWindow `
-Wait
- name: Run system tests
run: |
$dir = "${{ github.workspace }}\out\x64-Debug-MSVC"
Start-Process `
-FilePath "OpenCppCoverage.exe" `
-ArgumentList `
"--working_dir", "`"${{ github.workspace }}\tests`"", `
"--export_type", "`"cobertura:$dir\system-test-coverage.xml`"", `
"--cover_children", `
"--sources", "`"${{ github.workspace }}`"", `
"--excluded_sources", "`"$dir\vcpkg_installed\*`"", `
"--", `
"behave" `
-NoNewWindow `
-Wait
- name: Convert JUnit to CPPUnit format
run: |
$dir = "${{ github.workspace }}\out\x64-Debug-MSVC"
$xsltPath = "${{ github.workspace }}\tests\junit-to-cppunit.xsl"
$xslt = New-Object System.Xml.Xsl.XslCompiledTransform
$xslt.Load($xsltPath)
$junitFiles = Get-ChildItem -Path "$dir\*" -Include "TESTS-*.xml"
New-Item -Path $dir -Name "reports" -ItemType Directory
foreach ($inputXmlPath in $junitFiles) {
$outputXmlPath = Join-Path $dir "reports" (Split-Path $inputXmlPath -Leaf)
$inputXml = New-Object System.Xml.XPath.XPathDocument($inputXmlPath)
$outputWriter = New-Object System.Xml.XmlTextWriter($outputXmlPath, $null)
$xslt.Transform($inputXml, $outputWriter)
$outputWriter.Close()
}
- name: Save test, coverage and analysis results
uses: actions/upload-artifact@v4
with:
name: test-coverage-and-analysis-results
retention-days: 1
path: |
${{ github.workspace }}\out\x64-Debug-MSVC\reports\TESTS-*.xml
${{ github.workspace }}\out\x64-Debug-MSVC\unit-test-coverage.xml
${{ github.workspace }}\out\x64-Debug-MSVC\system-test-coverage.xml
${{ github.workspace }}\out\x64-Debug-MSVC\msvc.sarif
build-with-clang-and-analyze:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Export GitHub Actions cache environment variables
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Install cppcheck
run: |
$url = "https://github.com/danmar/cppcheck/releases/download/2.17.1/cppcheck-2.17.1-x64-Setup.msi"
$output = "cppcheck.msi"
Invoke-WebRequest -Uri $url -OutFile $output
Start-Process `
-FilePath msiexec `
-ArgumentList "/package $output /quiet /norestart" `
-NoNewWindow `
-Wait
Start-Process `
-FilePath "C:\Program Files\Cppcheck\cppcheck.exe" `
-ArgumentList "--version" `
-NoNewWindow `
-Wait
- name: Build (Clang)
uses: lukka/run-cmake@v10
env:
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
LLVM_PATH: C:/Program Files/LLVM/bin
CPPCHECK_PATH: C:/Program Files/Cppcheck
with:
workflowPreset: x64-Debug-Clang
- name: Save compile commands database and analysis results
uses: actions/upload-artifact@v4
with:
name: compile-command-database-and-analysis-results
retention-days: 1
path: |
${{ github.workspace }}\out\x64-Debug-Clang\compile_commands.json
${{ github.workspace }}\out\x64-Debug-Clang\CMakeFiles\*.dir\**
${{ github.workspace }}\out\x64-Debug-Clang\cppcheck.sarif
quality-gate:
runs-on: windows-latest
needs:
- build-with-msvc-and-test
- build-with-clang-and-analyze
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Restore test, coverage and analysis results
uses: actions/download-artifact@v4
with:
name: test-coverage-and-analysis-results
path: ${{ github.workspace }}/out/x64-Debug-MSVC
- name: Restore compile commands database and analysis results
uses: actions/download-artifact@v4
with:
name: compile-command-database-and-analysis-results
path: ${{ github.workspace }}/out/x64-Debug-Clang
# This step depends on the compile commands database
# created by CMake for the Clang build.
- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action@master
with:
pollingTimeoutSec: 600
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}