-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from asam-ev/2024-06-04
Clean up repo, split runtime module and improve CI/CD
- Loading branch information
Showing
53 changed files
with
1,118 additions
and
1,398 deletions.
There are no files selected for viewing
File renamed without changes.
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,68 @@ | ||
name: Build framework on Linux | ||
|
||
on: | ||
# execute on every PR made targeting the branches bellow | ||
pull_request: | ||
branches: | ||
- master | ||
- develop # can be removed on master merge | ||
paths: # we only include paths critical for building to avoid unnecessary runs | ||
- src/** | ||
- include/** | ||
- scripts/cmake/** | ||
- tests/** | ||
- .github/workflows/** | ||
- doc/** | ||
- runtime/** | ||
- docker/** | ||
|
||
# execute on every push made targeting the branches bellow | ||
push: | ||
branches: | ||
- master | ||
- develop # can be removed on master merge | ||
paths: # we only include paths critical for building to avoid unnecessary runs | ||
- src/** | ||
- include/** | ||
- scripts/cmake/** | ||
- .github/workflows/** | ||
- doc/** | ||
- runtime/** | ||
- docker/** | ||
|
||
jobs: | ||
build-linux: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Docker Build | ||
run: | | ||
docker build -f docker/Dockerfile.linux --target unit_test -t unit_test . | ||
docker build -f docker/Dockerfile.linux --target runtime_test -t runtime_test . | ||
- name: Unit test execution | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
docker run -v ${{ github.workspace }}:/out --name unit_test unit_test | ||
- name: Archive unit test results | ||
if: github.event_name == 'pull_request' && (success() || failure()) | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: unit-test-report | ||
path: ${{ github.workspace }}/LastTest.log | ||
|
||
- name: Runtime test execution | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
docker run -v ${{ github.workspace }}:/out --rm --name runtime_test runtime_test | ||
- name: Archive runtime test results | ||
if: github.event_name == 'pull_request' && (success() || failure()) | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: runtime-test-report | ||
path: ${{ github.workspace }}/runtime_test.log | ||
|
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,152 @@ | ||
name: Build framework on Windows | ||
|
||
on: | ||
# execute on every PR made targeting the branches bellow | ||
pull_request: | ||
branches: | ||
- master | ||
- develop # can be removed on master merge | ||
paths: # we only include paths critical for building to avoid unnecessary runs | ||
- src/** | ||
- include/** | ||
- scripts/cmake/** | ||
- test/** | ||
- .github/workflows/** | ||
- doc/** | ||
- runtime/** | ||
- docker/** | ||
|
||
# execute on every push made targeting the branches bellow | ||
push: | ||
branches: | ||
- master | ||
- develop # can be removed on master merge | ||
paths: # we only include paths critical for building to avoid unnecessary runs | ||
- src/** | ||
- include/** | ||
- scripts/cmake/** | ||
- .github/workflows/** | ||
- doc/** | ||
- runtime/** | ||
- docker/** | ||
|
||
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 | ||
|
||
- name: Add MSBuild to PATH | ||
uses: microsoft/setup-msbuild@v2 | ||
|
||
- name: Install Qt | ||
uses: jurplel/[email protected] | ||
with: | ||
version: 5.15.2 | ||
host: windows | ||
target: desktop | ||
arch: win64_msvc2019_64 | ||
|
||
- name: Install gtest | ||
if: github.event_name == 'pull_request' | ||
env: | ||
CXX: g++-10 | ||
run: | | ||
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 = "$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 "$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="$env:WORKING_PATH\Xerces-Out" .. | ||
cmake --build . --config Debug | ||
cmake --build . --config Debug --target install | ||
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: | | ||
Write-Output "Setting up QC-Framework..." | ||
cd "$env:WORKING_PATH\qc-framework\qc-framework" | ||
mkdir build | ||
cmake -H"$env:WORKING_PATH\qc-framework\qc-framework" -S. -Bbuild ` | ||
-G "Visual Studio 16 2019" -A x64 -T v142 ` | ||
-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="$env:WORKING_PATH\Xerces-Out" | ||
cmake --build build --target ALL_BUILD --config Release | ||
cmake --install build | ||
# Final output | ||
Write-Output "All installations and setups are complete!" | ||
shell: pwsh | ||
|
||
- name: Unit test execution | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
Write-Output "Starting unit tests..." | ||
cd "$env:WORKING_PATH\qc-framework\qc-framework" | ||
ctest --test-dir build -C Release | ||
Write-Output "All unit 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 | ||
|
||
- name: Runtime test execution | ||
if: github.event_name == 'pull_request' | ||
run: | | ||
Write-Output "Starting runtime tests..." | ||
Rename-Item -path "$env:WORKING_PATH\qc-framework\qc-framework\build" -NewName "$env:WORKING_PATH\qc-framework\qc-framework\out_build" | ||
Copy-Item -Path "$env:WORKING_PATH\QC-Framework-Out" -Destination "$env:WORKING_PATH\qc-framework\qc-framework\build" -Recurse | ||
Copy-Item -Path "$env:WORKING_PATH\qc-framework\qc-framework\out_build\examples\checker_bundle_example\Release\DemoCheckerBundle.exe" -Destination "$env:WORKING_PATH\qc-framework\qc-framework\build\bin" | ||
cd "$env:WORKING_PATH\qc-framework\qc-framework\runtime" | ||
python3 -m pip install -r requirements.txt | ||
python3 -m pytest | ||
Write-Output "All runtime tests done." | ||
shell: pwsh | ||
|
||
|
||
|
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
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,82 @@ | ||
# Copyright 2024, ASAM e.V. | ||
# This Source Code Form is subject to the terms of the Mozilla | ||
# Public License, v. 2.0. If a copy of the MPL was not distributed | ||
# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
FROM ubuntu:22.04 AS framework_builder | ||
|
||
SHELL ["/bin/bash", "-c"] | ||
|
||
RUN echo "Installing Dependencies..." && \ | ||
apt update && apt install -y \ | ||
g++ \ | ||
g++-10 \ | ||
make \ | ||
build-essential \ | ||
cmake \ | ||
libgtest-dev \ | ||
qtbase5-dev \ | ||
libqt5xmlpatterns5-dev \ | ||
libxerces-c-dev \ | ||
pkg-config && \ | ||
echo "Dependencies installed." | ||
|
||
RUN mkdir -p /app/framework | ||
|
||
COPY examples /app/framework/examples | ||
COPY include /app/framework/include | ||
COPY scripts /app/framework/scripts | ||
COPY src /app/framework/src | ||
COPY test /app/framework/test | ||
COPY doc /app/framework/doc | ||
COPY CMakeLists.txt /app/framework/CMakeLists.txt | ||
COPY version /app/framework/version | ||
COPY licenses /app/framework/licenses | ||
COPY runtime /app/framework/runtime | ||
|
||
RUN echo "Building framework..." && \ | ||
cd /app/framework && \ | ||
cmake -G "Unix Makefiles" -B./build -S . \ | ||
-DCMAKE_INSTALL_PREFIX="/home/$(whoami)/qc-build" \ | ||
-DENABLE_FUNCTIONAL_TESTS=ON -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." | ||
|
||
|
||
# Runtime stage | ||
FROM python:3.11.9-slim-bookworm as runtime_test | ||
|
||
RUN echo "Installing Qt..." && \ | ||
apt update && apt install -y \ | ||
qtbase5-dev \ | ||
libqt5xmlpatterns5-dev \ | ||
libxerces-c-dev \ | ||
pkg-config && \ | ||
echo "Dependencies installed." | ||
|
||
RUN mkdir -p /app | ||
|
||
COPY runtime/requirements.txt /app/ | ||
RUN pip install -r /app/requirements.txt | ||
|
||
# For testing files | ||
COPY --from=framework_builder /app/framework /app/framework | ||
# Copy install directory in runtime image | ||
COPY --from=framework_builder /home/root/qc-build /app/framework/build | ||
|
||
# @NOTE this is just because DemoCheckerBundle is not installed by default | ||
COPY --from=framework_builder /app/framework/build/examples/checker_bundle_example/DemoCheckerBundle /app/framework/build/bin/ | ||
|
||
ENV PYTHONUNBUFFERED=1 | ||
|
||
WORKDIR /app/framework/runtime/ | ||
|
||
CMD python3 -m pytest -rA > runtime_test.log && cp /app/framework/runtime/runtime_test.log /out/runtime_test.log | ||
|
||
# Runtime stage | ||
FROM framework_builder as unit_test | ||
|
||
CMD ctest --test-dir /app/framework/build -C Release && cp /app/framework/build/Testing/Temporary/LastTest.log /out/ |
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,29 @@ | ||
# Copyright 2024, ASAM e.V. | ||
# This Source Code Form is subject to the terms of the Mozilla | ||
# Public License, v. 2.0. If a copy of the MPL was not distributed | ||
# with this file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
readonly OUTPUT_DIR=$1 | ||
|
||
cd .. | ||
|
||
DOCKER_BUILDKIT=1 \ | ||
docker build \ | ||
-f docker/Dockerfile.linux \ | ||
--target runtime_test \ | ||
-t runtime_test . | ||
|
||
DOCKER_BUILDKIT=1 \ | ||
docker build \ | ||
-f docker/Dockerfile.linux \ | ||
--target unit_test \ | ||
-t unit_test . | ||
|
||
docker run \ | ||
-v "$OUTPUT_DIR":/out \ | ||
--rm --name runtime_test runtime_test | ||
|
||
docker run --rm \ | ||
-v "$OUTPUT_DIR":/out \ | ||
--name unit_test unit_test | ||
|
Oops, something went wrong.