Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
154 changes: 115 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ jobs:
include:
- os: ubuntu-22.04
job_name: linux
qt_host: 'linux'
qt_arch: 'linux_gcc_64'
vcpkg_triplet: 'x64-linux'
qt_version: '6.9.*'
artifact_name: 'app-linux.tar.gz'

- os: macos-14
Expand Down Expand Up @@ -64,18 +60,13 @@ jobs:
with:
submodules: recursive

- name: Install System Dependencies (Linux)
if: matrix.os == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev xvfb patchelf libproj-dev libunwind-dev libgoogle-perftools-dev

- name: Install System Dependencies (macOS)
if: matrix.os == 'macos-14'
run: |
brew install proj

- name: Install Qt
if: matrix.os != 'ubuntu-22.04'
uses: jurplel/install-qt-action@v4
with:
version: ${{ matrix.qt_version }}
Expand All @@ -90,9 +81,6 @@ jobs:
# We do not manually cache the vcpkg tool/repository itself since bootstrapping the exe is extremely fast (< 1s),
# and this avoids hitting GitHub's 10GB cache limit or caching corrupt/outdated repositories.




- name: Cache vcpkg binary packages
if: matrix.os == 'windows-2022'
uses: actions/cache@v4
Expand Down Expand Up @@ -133,20 +121,18 @@ jobs:
VCPKG_DOWNLOADS: ${{ env.VCPKG_DOWNLOADS }}

- name: Set Environment Variables
if: matrix.os != 'ubuntu-22.04'
shell: bash
run: |
echo "QT6_ROOT=${{ env.QT_ROOT_DIR }}" >> $GITHUB_ENV
if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then
echo "PROJ_ROOT=/usr" >> $GITHUB_ENV
elif [ "${{ matrix.os }}" = "macos-14" ]; then
if [ "${{ matrix.os }}" = "macos-14" ]; then
echo "PROJ_ROOT=$(brew --prefix proj)" >> $GITHUB_ENV
elif [ "${{ matrix.os }}" = "windows-2022" ]; then
# Elegant solution: vcpkg in manifest mode puts artifacts in vcpkg_installed/<triplet>.
# The packaging script will find all DLLs inside the 'bin' subdirectory.
echo "PROJ_ROOT=${{ github.workspace }}/vcpkg_installed/${{ matrix.vcpkg_triplet }}" >> $GITHUB_ENV
fi

- name: Cache Bazel
if: matrix.os != 'ubuntu-22.04'
uses: actions/cache@v5
with:
path: |
Expand All @@ -157,18 +143,82 @@ jobs:
restore-keys: |
bazel-${{ matrix.os }}-

- name: Cache CMake FetchContent (Linux Musl)
if: matrix.os == 'ubuntu-22.04'
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/cmake_deps
key: cmake-deps-alpine-${{ hashFiles('CMakeLists.txt', 'src/CMakeLists.txt') }}
restore-keys: |
cmake-deps-alpine-

- name: Cache Ccache (Linux Musl)
if: matrix.os == 'ubuntu-22.04'
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/.ccache
key: ccache-alpine-${{ github.sha }}
restore-keys: |
ccache-alpine-

- name: Build, Test & Package (Linux Musl)
if: matrix.os == 'ubuntu-22.04'
run: |
mkdir -p ${{ github.workspace }}/cmake_deps
mkdir -p ${{ github.workspace }}/.ccache
docker run -i --rm \
-v ${{ github.workspace }}:/workspace \
-v ${{ github.workspace }}/.ccache:/root/.ccache \
-w /workspace alpine:3.20 sh << 'EOF'
set -e
apk update
apk add --no-cache alpine-sdk build-base cmake ninja ccache qt6-qtbase-dev qt6-qtbase-x11 mesa-dev qt6-qttools-dev proj-dev patchelf libunwind-dev bash xvfb xvfb-run mesa-dri-gallium mesa-gl mesa-egl
apk add --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing gperftools-dev || true

# Configure ccache
export CCACHE_DIR=/root/.ccache
export CCACHE_MAXSIZE=500M
ccache --zero-stats

# Configure and Build with ccache
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DFETCHCONTENT_BASE_DIR="/workspace/cmake_deps" \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build build --config RelWithDebInfo

# Show ccache stats
ccache --show-stats

# Test
cd build
xvfb-run --auto-servernum ctest -C RelWithDebInfo --output-on-failure
cd ..

# Package if it's a release tag
if [ "${{ startsWith(github.ref, 'refs/tags/v') }}" = "true" ] || [ "${{ github.ref_type }}" = "tag" ]; then
export QT6_ROOT=/usr/lib/qt6
export PROJ_ROOT=/usr
chmod +x scripts/deploy/package_linux.sh
./scripts/deploy/package_linux.sh
fi
EOF

# Create archive for release
if [ "${{ startsWith(github.ref, 'refs/tags/v') }}" = "true" ] || [ "${{ github.ref_type }}" = "tag" ]; then
tar -czvf ${{ github.workspace }}/${{ matrix.artifact_name }} -C dist/linux OpenDriveViewer_linux_x64
fi

- name: Build and Test with Bazel
if: matrix.os != 'ubuntu-22.04'
shell: bash
run: |
BAZEL_STARTUP_OPTS="--host_jvm_args=-Djava.net.preferIPv4Stack=true"
BAZEL_OPTS="--repository_cache=$HOME/.cache/bazel-repo --disk_cache=$HOME/.cache/bazel-disk --keep_going --show_result=10 --registry=https://bcr.bazel.build"
COMMON_FLAGS="-c opt"

if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then
xvfb-run --auto-servernum bazel $BAZEL_STARTUP_OPTS test $COMMON_FLAGS //... --test_output=errors $BAZEL_OPTS --config=linux \
--action_env=QT6_ROOT="${{ env.QT_ROOT_DIR }}" \
--action_env=PROJ_ROOT="${{ env.PROJ_ROOT }}"
elif [ "${{ matrix.os }}" = "windows-2022" ]; then
if [ "${{ matrix.os }}" = "windows-2022" ]; then
TCMALLOC_LIB=$(find "${{ env.PROJ_ROOT }}/lib" -name "*tcmalloc*.lib" | head -n 1 | tr '/' '\\')
export PATH="${{ env.PROJ_ROOT }}/bin:$PATH"
bazel $BAZEL_STARTUP_OPTS test $COMMON_FLAGS --linkopt="${TCMALLOC_LIB}" //... --test_output=errors $BAZEL_OPTS --config=windows \
Expand All @@ -181,14 +231,6 @@ jobs:
--action_env=QT6_ROOT="${{ env.QT_ROOT_DIR }}" \
--action_env=PROJ_ROOT="${{ env.PROJ_ROOT }}"
fi

- name: Package (Linux)
if: matrix.os == 'ubuntu-22.04' && startsWith(github.ref, 'refs/tags/v')
run: |
chmod +x scripts/deploy/package_linux.sh
./scripts/deploy/package_linux.sh
# Create archive for release
tar -czvf ${{ github.workspace }}/${{ matrix.artifact_name }} -C dist/linux OpenDriveViewer_linux_x64

- name: Package (macOS)
if: matrix.os == 'macos-14' && startsWith(github.ref, 'refs/tags/v')
Expand Down Expand Up @@ -243,23 +285,30 @@ jobs:
env:
GH_TOKEN: ${{ github.token }}

build-cmake:
name: CMake Build on ${{ matrix.os }}
build-verify:
name: Verify ${{ matrix.job_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
job_name: linux-bazel
build_system: bazel
qt_version: '6.9.*'
- os: ubuntu-22.04
job_name: linux-cmake
build_system: cmake
vcpkg_triplet: 'x64-linux'
qt_version: '6.9.*'
- os: macos-14
job_name: macos-cmake
build_system: cmake
vcpkg_triplet: 'arm64-osx'
qt_version: '6.9.1'
- os: windows-2022
job_name: windows-cmake
build_system: cmake
vcpkg_triplet: 'x64-windows'
qt_version: '6.9.1'

Expand All @@ -283,18 +332,16 @@ jobs:
fi

- name: Setup Ccache
if: matrix.build_system == 'cmake'
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}-ccache
key: ${{ matrix.job_name }}-ccache
variant: ccache
append-timestamp: true

# Cache built library packages (vcpkg ports) for maximum compilation speedup.
# We do not manually cache the vcpkg tool/repository itself since bootstrapping the exe is extremely fast (< 1s),
# and this avoids hitting GitHub's 10GB cache limit or caching corrupt/outdated repositories.




- name: Cache vcpkg binary packages
if: matrix.os == 'windows-2022'
Expand Down Expand Up @@ -348,6 +395,7 @@ jobs:
- name: Set Environment Variables
shell: bash
run: |
echo "QT6_ROOT=${{ env.QT_ROOT_DIR }}" >> $GITHUB_ENV
if [ "${{ matrix.os }}" = "ubuntu-22.04" ]; then
echo "PROJ_ROOT=/usr" >> $GITHUB_ENV
elif [ "${{ matrix.os }}" = "macos-14" ]; then
Expand All @@ -356,15 +404,18 @@ jobs:
echo "PROJ_ROOT=${{ github.workspace }}/vcpkg_installed/${{ matrix.vcpkg_triplet }}" >> $GITHUB_ENV
fi

# --- CMake-specific steps ---
- name: Cache CMake FetchContent
if: matrix.build_system == 'cmake'
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/cmake_deps
key: cmake-deps-${{ matrix.os }}-${{ hashFiles('CMakeLists.txt', 'src/CMakeLists.txt') }}
restore-keys: |
cmake-deps-${{ matrix.os }}-

- name: Configure and Build
- name: Configure and Build (CMake)
if: matrix.build_system == 'cmake'
shell: bash
run: |
cmake -B build -G Ninja \
Expand All @@ -376,7 +427,8 @@ jobs:
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
cmake --build build --config RelWithDebInfo

- name: Test
- name: Test (CMake)
if: matrix.build_system == 'cmake'
shell: bash
run: |
cd build
Expand All @@ -386,6 +438,30 @@ jobs:
ctest -C RelWithDebInfo --output-on-failure
fi

# --- Bazel-specific steps ---
- name: Cache Bazel
if: matrix.build_system == 'bazel'
uses: actions/cache@v5
with:
path: |
~/.cache/bazel-repo
~/.cache/bazel-disk
key: bazel-${{ matrix.os }}-${{ hashFiles('**/BUILD*', '**/WORKSPACE*', 'MODULE.bazel', '*.bzl') }}
restore-keys: |
bazel-${{ matrix.os }}-

- name: Build and Test (Bazel)
if: matrix.build_system == 'bazel'
shell: bash
run: |
BAZEL_STARTUP_OPTS="--host_jvm_args=-Djava.net.preferIPv4Stack=true"
BAZEL_OPTS="--repository_cache=$HOME/.cache/bazel-repo --disk_cache=$HOME/.cache/bazel-disk --keep_going --show_result=10 --registry=https://bcr.bazel.build"
COMMON_FLAGS="-c opt"

xvfb-run --auto-servernum bazel $BAZEL_STARTUP_OPTS test $COMMON_FLAGS //... --test_output=errors $BAZEL_OPTS --config=linux \
--action_env=QT6_ROOT="${{ env.QT_ROOT_DIR }}" \
--action_env=PROJ_ROOT="${{ env.PROJ_ROOT }}"

- name: Cleanup Old Caches
if: always()
shell: bash
Expand Down
Loading
Loading