Skip to content

Commit

Permalink
Created abi test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Jun 16, 2024
1 parent 3d5cd73 commit 7197ff2
Show file tree
Hide file tree
Showing 3 changed files with 6,600 additions and 15 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/abi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# Copyright 2024 Ribose Inc. (https://www.ribose.com)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

name: abi

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

concurrency:
group: '${{ github.workflow }}-${{ github.job }}-${{ github.head_ref || github.ref_name }}'
cancel-in-progress: true

jobs:
abi-test:
runs-on: ubuntu-latest
env:
CC: gcc
CXX: g++
MAKEFLAGS: j4
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install abi tools
run: |
sudo apt-get install abi-compliance-checker abi-dumper
- name: Configure
run: |
cmake -Bbuild -DWITH_ABI_TEST=ON
- name: Build
run: cmake --build build

- name: Generate abi dump
run: abi-dumper build/libsexpp.so -o build/libsexpp.abi -lver 0

- name: Test abi compatibility
run: abi-compliance-checker -l libsexpp -new build/libsexpp.abi -old tests/abi/libsexpp.0.abi -report-path build/abi-report.html

- name: Upload abi report
uses: actions/upload-artifact@v4
with:
name: abi-report
path: build/abi-report.html
57 changes: 42 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2021-2023 Ribose Inc. (https://www.ribose.com)
# Copyright 2021-2024 Ribose Inc. (https://www.ribose.com)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -35,33 +35,21 @@ option(WITH_SEXP_TESTS "Build tests" ON)
option(WITH_SEXP_CLI "Build sexp console application" ON)
option(WITH_SANITIZERS "Enable ASAN and other sanitizers" OFF)
option(WITH_COVERAGE "Enable coverage report" OFF)
option(WITH_ABI_TEST "Configure for ABI compatibility test" OFF)
option(DOWNLOAD_GTEST "Download googletest" ON)
option(BUILD_SHARED_LIBS "Build shared library" OFF)

include(GNUInstallDirs)
include(CheckCXXSourceCompiles)

if (BUILD_SHARED_LIBS)
set(TYPE "SHARED")
else (BUILD_SHARED_LIBS)
set(TYPE "STATIC")
endif (BUILD_SHARED_LIBS)

if (BUILD_SHARED_LIBS AND MSVC)
message(FATAL_ERROR "Building sexp shared library with MSVC is not supported")
endif(BUILD_SHARED_LIBS AND MSVC)


message(STATUS "Building ${TYPE} library")

if (WITH_SANITIZERS)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "Sanitizers work with clang compiler only.")
endif()
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
message(STATUS "Forcing build type to Debug for sanitizers")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type. Forced to Debug" FORCE)
set(WITH_TESTS ON CACHE STRING "Forced to ON" FORCE)
set(WITH_SEXP_TESTS ON CACHE STRING "Forced to ON" FORCE)
endif()
endif()

Expand All @@ -72,10 +60,45 @@ if (WITH_COVERAGE)
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
message(STATUS "Forcing build type to Debug for coverage")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type. Forced to Debug" FORCE)
set(WITH_SEXP_TESTS ON CACHE STRING "Forced to ON" FORCE)
endif()
endif()

if (WITH_ABI_TEST)
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(FATAL_ERROR "Abi test works with GNU compiler only.")
endif()
if(NOT CMAKE_BUILD_TYPE MATCHES "Debug")
message(STATUS "Forcing build type to Debug for abi test")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type. Forced to Debug" FORCE)
set(WITH_TESTS ON CACHE STRING "Forced to ON" FORCE)
endif()
if(WITH_SEXP_TESTS)
message(STATUS "Disabling tests build for abi test")
set(WITH_SEXP_TESTS OFF CACHE STRING "Forced to OFF" FORCE)
endif()
if(WITH_SEXP_CLI)
message(STATUS "Disabling sexp cli application build for abi test")
set(WITH_SEXP_CLI OFF CACHE STRING "Forced to OFF" FORCE)
endif()
if(NOT BUILD_SHARED_LIBS)
message(STATUS "Forcing shared libs for abi test")
set(BUILD_SHARED_LIBS ON CACHE STRING "Forced to ON" FORCE)
endif()
endif()

if (BUILD_SHARED_LIBS)
set(TYPE "SHARED")
else (BUILD_SHARED_LIBS)
set(TYPE "STATIC")
endif (BUILD_SHARED_LIBS)

if (BUILD_SHARED_LIBS AND MSVC)
message(FATAL_ERROR "Building sexp shared library with MSVC is not supported")
endif(BUILD_SHARED_LIBS AND MSVC)

message(STATUS "Building ${TYPE} library")

if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Defaulting build type to Debug")
set(CMAKE_BUILD_TYPE Debug)
Expand All @@ -93,6 +116,10 @@ if (WITH_COVERAGE)
link_libraries(--coverage)
endif(WITH_COVERAGE)

if (WITH_ABI_TEST)
add_compile_options(-Og)
endif(WITH_ABI_TEST)

# set warning flags at the top level
if(NOT MSVC)
add_compile_options(
Expand Down

0 comments on commit 7197ff2

Please sign in to comment.