Skip to content

Add the foundation for automated unit testing using the Google Test framework #9

Add the foundation for automated unit testing using the Google Test framework

Add the foundation for automated unit testing using the Google Test framework #9

Workflow file for this run

name: Unit Tests
on:
push:
branches:
- dev
- main
pull_request:
branches:
- dev
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
container:
image: zeek/zeek:6.2.1
strategy:
fail-fast: true
# Set up a matrix to run the following 3 configurations:
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, make and ninja generators>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, make and ninja generators>
matrix:
build_type: [Release]
c_compiler: [gcc, clang]
cpp_compiler: [g++, clang++]
generator: [Unix Makefiles, Ninja]
exclude:
- c_compiler: gcc
cpp_compiler: clang++
- c_compiler: clang
cpp_compiler: g++
steps:
- uses: actions/checkout@v4
# Necessary due to https://github.com/actions/runner/issues/2058
- name: Save workspace to environment
run: echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Update package cache
run: apt update -y
- name: Install build dependencies
run: >
apt install -y
clang
cmake
g++
gcc
make
ninja-build
xxd
- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ env.GITHUB_WORKSPACE }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-G "${{ matrix.generator }}"
-DCMAKE_CXX_COMPILER=/usr/bin/${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=/usr/bin/${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DSPICY_PROTOBUF_TEST=ON
-S ${{ env.GITHUB_WORKSPACE }}
- name: Build
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}/testing/gtest/
run: ctest --build-config ${{ matrix.build_type }} -VV