diff --git a/.github/workflows/build-on-change-linux.yaml b/.github/workflows/build-on-change-linux.yaml index 44151c99..f754ed49 100644 --- a/.github/workflows/build-on-change-linux.yaml +++ b/.github/workflows/build-on-change-linux.yaml @@ -10,6 +10,7 @@ on: - src/** - include/** - scripts/cmake/** + - tests/** # execute on every push made targeting the branches bellow push: @@ -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 @@ -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 diff --git a/.github/workflows/build-on-change-windows.yaml b/.github/workflows/build-on-change-windows.yaml index cfad9cc9..b33d5b8d 100644 --- a/.github/workflows/build-on-change-windows.yaml +++ b/.github/workflows/build-on-change-windows.yaml @@ -10,6 +10,7 @@ on: - src/** - include/** - scripts/cmake/** + - test/** # execute on every push made targeting the branches bellow push: @@ -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 @@ -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 @@ -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