Skip to content

ci: Add unit tests

ci: Add unit tests #3

Workflow file for this run

name: Unit tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Update package info
run: sudo apt update
- name: Install dependencies
run: >
sudo apt install --no-install-recommends --yes
build-essential meson pkg-config wayland-protocols
libwayland-dev libjson-c-dev libxkbcommon-dev
libfreetype-dev libfontconfig-dev
libopenexr-dev libgif-dev libheif-dev libavif-dev
libjpeg-dev librsvg2-dev libtiff-dev libwebp-dev
libgtest-dev cmake
- name: Install gtest
run: |
mkdir /tmp/gtest
cd /tmp/gtest && cmake /usr/src/gtest && make -j$(nproc)
sudo cp /tmp/gtest/lib/* /usr/lib/
- name: Check out source code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get version
run: echo "VERSION=$(git describe --tags --long --always | sed 's/^v//;s/-/./')" >> $GITHUB_OUTPUT
id: version
- name: Build
run: |
export CC="clang"
export CXX="clang++"
export CFLAGS="-g -fsanitize=address"
export CXXFLAGS="-g -fsanitize=address"
export LDFLAGS="-fsanitize=address"
meson -Dversion=${{steps.version.outputs.VERSION}} -Dtests=enabled --prefix=/usr ./build
ninja -C ./build
- name: Install
run: DESTDIR=install ninja -C ./build install
- name: Check version
run: ./build/install/usr/bin/swayimg --version
- name: Run unit tests
run: meson test --verbose -C ./build