Skip to content

Add unit tests for assertions #97

Add unit tests for assertions

Add unit tests for assertions #97

Workflow file for this run

# This file is part of the Ssstr string library.
# Copyright 2022-2023 Board of Regents of the University of Wisconsin System
# SPDX-License-Identifier: MIT
name: CI
on:
pull_request:
push:
branches:
- main
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: pre-commit/action@v3.0.0
test:
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- macos
- windows
arch:
- x86_64
- x86
compiler:
- gcc
- clang
- clang-cl
- msvc
exclude:
- arch: x86
compiler: clang-cl
- os: ubuntu
compiler: msvc
- os: ubuntu
compiler: clang-cl
- os: macos
arch: x86
- os: macos
compiler: msvc
- os: macos
compiler: clang-cl
- os: windows
compiler: clang
- os: windows
arch: x86
compiler: gcc
include:
- os: ubuntu
runner: ubuntu-latest
- os: macos
runner: macos-latest
- os: windows
runner: windows-latest
- arch: x86_64
arch_flag: -m64
vsenv_arch: amd64
- arch: x86
arch_flag: -m32
vsenv_arch: amd64_x86
- compiler: gcc
cc: gcc
cxx: g++
- compiler: clang
cc: clang
cxx: clang++
- compiler: clang-cl
cc: clang-cl
cxx: clang-cl
- compiler: msvc
arch_flag: ""
cc: cl
cxx: cl
- os: macos
compiler: gcc
# macOS has gcc/g++ pointing to clang/clang++
cc: gcc-12
cxx: g++-12
name: test-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.compiler }}
runs-on: ${{ matrix.runner }}
env: # These are recognized by meson
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
CFLAGS: ${{ matrix.arch_flag }}
CXXFLAGS: ${{ matrix.arch_flag }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install tools
run: |
python -m pip install --upgrade pip meson ninja
- if: matrix.os == 'ubuntu' && matrix.arch == 'x86'
run: sudo apt-get install -y gcc-multilib g++-multilib
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.vsenv_arch }}
- name: Build and test (debug)
run: |
meson setup build-debug --buildtype debug -Dtest=enabled -Ddocs=auto
meson dist -C build-debug
- name: Build and test (release)
run: |
meson setup build-release --buildtype release -Dtest=enabled -Ddocs=auto
meson dist -C build-release
- name: Run benchmarks
# Exclude MinGW for now (crashes at runtime; needs investigation)
if: matrix.os != 'windows' || matrix.compiler != 'gcc'
run: |
cd build-release
meson configure -Dbenchmark=enabled
ninja benchmark
- name: Build with different GCC dialects
if: matrix.compiler == 'gcc'
run: |
meson setup dialects --buildtype debug -Dtest=enabled
cd dialects
meson configure -Dc_std=c99 -Dcpp_std=c++03
meson test
meson configure -Dc_std=c17 -Dcpp_std=c++20
meson test
meson configure -Dc_std=gnu99 -Dcpp_std=gnu++03
meson test
meson configure -Dc_std=gnu17 -Dcpp_std=gnu++20
meson test
- name: Sanitize address/undefined
if: matrix.os == 'ubuntu' && matrix.compiler == 'clang'
run: |
meson setup sanitize --buildtype debug -Db_lundef=false -Dtest=enabled
cd sanitize
meson configure -Db_sanitize=address,undefined
meson test
- name: Sanitize memory/leak
if: matrix.os == 'ubuntu' && matrix.arch == 'x86_64' && matrix.compiler == 'clang'
run: |
cd sanitize
meson configure -Db_sanitize=memory
meson test
meson configure -Db_sanitize=leak
meson test
docs:
needs:
- lint
- test
concurrency:
group: publish-gh-pages
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install tools
run: |
python -m pip install --upgrade pip meson ninja
- name: Build man pages
run: |
meson setup builddir -Ddocs=enabled
cd builddir
ninja htmlman
- name: Publish to gh-pages
if: >-
github.repository == 'marktsuchida/ssstr' &&
github.event_name == 'push' &&
github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: builddir/htmlman
commit_message: Deploy from main