Skip to content

Commit

Permalink
Merge pull request #70 from asam-ev/2024-06-04
Browse files Browse the repository at this point in the history
Clean up repo, split runtime module and improve CI/CD
  • Loading branch information
pmai authored Jun 6, 2024
2 parents e96e30b + a48f3c1 commit 9a9af83
Show file tree
Hide file tree
Showing 53 changed files with 1,118 additions and 1,398 deletions.
File renamed without changes.
68 changes: 68 additions & 0 deletions .github/workflows/build-on-change-linux.yaml
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

152 changes: 152 additions & 0 deletions .github/workflows/build-on-change-windows.yaml
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



3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 17)

add_definitions( -DDEV_ESSENTIAL_DISABLE_MAKE_RESULT_CHECK_RESERVED_ZERO=1 -DDEV_ESSENTIAL_DISABLE_DEPRECATED_WARNINGS=1)

file(STRINGS version QC4OPENX_VERSION LIMIT_COUNT 1)
project(qc4openx VERSION ${QC4OPENX_VERSION})

Expand All @@ -44,7 +42,6 @@ elseif()
-Wall -Wextra -Wno-reorder -Wno-sign-compare)
endif()

find_package(dev_essential REQUIRED)
find_package(XercesC REQUIRED)

# QT
Expand Down
3 changes: 0 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ The ASAM Quality Checker Framework runs on Linux and Windows.

## 3rd Party Dependencies

- dev_essential
- Xerces-C++
- Qt 5
- **Optional:** GoogleTest (only if tests are enabled)
Expand Down Expand Up @@ -83,7 +82,6 @@ $ cmake -G "Visual Studio 16 2019" -A "x64" -T "v142" -B../build -S. ^
-DASAM_OPENDRIVE_XSD_DIR="<asam_opendrive_xsd_dir>" ^
-DASAM_OPENSCENARIO_XSD_DIR="<asam_openscenario_xsd_dir>" ^
-DXERCES_ROOT="<xerces_c_root>" ^
-Ddev_essential_ROOT="<dev_essential_root>" ^
-DQt5_ROOT="<qt5_root>"
$ cmake --build ../build --target ALL_BUILD --config Release
$ ctest --test-dir ../build -C Release
Expand All @@ -101,7 +99,6 @@ With the following CMake values:
files for OpenSCENARIO downloaded from the ASAM website (multiple versions of
the schema files in this directory are supported).
- _\<xerces_c_root\>_: The root dir of the pre-built Xerces-C++ package
- _\<dev_essential_ROOT\>_: The root dir of the pre-built dev_essential package
- _\<Qt5_ROOT\>_: The root dir of the pre-built qt5 package

### Options
Expand Down
4 changes: 2 additions & 2 deletions doc/schema/xqar_report_format.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

<xs:complexType name="IssueType">
<xs:sequence>
<xs:element name="Locations" type="LocationsType" minOccurs="1" maxOccurs="unbounded" />
<xs:element name="Locations" type="LocationsType" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="issueId" type="xs:string" />
<xs:attribute name="description" type="xs:string" />
Expand Down Expand Up @@ -61,7 +61,7 @@ with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
<xs:element name="CheckerResults">
<xs:complexType>
<xs:sequence>
<xs:element name="CheckerBundle" minOccurs="1" maxOccurs="unbounded" >
<xs:element name="CheckerBundle" minOccurs="0" maxOccurs="unbounded" >
<xs:complexType>
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
Expand Down
82 changes: 82 additions & 0 deletions docker/Dockerfile.linux
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/
29 changes: 29 additions & 0 deletions docker/test_runtime.sh
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

Loading

0 comments on commit 9a9af83

Please sign in to comment.