Skip to content

Commit

Permalink
feat: comprehensive ubuntu builds for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
abdes committed Apr 21, 2023
1 parent 4a74091 commit 27fce46
Showing 1 changed file with 198 additions and 0 deletions.
198 changes: 198 additions & 0 deletions .github/workflows/ubuntu-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
name: ubuntu-builds

on: [push, pull_request]

env:
CMAKE_VERSION: 3.21.1
NINJA_VERSION: 1.11.1
CCACHE_VERSION: 4.8
CC: ''
CXX: ''
GCC_VERSION: ''
CLANG_VERSION: ''

jobs:
dev-build:
runs-on: ubuntu-22.04
strategy:
matrix:
compiler: [gcc-10, gcc-11, gcc-12, clang-14, clang-15, clang-16]
build_type: [Debug, Release]
include:
- build_type: Debug
examples: ON
tests: OFF # the template asap has no unit tests
- build_type: Release
examples: ON
tests: OFF # the template asap has no unit tests

steps:
- name: Split compiler name and version
id: split
env:
COMPILER: ${{ matrix.compiler }}
COMPILER_NAME: ''
COMPILER_VERSION: ''
run: |
COMPILER_NAME=${COMPILER%%-*}
COMPILER_VERSION=${COMPILER##*-}
echo "compiler_name=$COMPILER_NAME" >> $GITHUB_OUTPUT
if [ $COMPILER_NAME == 'gcc' ]
then
echo "gcc_version=$COMPILER_VERSION" >> $GITHUB_OUTPUT
elif [ $COMPILER_NAME == 'clang' ]
then
echo "clang_version=$COMPILER_VERSION" >> $GITHUB_OUTPUT
echo "gcc_version=11" >> $GITHUB_OUTPUT
fi
- name: Install basic OS packages
run: |
sudo apt-get -qq update
sudo apt-get -qq -y install \
software-properties-common \
apt-transport-https \
lsb-release \
ca-certificates \
curl \
gnupg \
build-essential
- name: Install GCC (always runs)
run: |
# sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get -qq update && \
sudo apt-get -qq -y install gcc-${{steps.split.outputs.gcc_version}} g++-${{steps.split.outputs.gcc_version}}
- name: Install clang (only if building with clang)
if: ${{ steps.split.outputs.compiler_name == 'clang' }}
run: |
curl https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-${{steps.split.outputs.clang_version}} main'
sudo apt-get -qq update
sudo apt-get -qq -y install \
libllvm${{steps.split.outputs.clang_version}} \
llvm-${{steps.split.outputs.clang_version}} \
llvm-${{steps.split.outputs.clang_version}}-dev \
llvm-${{steps.split.outputs.clang_version}}-runtime \
llvm-${{steps.split.outputs.clang_version}}-linker-tools \
lld-${{steps.split.outputs.clang_version}} \
clang-${{steps.split.outputs.clang_version}} \
clang-tools-${{steps.split.outputs.clang_version}} \
clang-format-${{steps.split.outputs.clang_version}} \
libclang1-${{steps.split.outputs.clang_version}} \
libc++-${{steps.split.outputs.clang_version}}-dev \
libc++abi-${{steps.split.outputs.clang_version}}-dev \
clang-format-${{steps.split.outputs.clang_version}} \
python3-clang-${{steps.split.outputs.clang_version}} \
clang-tools-${{steps.split.outputs.clang_version}} \
clang-tidy-${{steps.split.outputs.clang_version}}
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Use GNU compilers (only if building with gcc/g++)
if: ${{ steps.split.outputs.compiler_name == 'gcc' }}
run: |
echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV
sudo update-alternatives --install \
/usr/bin/gcc gcc /usr/bin/gcc-${{steps.split.outputs.gcc_version}} 110 \
--slave /usr/bin/g++ g++ /usr/bin/g++-${{steps.split.outputs.gcc_version}} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{steps.split.outputs.gcc_version}}
- name: Use clang (only if building with clang/clang++)
if: ${{ steps.split.outputs.compiler_name == 'clang' }}
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
for command in clang clang++ clang-apply-replacements clang-check \
clang-query clang-tidy clang-format scan-build scan-view llvm-cov \
llvm-profdata
do
sudo update-alternatives --install /usr/bin/$command $command \
/usr/bin/$command-${{steps.split.outputs.clang_version}} 110
done
clang --version
- name: Setup ninja
# Do not use ninja-build from the distro repos as it is always old
uses: abdes/gha-setup-ninja@master
with:
version: ${{ env.NINJA_VERSION }}

- name: Setup cmake
# Do not use cmake from the distro repos as it is not the version we
# want
uses: jwlawson/actions-setup-cmake@v1
with:
cmake-version: ${{ env.CMAKE_VERSION }}

- name: Install ccache from latest
run: |
CCACHE_DIST="ccache-${{ env.CCACHE_VERSION }}-linux-x86_64"
CCACHE_URL="https://github.com/ccache/ccache/releases/download/v$CCACHE_VERSION/$CCACHE_DIST.tar.xz"
echo "Installing ccache from: $CCACHE_URL"
curl -s -L -o ./ccache.tar.xz $CCACHE_URL
tar xf ./ccache.tar.xz
rm -f ./ccache.tar.xz
echo "$GITHUB_WORKSPACE/$CCACHE_DIST" >> $GITHUB_PATH
- name: Log environment properties
run: |
echo "Build Type : ${{matrix.build_type}}"
echo "Compiler Name : ${{steps.split.outputs.compiler_name}}"
if [ ${{steps.split.outputs.compiler_name}} == 'clang' ]
then
echo "Clang Version : ${{steps.split.outputs.clang_version}}"
fi
echo "GCC Version : ${{steps.split.outputs.gcc_version}}"
ninja --version
cmake --version
gcc --version
clang --version
ccache --version
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
install_ccache: false
update_packager_index: false
prepend_symlinks_to_path: false
windows_compile_environment: msvc # this field is required

- name: Configure build
working-directory: ${{runner.workspace}}
run: |
cmake -B build -S $GITHUB_WORKSPACE \
-D CMAKE_BUILD_TYPE=${{matrix.build_type}} \
-G Ninja \
-D CMAKE_MAKE_PROGRAM=ninja \
-D USE_CCACHE=ON \
-D ASAP_BUILD_TESTS=${{matrix.tests}} \
-D ASAP_BUILD_EXAMPLES=${{matrix.examples}} \
-D ASAP_BUILD_DOCS=OFF \
-D CMAKE_INSTALL_PREFIX=install \
-D CMAKE_VERBOSE_MAKEFILE=ON
- name: Build main targets
working-directory: ${{runner.workspace}}
run: |
cmake --build build --target all
- name: Build test targets
working-directory: ${{runner.workspace}}
if: ${{ matrix.tests == true }}
run: |
cmake --build build --target build-all-tests
- name: Run tests with ctest
working-directory: ${{runner.workspace}}
# Hardcode 2 cores we know are there
run: |
ctest \
--test-dir build \
-C ${{matrix.build_type}} \
-j 2 \
--output-on-failure

0 comments on commit 27fce46

Please sign in to comment.