Skip to content

Commit

Permalink
Combined Ubuntu 22 and 20 workflow in single matrix workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianReimold committed Apr 23, 2024
1 parent 0ad9379 commit fcd8770
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 210 deletions.
157 changes: 0 additions & 157 deletions .github/workflows/build-ubuntu-22.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,32 +1,63 @@
name: Build Ubuntu 20.04
name: Build Ubuntu

on:
push:
pull_request:
branches:
- master

jobs:
build-ubuntu:
runs-on: ubuntu-20.04

strategy:
matrix:
os: [ubuntu-22.04, ubuntu-20.04]

runs-on: ${{ matrix.os }}

env:
# enable starting Qt GUI Applications
QT_QPA_PLATFORM: offscreen
PROJECT_NAME: ecal

steps:

- name: Install Dependencies
run: |
sudo apt update
sudo apt-get install ninja-build doxygen graphviz libcurl4-openssl-dev libprotobuf-dev libprotoc-dev protobuf-compiler libhdf5-dev qt5-default libqt5opengl5-dev libqt5svg5-dev libyaml-cpp-dev
if [ "${{ matrix.os }}" == "ubuntu-24.04" ]; then
sudo apt-get install ninja-build doxygen graphviz libcurl4-openssl-dev libprotobuf-dev libprotoc-dev protobuf-compiler libhdf5-dev qt6-base-dev qt6-svg-dev libyaml-cpp-dev
sudo apt-get -y install python python-venv
elif [ "${{ matrix.os }}" == "ubuntu-22.04" ]; then
sudo apt-get install ninja-build doxygen graphviz libcurl4-openssl-dev libprotobuf-dev libprotoc-dev protobuf-compiler libhdf5-dev qtbase5-dev libqt5opengl5-dev libqt5svg5-dev libyaml-cpp-dev
sudo apt-get -y install python python-venv
elif [ "${{ matrix.os }}" == "ubuntu-20.04" ]; then
sudo apt-get install ninja-build doxygen graphviz libcurl4-openssl-dev libprotobuf-dev libprotoc-dev protobuf-compiler libhdf5-dev qt5-default libqt5opengl5-dev libqt5svg5-dev libyaml-cpp-dev
sudo apt-get -y install python3.9 python3.9-venv
fi
- name: Set variables
run: |
if [ "${{ matrix.os }}" == "ubuntu-24.04" ]; then
echo "ubuntu_codename=noble" >> "$GITHUB_ENV"
echo "python_version=3" >> "$GITHUB_ENV" # => default python 3 version
elif [ "${{ matrix.os }}" == "ubuntu-22.04" ]; then
echo "ubuntu_codename=focal" >> "$GITHUB_ENV"
echo "python_version=3" >> "$GITHUB_ENV" # => default python 3 version
elif [ "${{ matrix.os }}" == "ubuntu-20.04" ]; then
echo "ubuntu_codename=jammy" >> "$GITHUB_ENV"
echo "python_version=3.9" >> "$GITHUB_ENV"
fi
# Get cpu architecture
echo "cpu_architecture=$(dpkg --print-architecture)" >> "$GITHUB_ENV"
- name: Install Cap'n Proto
run: |
mkdir "${{ runner.workspace }}/capnp"
cd "${{ runner.workspace }}/capnp"
curl -O https://capnproto.org/capnproto-c++-0.9.0.tar.gz
tar zxf capnproto-c++-0.9.0.tar.gz
cd capnproto-c++-0.9.0
curl -O https://capnproto.org/capnproto-c++-1.0.2.tar.gz
tar zxf capnproto-c++-1.0.2.tar.gz
cd capnproto-c++-1.0.2
./configure
make -j
sudo make install
Expand All @@ -40,9 +71,8 @@ jobs:
- name: Install Python requirements
shell: bash
run: |
sudo apt-get -y install python3.9-dev python3.9-venv
mkdir ".venv_build"
python3.9 -m venv ".venv_build"
python${{ env.python_version }} -m venv ".venv_build"
source ".venv_build/bin/activate"
pip install --upgrade pip
pip install wheel setuptools
Expand All @@ -52,8 +82,6 @@ jobs:
run: |
source ".venv_build/bin/activate"
export CC=/usr/bin/gcc-9
export CXX=/usr/bin/g++-9
mkdir "${{ runner.workspace }}/_build"
cd "${{ runner.workspace }}/_build"
Expand All @@ -69,8 +97,8 @@ jobs:
-DBUILD_APPS=ON \
-DBUILD_SAMPLES=ON \
-DBUILD_TIME=ON \
-DBUILD_PY_BINDING=ON \
-DBUILD_STANDALONE_PY_WHEEL=ON \
-DBUILD_PY_BINDING=OFF \
-DBUILD_STANDALONE_PY_WHEEL=OFF \
-DBUILD_CSHARP_BINDING=OFF \
-DBUILD_ECAL_TESTS=ON \
-DECAL_INCLUDE_PY_SAMPLES=OFF \
Expand Down Expand Up @@ -104,55 +132,30 @@ jobs:
run: cmake --build . --config Release -- -k 0
working-directory: ${{ runner.workspace }}/_build

# Create Python Wheels
# The strang-looking double-cmake is an ugly workaround to force CMake to
# re-find Python, after we have changed the venv from the outside. The
# alternative would be to clean everything, which would cause an unnecessary
# rebuild of eCAL for each python Version.
- name: Build Python 3.9 Wheel
run: |
sudo apt-get -y install python3.9-dev python3.9-venv
mkdir ".venv_39"
python3.9 -m venv ".venv_39"
source ".venv_39/bin/activate"
pip install --upgrade pip
pip install wheel setuptools
cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=FIRST
cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=ONLY
cmake --build . --target create_python_wheel --config Release
shell: bash
- name: Run Tests
run: ctest -V
working-directory: ${{ runner.workspace }}/_build

- name: Build Python 3.8 Wheel
- name: Read Project Version from CMakeCache
run: |
sudo apt-get -y install python3.8-dev python3.8-venv
mkdir ".venv_38"
python3.8 -m venv ".venv_38"
source ".venv_38/bin/activate"
pip install --upgrade pip
pip install wheel setuptools
cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=FIRST
cmake $GITHUB_WORKSPACE -DPython_FIND_VIRTUALENV=ONLY
cmake --build . --target create_python_wheel --config Release
cmake_project_version_string=$(cat "${{github.workspace}}/_build/CMakeCache.txt" | grep "^CMAKE_PROJECT_VERSION:")
arr=(${cmake_project_version_string//=/ })
cmake_project_version=${arr[1]}
echo "CMAKE_PROJECT_VERSION=$cmake_project_version" >> "$GITHUB_ENV"
shell: bash
working-directory: ${{ runner.workspace }}/_build

- name: Run Tests
run: ctest -V
working-directory: ${{ runner.workspace }}/_build

- name: Pack
- name: CPack
run: cpack -G DEB
working-directory: ${{ runner.workspace }}/_build

- name: Rename .deb installer
run: |
mv *.deb '${{ env.PROJECT_NAME }}_${{ env.CMAKE_PROJECT_VERSION }}-${{ env.ubuntu_codename }}_${{ env.cpu_architecture }}.deb'
shell: bash
working-directory: ${{github.workspace}}/_build/_deploy/

- name: Upload Debian
uses: actions/upload-artifact@v4
with:
name: ubuntu-debian
path: ${{ runner.workspace }}/_build/_deploy/*.deb

- name: Upload Python Wheel
uses: actions/upload-artifact@v4
with:
name: ubuntu-python-wheel
path: ${{ runner.workspace }}/_build/_deploy/*.whl

0 comments on commit fcd8770

Please sign in to comment.