forked from siemens/CtrlppCheck
-
Notifications
You must be signed in to change notification settings - Fork 0
411 lines (355 loc) · 13.9 KB
/
createBundle.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
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:
contents: read
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@v4
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@v4
with:
name: html-help
path: ${{github.workspace}}/WinCCOA_QualityChecks/help/html/*
- name: Upload QT help
uses: actions/upload-artifact@v4
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: 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@v4
with:
name: WinCCOA_QualityChecks
path: ${{github.workspace}}/install/*
- name: Upload WinCC_OA_Test
uses: actions/upload-artifact@v4
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: 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: Add x bit to Linux binary
run: |
chmod +x ${{ github.workspace }}/WinCCOA_QualityChecks/bin/ctrlppcheck/ctrlppcheck
- name: Publish Failed projects
uses: actions/upload-artifact@v4
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: Add x bit to Linux binary
run: |
chmod +x ${{ github.workspace }}/install/WinCCOA_QualityChecks/bin/ctrlppcheck/ctrlppcheck
- 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
# inspired by https://nimblehq.co/blog/create-github-wiki-pull-request
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:
token: ${{ secrets.WIKI_ACTION_TOKEN }}
branch: gh-pages
folder: ${{ inputs.folder }}
# target-folder: ${{ inputs.target_folder }}