Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI/CD: Add tests to workflows #58

Merged
merged 29 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0b31523
Add linux conditional test on PR
patrickpa May 24, 2024
b2af538
Update Gtest install to github actions installation
patrickpa May 24, 2024
35dc9f8
Move gtest to 1.11.0 to test install
patrickpa May 24, 2024
29f16b4
Move g++ to 10 to build proper gtest version
patrickpa May 24, 2024
2c1e282
Add first attempt to test on Windows runner
patrickpa May 24, 2024
89eecb8
Remove working environment directory
patrickpa May 24, 2024
7e55541
Add visual studio to gtest build
patrickpa May 24, 2024
6cc77df
Set cmake for install
patrickpa May 24, 2024
ce4f447
Add cd to test to be on proper folder
patrickpa May 24, 2024
41cbde2
Set working path to proper env
patrickpa May 24, 2024
469b6b4
Fix gtest root path
patrickpa May 24, 2024
8b2f0fa
Update tests to specify exactly .exe to run
patrickpa May 24, 2024
9e39872
Set gtest to force shared crt
patrickpa May 24, 2024
b782c24
Remove wrong flag on buikd
patrickpa May 24, 2024
c4d4170
Set build back to ALL_BUILD
patrickpa May 24, 2024
7177c30
Fix wrong quotation sign
patrickpa May 24, 2024
bb720d6
Add debug dir to test folder
patrickpa May 24, 2024
9b7d498
Add release to tests src path
patrickpa May 24, 2024
6d3a509
Update test to use ctest
patrickpa May 24, 2024
0ac069c
Add test artifact upload after tests are done
patrickpa May 27, 2024
a99fc42
Add condition to always run the test archive step
patrickpa May 27, 2024
6562ac8
Set archive path to complete path for log file
patrickpa May 27, 2024
3e318c5
Set both workflows to output on same path
patrickpa May 27, 2024
be65b0d
Update to ctest on linux execution
patrickpa May 27, 2024
b312175
Remove exceptional rule for running workflow on PRs on github actions…
patrickpa May 27, 2024
bdd528b
Merge develop branch into test CI/CD branch
patrickpa May 27, 2024
1d9be74
Add github workflows to target paths to test
patrickpa May 27, 2024
ee0d098
Merge branch 'develop' of https://github.com/asam-ev/qc-framework int…
patrickpa May 27, 2024
e1f18d9
Remove testing path from workflows
patrickpa May 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions .github/workflows/build-on-change-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- src/**
- include/**
- scripts/cmake/**
- tests/**

# execute on every push made targeting the branches bellow
push:
Expand All @@ -24,6 +25,8 @@ on:
jobs:
build-linux:
runs-on: ubuntu-22.04
env:
TEST_ENABLED: ${{ github.event_name == 'pull_request' && 'ON' || 'OFF' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand Down Expand Up @@ -52,16 +55,53 @@ jobs:
echo Dependencies installed.
shell: bash

- name: Install gtest
working-directory: dependencies
if: github.event_name == 'pull_request'
env:
CXX: g++-10
run: |
echo Installing gtest...

git clone https://github.com/google/googletest.git -b release-1.10.0
cd googletest
mkdir build
cd build
cmake ..
make
sudo make install

echo Gtest installed.
shell: bash

- name: Build framework
# Currently this is building without the XSD file. If we want to expose
# the build artifact after, we might as well need to add the XSD file.
run: |
echo Building framework...
cmake -G "Unix Makefiles" -B./build -S . -DCMAKE_INSTALL_PREFIX="/home/$(whoami)/qc-build" \
-DENABLE_FUNCTIONAL_TESTS=OFF -DXERCES_ROOT="/usr" \
cmake -G "Unix Makefiles" -B./build -S . \
-DCMAKE_INSTALL_PREFIX="/home/$(whoami)/qc-build" \
-DENABLE_FUNCTIONAL_TESTS=$TEST_ENABLED -DXERCES_ROOT="/usr" \
-DQt5_DIR="/usr/lib/x86_64-linux-gnu/cmake/Qt5/" \
-DQt5XmlPatterns_DIR="/usr/lib/x86_64-linux-gnu/cmake/Qt5XmlPatterns/"
cmake --build ./build --target install --config Release -j4
cmake --install ./build
echo Done.
shell: bash

- name: Test
if: github.event_name == 'pull_request'
run: |
echo Starting tests...

ctest --test-dir build -C Release

echo All tests done.
shell: bash

- name: Archive test results
if: github.event_name == 'pull_request' && (success() || failure())
uses: actions/upload-artifact@v4
with:
name: test-report
path: ${{ github.workspace }}/build/Testing/Temporary/LastTest.log
72 changes: 56 additions & 16 deletions .github/workflows/build-on-change-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
- src/**
- include/**
- scripts/cmake/**
- test/**

# execute on every push made targeting the branches bellow
push:
Expand All @@ -24,6 +25,9 @@ on:
jobs:
build-windows:
runs-on: windows-2019
env:
TEST_ENABLED: ${{ github.event_name == 'pull_request' && 'ON' || 'OFF' }}
WORKING_PATH: "D:\\a"
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -39,42 +43,59 @@ jobs:
target: desktop
arch: win64_msvc2019_64

- name: Install dependencies
- name: Install gtest
if: github.event_name == 'pull_request'
env:
CXX: g++-10
run: |
$workingPath = "D:\a"
Write-Output "Installing gtest..."

git clone https://github.com/google/googletest.git -b release-1.10.0
cd googletest
mkdir build
cd build
cmake -G "Visual Studio 16 2019" `
-Dgtest_force_shared_crt=ON `
-DCMAKE_INSTALL_PREFIX="$env:WORKING_PATH\gtest-Out" ..
cmake --build . --config Release
cmake --build . --config Release --target install

Write-Output "Gtest installed."
shell: pwsh

- name: Install XercesC
run: |
Write-Output "Setting up Xerces-C++..."
$xercesZip = "$workingPath\xerces-c-3.2.5.zip"
$xercesZip = "$env:WORKING_PATH\xerces-c-3.2.5.zip"
Invoke-WebRequest -Uri "https://dlcdn.apache.org/xerces/c/3/sources/xerces-c-3.2.5.zip" -OutFile $xercesZip
Expand-Archive -Path $xercesZip -DestinationPath "$workingPath"
cd "$workingPath\xerces-c-3.2.5"
Expand-Archive -Path $xercesZip -DestinationPath "$env:WORKING_PATH"
cd "$env:WORKING_PATH\xerces-c-3.2.5"
mkdir build
cd build
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="$workingPath\Xerces-Out" ..
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX="$env:WORKING_PATH\Xerces-Out" ..
cmake --build . --config Debug
cmake --build . --config Debug --target install

Add-Content $env:GITHUB_PATH "$workingPath\bin\xerces-c_3_2D.dll"
Add-Content $env:GITHUB_PATH "$workingPath\Xerces-Out\include"
Add-Content $env:GITHUB_PATH "$workingPath\Xerces-Out\bin"
Add-Content $env:GITHUB_PATH "$env:WORKING_PATH\bin\xerces-c_3_2D.dll"
Add-Content $env:GITHUB_PATH "$env:WORKING_PATH\Xerces-Out\include"
Add-Content $env:GITHUB_PATH "$env:WORKING_PATH\Xerces-Out\bin"

shell: pwsh

- name: Build framework
run: |
$workingPath = "D:\a"

Write-Output "Setting up QC-Framework..."

cd "$workingPath\qc-framework\qc-framework"
cd "$env:WORKING_PATH\qc-framework\qc-framework"
mkdir build

cmake -H"$workingPath\qc-framework\qc-framework" -S. -Bbuild `
cmake -H"$env:WORKING_PATH\qc-framework\qc-framework" -S. -Bbuild `
-G "Visual Studio 16 2019" -A x64 -T v142 `
-DCMAKE_INSTALL_PREFIX="$workingPath\QC-Framework-Out" `
-DENABLE_FUNCTIONAL_TESTS=OFF `
-DCMAKE_INSTALL_PREFIX="$env:WORKING_PATH\QC-Framework-Out" `
-DENABLE_FUNCTIONAL_TESTS="$env:TEST_ENABLED" `
-DGTest_ROOT="$env:WORKING_PATH\gtest-Out" `
-DQt5_ROOT="$env:Qt5_DIR\Qt5\" `
-DXercesC_ROOT="$workingPath\Xerces-Out"
-DXercesC_ROOT="$env:WORKING_PATH\Xerces-Out"

cmake --build build --target ALL_BUILD --config Release

Expand All @@ -83,3 +104,22 @@ jobs:
# Final output
Write-Output "All installations and setups are complete!"
shell: pwsh

- name: Test
if: github.event_name == 'pull_request'
run: |
Write-Output "Starting tests..."

cd "$env:WORKING_PATH\qc-framework\qc-framework"

ctest --test-dir build -C Release

Write-Output "All tests done."
shell: pwsh

- name: Archive test results
if: github.event_name == 'pull_request' && (success() || failure())
uses: actions/upload-artifact@v4
with:
name: test-report
path: ${{ github.workspace }}\build\Testing\Temporary\LastTest.log