Skip to content

Commit

Permalink
CI/CD: Add tests to workflows (#58)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Abrahão <[email protected]>

Signed-off-by: Patrick Abrahão <[email protected]>
  • Loading branch information
patrickpa authored and hoangtungdinh committed Jun 5, 2024
1 parent 98796e3 commit 71bad84
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 18 deletions.
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

0 comments on commit 71bad84

Please sign in to comment.