Skip to content

Update createBundle.yml #109

Update createBundle.yml

Update createBundle.yml #109

Workflow file for this run

name: CI
on:
push:
branches: [ "main", "release/*" , "feature/*"]
# tags: ["v*"]
pull_request:
branches: [ "main", "release/*" ]
release:
types: [published]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
# for JamesIves/github-pages-deploy-action@v4
contents: write
pages: write
id-token: write
# for jUnit report
checks: write
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
NINJA_VERSION: 1.11.1
SCCACHE_VERSION: 0.3.0
jobs:
build:
strategy:
matrix:
config:
- {
name: "Windows 2019 MSVC",
artifact: "bin/ctrlppcheck.exe",
os: windows-2019,
cc: "cl", cxx: "cl",
environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
}
- {
name: "Ubuntu 2004 GCC",
artifact: "bin/ctrlppcheck",
os: ubuntu-20.04,
cc: "gcc", cxx: "g++"
}
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ${{ matrix.config.os }}
steps:
- uses: actions/checkout@v3
# Based on the work of https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/
# and https://github.com/cristianadam/HelloWorld
- name: Download Ninja and sccache
shell: cmake -P {0}
run: |
set(ninja_version $ENV{NINJA_VERSION})
set(sccache_version $ENV{SCCACHE_VERSION})
if ("${{ runner.os }}" STREQUAL "Windows")
set(ninja_suffix "win.zip")
set(sccache_suffix "x86_64-pc-windows-msvc")
set(sccache_ext ".tar.gz")
set(sccache_dir "sccache-v${sccache_version}-${sccache_suffix}")
elseif ("${{ runner.os }}" STREQUAL "Linux")
set(ninja_suffix "linux.zip")
set(sccache_suffix "x86_64-unknown-linux-musl")
set(sccache_ext ".tar.gz")
set(sccache_dir "sccache-v${sccache_version}-${sccache_suffix}")
endif()
set(ninja_url "https://github.com/ninja-build/ninja/releases/download/v${ninja_version}/ninja-${ninja_suffix}")
file(DOWNLOAD "${ninja_url}" ./ninja.zip SHOW_PROGRESS)
message(STATUS "Download ${ninja_url}")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./ninja.zip)
set(sccache_url "https://github.com/mozilla/sccache/releases/download/v${sccache_version}/${sccache_dir}${sccache_ext}")
message(STATUS "Download ${sccache_url}")
file(DOWNLOAD "${sccache_url}" ./sccache.tar.gz SHOW_PROGRESS)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xvf ./sccache.tar.gz)
file(GLOB_RECURSE mydirs LIST_DIRECTORIES true)
message(STATUS "${mydirs}")
set(path_separator ":")
if ("${{ runner.os }}" STREQUAL "Windows")
set(path_separator ";")
endif()
file(TO_NATIVE_PATH "$ENV{GITHUB_WORKSPACE}/${sccache_dir}" sccache_dir)
file(APPEND "$ENV{GITHUB_PATH}" "$ENV{GITHUB_WORKSPACE}${path_separator}${sccache_dir}")
if (NOT "${{ runner.os }}" STREQUAL "Windows")
execute_process(
COMMAND chmod +x ninja
COMMAND chmod +x ${sccache_dir}/sccache
)
endif()
- name: sccache cache files
uses: actions/cache@v3
with:
path: .sccache
key: ${{ matrix.config.name }}-sccache
- name: Version info
run: ninja --version && sccache --version && cmake --version
- name: Configure CMake
shell: cmake -P {0}
run: |
set(ENV{CC} ${{ matrix.config.cc }})
set(ENV{CXX} ${{ matrix.config.cxx }})
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
execute_process(
COMMAND "${{ matrix.config.environment_script }}" && set
OUTPUT_FILE environment_script_output.txt
)
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
execute_process(
COMMAND cmake
-S ctrlppcheck
-B $ENV{GITHUB_WORKSPACE}/build
-D CMAKE_BUILD_TYPE=$ENV{BUILD_TYPE}
-G Ninja
-D CMAKE_C_COMPILER_LAUNCHER=sccache
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache
-D USE_MATCHCOMPILER=Off
RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
message(FATAL_ERROR "Bad exit status")
endif()
- name: Build
shell: cmake -P {0}
run: |
set(ENV{NINJA_STATUS} "[%f/%t %o/sec] ")
if ("${{ runner.os }}" STREQUAL "Windows" AND NOT "x${{ matrix.config.environment_script }}" STREQUAL "x")
file(STRINGS environment_script_output.txt output_lines)
foreach(line IN LISTS output_lines)
if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
set(ENV{${CMAKE_MATCH_1}} "${CMAKE_MATCH_2}")
endif()
endforeach()
endif()
file(TO_CMAKE_PATH "$ENV{GITHUB_WORKSPACE}/.sccache" sccache_dir)
set(ENV{SCCACHE_DIR} "${sccache_dir}")
set(ENV{SCCACHE_CACHE_SIZE} "100M")
execute_process(
COMMAND cmake --build $ENV{GITHUB_WORKSPACE}/build --config $ENV{BUILD_TYPE}
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
ECHO_OUTPUT_VARIABLE ECHO_ERROR_VARIABLE
)
if (NOT result EQUAL 0)
string(REGEX MATCH "FAILED:.*$" error_message "${output}")
string(REPLACE "\n" "%0A" error_message "${error_message}")
message("::error::${error_message}")
message(FATAL_ERROR "Build failed")
else()
execute_process(COMMAND sccache --show-stats)
endif()
- name: Upload ctrlppcheck
uses: actions/upload-artifact@v3
with:
name: ctrlppcheck
path: ${{github.workspace}}/build/${{ matrix.config.artifact }}
buildHelp:
name: Build help
runs-on: ubuntu-20.04
container:
image: mpokornyetm/winccoa:v3.19.8-full
options: --user root
credentials:
username: mpokornyetm
password: Katopeso1#
steps:
- name: Install doxygen
working-directory: /opt/WinCC_OA/3.19/bin/
run: |
apt-get update
apt-get --assume-yes install -f doxygen graphviz
- uses: actions/checkout@v1
- name: Register Project
working-directory: ${{github.workspace}}/WinCCOA_QualityChecks/
run: |
cwd=$(pwd)
mkdir -p $cwd/config
cd $cwd/config
echo "[general]
pvss_path = \"/opt/WinCC_OA/3.19\"
proj_path = \"$cwd\"
proj_version = \"3.19\"
langs = \"en_US.utf8\"
pmonPort = 5999
" > config
mkdir -p $cwd/log
/opt/WinCC_OA/3.19/bin/WCCILpmon -config $cwd/config/config -n -autofreg -status -log +stderr || true
- name: Generate help
working-directory: /opt/WinCC_OA/3.19/bin/
run: |
./WCCOActrl -proj WinCCOA_QualityChecks -n doxygen.ctl -log +stderr -lang en_US.utf8
- name: Upload html help
uses: actions/upload-artifact@v3
with:
name: html-help
path: ${{github.workspace}}/WinCCOA_QualityChecks/help/html/*
- name: Upload QT help
uses: actions/upload-artifact@v3
with:
name: qt-help
path: ${{github.workspace}}/WinCCOA_QualityChecks/help/html/index.qch
package:
name: Package project and binaries
runs-on: ubuntu-20.04
needs: [build, buildHelp]
steps:
- uses: actions/checkout@v3
- name: Prepare file structure and project
run: |
mkdir -p ${{github.workspace}}/install/WinCCOA_QualityChecks/bin/ctrlppcheck
cp -rp ${{github.workspace}}/WinCCOA_QualityChecks/* ${{github.workspace}}/install/WinCCOA_QualityChecks/
mkdir -p ${{github.workspace}}/tests/WinCC_OA_Test/
cp -rp ${{github.workspace}}/WinCC_OA_Test/* ${{github.workspace}}/tests/WinCC_OA_Test/
mkdir -p ${{github.workspace}}/install/WinCCOA_QualityChecks/help
- name: Download ctrlppcheck binaries
uses: actions/download-artifact@v3
with:
name: ctrlppcheck
path: ${{github.workspace}}/install/WinCCOA_QualityChecks/bin/ctrlppcheck/
- name: Add x bit to Linux binary
run: |
chmod +x ${{github.workspace}}/install/WinCCOA_QualityChecks/bin/ctrlppcheck/ctrlppcheck
- name: Download help
uses: actions/download-artifact@v3
with:
name: qt-help
path: ${{github.workspace}}/install/WinCCOA_QualityChecks/help/index.qch
- name: Upload WinCCOA_QualityChecks
uses: actions/upload-artifact@v3
with:
name: WinCCOA_QualityChecks
path: ${{github.workspace}}/install/*
- name: Upload WinCC_OA_Test
uses: actions/upload-artifact@v3
with:
name: WinCC_OA_Test
path: ${{github.workspace}}/tests/*
tests:
name: WinCC OA tests
runs-on: ubuntu-20.04
container:
image: mpokornyetm/winccoa:v3.19.8-full
options: --user root
credentials:
username: mpokornyetm
password: Katopeso1#
needs: [build, package]
steps:
- name: Print WinCC OA version
shell: bash
run: |
/opt/WinCC_OA/3.19/bin/WCCOActrl -version || true
- name: Download WinCCOA_QualityChecks package
uses: actions/download-artifact@v3
with:
name: WinCCOA_QualityChecks
path: ${{github.workspace}}/
- name: Download WinCC_OA_Test
uses: actions/download-artifact@v3
with:
name: WinCC_OA_Test
path: ${{github.workspace}}/
- name: 'Echo download path'
run: echo ${{steps.download.outputs.download-path}}
- name: Register Ctrl TestFramework
working-directory: ${{github.workspace}}/WinCC_OA_Test/
run: |
cwd=$(pwd)
mkdir -p $cwd/Projects/TfCustomizedQG/config
cd $cwd/Projects/TfCustomizedQG/config
echo "[general]
pvss_path = \"/opt/WinCC_OA/3.19\"
proj_path = \"/opt/WinCC_OA/3.19/TestFramework_3.19\"
proj_path = \"$cwd/Projects/Global\"
proj_path = \"$cwd/Projects/TfCustomizedQG\"
proj_version = \"3.19\"
langs = \"de_AT.utf8\"
langs = \"en_US.utf8\"
pmonPort = 5999
[testFramework]
installPath = \"$cwd/\"
" > config
mkdir -p $$cwd/Projects/TfCustomizedQG/log
/opt/WinCC_OA/3.19/bin/WCCILpmon -config $cwd/Projects/TfCustomizedQG/config/config -n -autofreg -status -log +stderr || true
- name: Add x bit to Linux binary
run: |
chmod +x /__w/CtrlppCheck/CtrlppCheck/WinCCOA_QualityChecks/bin/ctrlppcheck/ctrlppcheck
- name: Start WinCC OA tests
working-directory: /opt/WinCC_OA/3.19/bin/
run: |
echo ****** Execute WinCC OA Tests
./WCCOActrl -proj TfCustomizedQG -n testRunner.ctl {\'testRunId\':\'Regression-tests\',\'registerGlobalProject\':true,\'registerAllTools\':true,\'registerAllTemplates\':true,\'showLogViewer\':false,\'TfTestManager.checkForPossibleFreezeTests\':true} -log +stderr -lang en_US.utf8
- name: Convert WinCC OA tests to jUnit
working-directory: /opt/WinCC_OA/3.19/bin/
run: |
echo ****** Convert results into jUnit format
./WCCOActrl -proj TfCustomizedQG -n oaTestParsers/jsonToJUnit.ctl -log +stderr -lang en_US.utf8
- name: Publish Failed projects
uses: actions/upload-artifact@v3
with:
name: failed-test-projects
path: /__w/CtrlppCheck/CtrlppCheck/WinCC_OA_Test/Projects/Stored/Failed/
if-no-files-found: ignore # #error', 'warn' or 'ignore' are also available, defaults to `warn`
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
with:
fail_on_failure : true
require_tests : true
report_paths : /__w/CtrlppCheck/CtrlppCheck/WinCC_OA_Test/Results/jUnit*.xml
release:
if: github.event_name == 'release'
name: Release
runs-on: ubuntu-20.04
needs: tests
steps:
- name: Get the version
id: get_version
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: WinCCOA_QualityChecks
path: ${{github.workspace}}/install/
- name: Zip Folder
run: cd ${{ github.workspace }}/install/ && zip -r ${{ github.workspace }}/WinCCOA_QualityChecks_${{ github.event.release.tag_name }}.zip *
- name: Upload to Release
id: upload_to_release
uses: softprops/action-gh-release@v1
with:
files: WinCCOA_QualityChecks_${{ github.event.release.tag_name }}.zip
publish-help:
# !! TODO enable it only on release
# if: github.event_name == 'release'
name: Publish help
runs-on: ubuntu-latest
needs: tests
steps:
- name: Download help
uses: actions/download-artifact@v3
with:
name: html-help
path: ${{github.workspace}}/docs/
- name: Create .nojekyll (ensures pages with underscores work on gh pages)
run: touch ./docs/.nojekyll
shell: bash
- name: Publish GitHub pages help
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: ./docs/