-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add prebuild and robot test workflows (#1537)
* compile agent on windows runner fix fmt windows compile issue
- Loading branch information
1 parent
04e2c90
commit f611324
Showing
33 changed files
with
1,210 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# | ||
# Copyright 2024 Centreon | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
# | ||
# For more information : [email protected] | ||
# | ||
|
||
Write-Host "Work in" $pwd.ToString() | ||
|
||
[System.Environment]::SetEnvironmentVariable("AWS_EC2_METADATA_DISABLED","true") | ||
|
||
Write-Host $env:VCPKG_BINARY_SOURCES | ||
|
||
$current_dir = $pwd.ToString() | ||
|
||
#get cache from s3 | ||
$files_to_hash = "vcpkg.json", "custom-triplets\x64-windows.cmake", "CMakeLists.txt", "CMakeListsWindows.txt" | ||
$files_content = Get-Content -Path $files_to_hash -Raw | ||
$stringAsStream = [System.IO.MemoryStream]::new() | ||
$writer = [System.IO.StreamWriter]::new($stringAsStream) | ||
$writer.write($files_content -join " ") | ||
$writer.Flush() | ||
$stringAsStream.Position = 0 | ||
$vcpkg_hash = Get-FileHash -InputStream $stringAsStream -Algorithm SHA256 | Select-Object Hash | ||
$file_name = "windows-agent-vcpkg-dependencies-cache-" + $vcpkg_hash.Hash | ||
$file_name_extension = "${file_name}.7z" | ||
|
||
#try to get compiled dependenciesfrom s3 | ||
Write-Host "try to download compiled dependencies from s3" | ||
aws --quiet s3 cp s3://centreon-collect-robot-report/$file_name_extension $file_name_extension | ||
if ( $? -ne $true ) { | ||
#no => generate | ||
Write-Host "#######################################################################################################################" | ||
Write-Host "compiled dependencies unavailable for this version we will need to build it, it will take a long time" | ||
Write-Host "#######################################################################################################################" | ||
|
||
Write-Host "install vcpkg" | ||
git clone --depth 1 --single-branch --no-tags https://github.com/microsoft/vcpkg vcpkg | ||
cd vcpkg | ||
bootstrap-vcpkg.bat | ||
cd $current_dir | ||
|
||
[System.Environment]::SetEnvironmentVariable("VCPKG_ROOT",$pwd.ToString()+"\vcpkg") | ||
[System.Environment]::SetEnvironmentVariable("PATH",$pwd.ToString()+"\vcpkg;" + $env:PATH) | ||
|
||
Write-Host "compile vcpkg dependencies" | ||
vcpkg install --vcpkg-root $env:VCPKG_ROOT --x-install-root build_windows\vcpkg_installed --x-manifest-root . --overlay-triplets custom-triplets --triplet x64-windows | ||
|
||
Write-Host "Compress binary archive" | ||
7z a $file_name_extension build_windows\vcpkg_installed | ||
Write-Host "Upload binary archive" | ||
aws s3 cp $file_name_extension s3://centreon-collect-robot-report/$file_name_extension | ||
Write-Host "create CMake files" | ||
} | ||
else { | ||
7z x $file_name_extension | ||
Write-Host "Create cmake files from binary-cache downloaded without use vcpkg" | ||
} | ||
|
||
|
||
|
||
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 | ||
|
||
Write-Host "build agent and tests" | ||
|
||
cmake --build build_windows --config Release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Centreon Monitoring Agent Windows robot test | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build-agent: | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,71 @@ | ||
name: Centreon Monitoring Agent Windows packaging | ||
name: Centreon Monitoring Agent Windows build and packaging | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
paths: | ||
- agent/** | ||
- custom-triplets/** | ||
- CMakeLists.txt | ||
- CMakeListsWindows.txt | ||
- vcpkg.json | ||
push: | ||
branches: | ||
- develop | ||
- dev-[2-9][0-9].[0-9][0-9].x | ||
- master | ||
- "[2-9][0-9].[0-9][0-9].x" | ||
paths: | ||
- agent/** | ||
- custom-triplets/** | ||
- CMakeLists.txt | ||
- CMakeListsWindows.txt | ||
- vcpkg.json | ||
|
||
jobs: | ||
build: | ||
build-and-test-agent: | ||
runs-on: windows-latest | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.COLLECT_S3_ACCESS_KEY }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.COLLECT_S3_SECRET_KEY }} | ||
|
||
steps: | ||
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
- uses: ilammy/[email protected] | ||
- name: Checkout sources | ||
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | ||
|
||
- name: Compile Agent | ||
run: .github/scripts/windows-agent-compile.ps1 | ||
shell: powershell | ||
|
||
- name: Common test | ||
run: | | ||
cd build_windows | ||
tests/ut_common | ||
- name: install vcpkg | ||
- name: Agent test | ||
run: | | ||
git clone --depth 1 https://github.com/microsoft/vcpkg $HOME/vcpkg | ||
cd $HOME/vcpkg | ||
bootstrap-vcpkg.bat | ||
cd build_windows | ||
tests/ut_agent | ||
- name: Zip agent | ||
run: | | ||
$files_to_compress = "agent\conf\centagent.reg", "build_windows\agent\Release\centagent.exe" | ||
Compress-Archive -Path $files_to_compress -DestinationPath centreon-monitoring-agent.zip | ||
- name: Save agent package in cache | ||
uses: actions/cache/save@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 | ||
with: | ||
path: centreon-monitoring-agent.zip | ||
key: ${{ github.run_id }}-${{ github.sha }}-CMA-${{ github.head_ref || github.ref_name }} | ||
|
||
- name: Upload package artifacts | ||
if: ${{ false }} | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 | ||
with: | ||
name: packages-centreon-monitoring-agent-windows | ||
path: centreon-monitoring-agent.zip | ||
retention-days: 1 |
Oops, something went wrong.