Skip to content

Commit f611324

Browse files
add prebuild and robot test workflows (#1537)
* compile agent on windows runner fix fmt windows compile issue
1 parent 04e2c90 commit f611324

33 files changed

+1210
-314
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#
2+
# Copyright 2024 Centreon
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
# use this file except in compliance with the License. You may obtain a copy of
6+
# the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations under
14+
# the License.
15+
#
16+
# For more information : [email protected]
17+
#
18+
19+
Write-Host "Work in" $pwd.ToString()
20+
21+
[System.Environment]::SetEnvironmentVariable("AWS_EC2_METADATA_DISABLED","true")
22+
23+
Write-Host $env:VCPKG_BINARY_SOURCES
24+
25+
$current_dir = $pwd.ToString()
26+
27+
#get cache from s3
28+
$files_to_hash = "vcpkg.json", "custom-triplets\x64-windows.cmake", "CMakeLists.txt", "CMakeListsWindows.txt"
29+
$files_content = Get-Content -Path $files_to_hash -Raw
30+
$stringAsStream = [System.IO.MemoryStream]::new()
31+
$writer = [System.IO.StreamWriter]::new($stringAsStream)
32+
$writer.write($files_content -join " ")
33+
$writer.Flush()
34+
$stringAsStream.Position = 0
35+
$vcpkg_hash = Get-FileHash -InputStream $stringAsStream -Algorithm SHA256 | Select-Object Hash
36+
$file_name = "windows-agent-vcpkg-dependencies-cache-" + $vcpkg_hash.Hash
37+
$file_name_extension = "${file_name}.7z"
38+
39+
#try to get compiled dependenciesfrom s3
40+
Write-Host "try to download compiled dependencies from s3"
41+
aws --quiet s3 cp s3://centreon-collect-robot-report/$file_name_extension $file_name_extension
42+
if ( $? -ne $true ) {
43+
#no => generate
44+
Write-Host "#######################################################################################################################"
45+
Write-Host "compiled dependencies unavailable for this version we will need to build it, it will take a long time"
46+
Write-Host "#######################################################################################################################"
47+
48+
Write-Host "install vcpkg"
49+
git clone --depth 1 --single-branch --no-tags https://github.com/microsoft/vcpkg vcpkg
50+
cd vcpkg
51+
bootstrap-vcpkg.bat
52+
cd $current_dir
53+
54+
[System.Environment]::SetEnvironmentVariable("VCPKG_ROOT",$pwd.ToString()+"\vcpkg")
55+
[System.Environment]::SetEnvironmentVariable("PATH",$pwd.ToString()+"\vcpkg;" + $env:PATH)
56+
57+
Write-Host "compile vcpkg dependencies"
58+
vcpkg install --vcpkg-root $env:VCPKG_ROOT --x-install-root build_windows\vcpkg_installed --x-manifest-root . --overlay-triplets custom-triplets --triplet x64-windows
59+
60+
Write-Host "Compress binary archive"
61+
7z a $file_name_extension build_windows\vcpkg_installed
62+
Write-Host "Upload binary archive"
63+
aws s3 cp $file_name_extension s3://centreon-collect-robot-report/$file_name_extension
64+
Write-Host "create CMake files"
65+
}
66+
else {
67+
7z x $file_name_extension
68+
Write-Host "Create cmake files from binary-cache downloaded without use vcpkg"
69+
}
70+
71+
72+
73+
cmake -DCMAKE_BUILD_TYPE=Release -DWITH_TESTING=On -DWINDOWS=On -DBUILD_FROM_CACHE=On -S. -DVCPKG_CRT_LINKAGE=dynamic -DBUILD_SHARED_LIBS=OFF -Bbuild_windows
74+
75+
Write-Host "build agent and tests"
76+
77+
cmake --build build_windows --config Release
78+

.github/workflows/centreon-collect.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ on:
2121
- cmake.sh
2222
- cmake-vcpkg.sh
2323
- CMakeLists.txt
24+
- CMakeListsLinux.txt
2425
- vcpkg.json
2526
- overlays/**
2627
- selinux/**
27-
- vcpkg/**
2828
- "!.veracode-exclusions"
2929
- "!veracode.json"
3030
- "!**/test/**"
@@ -48,10 +48,10 @@ on:
4848
- cmake.sh
4949
- cmake-vcpkg.sh
5050
- CMakeLists.txt
51+
- CMakeListsLinux.txt
5152
- vcpkg.json
5253
- overlays/**
5354
- selinux/**
54-
- vcpkg/**
5555
- "!.veracode-exclusions"
5656
- "!veracode.json"
5757
- "!**/test/**"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Centreon Monitoring Agent Windows robot test
2+
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
5+
cancel-in-progress: true
6+
7+
on:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-agent:
12+
runs-on: windows-latest
13+
steps:
14+
- name: Checkout sources
15+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

.github/workflows/windows-agent.yml

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,71 @@
1-
name: Centreon Monitoring Agent Windows packaging
1+
name: Centreon Monitoring Agent Windows build and packaging
22

33
concurrency:
44
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
55
cancel-in-progress: true
66

77
on:
88
workflow_dispatch:
9+
pull_request:
10+
paths:
11+
- agent/**
12+
- custom-triplets/**
13+
- CMakeLists.txt
14+
- CMakeListsWindows.txt
15+
- vcpkg.json
16+
push:
17+
branches:
18+
- develop
19+
- dev-[2-9][0-9].[0-9][0-9].x
20+
- master
21+
- "[2-9][0-9].[0-9][0-9].x"
22+
paths:
23+
- agent/**
24+
- custom-triplets/**
25+
- CMakeLists.txt
26+
- CMakeListsWindows.txt
27+
- vcpkg.json
928

1029
jobs:
11-
build:
30+
build-and-test-agent:
1231
runs-on: windows-latest
32+
env:
33+
AWS_ACCESS_KEY_ID: ${{ secrets.COLLECT_S3_ACCESS_KEY }}
34+
AWS_SECRET_ACCESS_KEY: ${{ secrets.COLLECT_S3_SECRET_KEY }}
35+
1336
steps:
14-
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
15-
- uses: ilammy/[email protected]
37+
- name: Checkout sources
38+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
39+
40+
- name: Compile Agent
41+
run: .github/scripts/windows-agent-compile.ps1
42+
shell: powershell
43+
44+
- name: Common test
45+
run: |
46+
cd build_windows
47+
tests/ut_common
1648
17-
- name: install vcpkg
49+
- name: Agent test
1850
run: |
19-
git clone --depth 1 https://github.com/microsoft/vcpkg $HOME/vcpkg
20-
cd $HOME/vcpkg
21-
bootstrap-vcpkg.bat
51+
cd build_windows
52+
tests/ut_agent
53+
54+
- name: Zip agent
55+
run: |
56+
$files_to_compress = "agent\conf\centagent.reg", "build_windows\agent\Release\centagent.exe"
57+
Compress-Archive -Path $files_to_compress -DestinationPath centreon-monitoring-agent.zip
58+
59+
- name: Save agent package in cache
60+
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
61+
with:
62+
path: centreon-monitoring-agent.zip
63+
key: ${{ github.run_id }}-${{ github.sha }}-CMA-${{ github.head_ref || github.ref_name }}
64+
65+
- name: Upload package artifacts
66+
if: ${{ false }}
67+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
68+
with:
69+
name: packages-centreon-monitoring-agent-windows
70+
path: centreon-monitoring-agent.zip
71+
retention-days: 1

0 commit comments

Comments
 (0)