Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run ldconfig and add testing in CI #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 25 additions & 32 deletions .github/workflows/publish_deb.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Publish deb package

on:
workflow_dispatch:
push:
branches:
master
Expand All @@ -20,55 +21,47 @@ jobs:
release_branch: master
use_api: true

build_deb_2004:
build_and_publish:
needs: create_release
runs-on: ubuntu-20.04
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04]

steps:
- name: Install git
run: sudo apt-get -qq update -y && sudo apt-get -qq install cmake ninja-build rapidjson-dev -y
- name: Install dependencies
run: |
sudo apt-get -qq update -y
sudo apt-get -qq install cmake ninja-build rapidjson-dev libgtest-dev -y

- name: Check out
uses: actions/checkout@v4

- name: Build package
- name: Build with testing enabled and run tests
working-directory: .
run: mkdir build && cd build && cmake -GNinja .. && ninja && ninja package

- name: Upload debian package to release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create_release.outputs.v-version }}
files: |
build/*.deb

build_deb_2204:
needs: create_release
runs-on: ubuntu-22.04

steps:
- name: Install dependencies
run: sudo apt-get -qq update -y && sudo apt-get -qq install cmake ninja-build rapidjson-dev -y

- name: Check out
uses: actions/checkout@v4
run: |
cmake -B build -GNinja -DENABLE_TESTING=ON
ninja -C build
ninja -C build test

- name: Remove build directory after tests
if: success() # Only run if tests pass
run: rm -rf build

- name: Build package
if: success() # Only run if tests pass
working-directory: .
run: |
mkdir build
cd build
cmake -GNinja .. -DVERSION=${{ needs.create_release.outputs.v-version }}
ninja
ninja package
cmake -B build -GNinja -DVERSION=${{ needs.create_release.outputs.v-version }} -DCMAKE_INSTALL_PREFIX=/usr
ninja -C build
ninja -C build package

- name: Upload debian package to release
if: success() # Only run if package build succeeds
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.create_release.outputs.v-version }}
files: |
build/*.deb
build/*.deb
14 changes: 8 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(libosi)
include(GNUInstallDirs)

cmake_minimum_required(VERSION 3.0.2)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -112,9 +112,11 @@ target_link_libraries(osi offset ${GLIB_PKG_LIBRARIES})

# Install everything
install(TARGETS osi osi-static offset offset-static iohal iohal-static
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

# Install the headers
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
Expand Down
4 changes: 3 additions & 1 deletion CPackConfig.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ if(UBUNTU_CHECK STREQUAL "Ubuntu")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}_${UBUNTU_VERSION}")
endif()

include(CPack)
# Include additional control files
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/triggers")

include(CPack)
18 changes: 8 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ sudo apt-get install cmake ninja-build rapidjson-dev
To build libosi, from the root of this repo run:

```bash
mkdir build && cd $_
cmake -GNinja ..
ninja
cmake -B build -GNinja -DCMAKE_INSTALL_PREFIX=/usr
ninja -C build
```

### Installing

Installing libosi includes running:

```bash
cd build && ninja package
sudo dpkg -i libosi-[version].deb
ninja -C build package
cd build
sudo dpkg -i libosi_[ubuntu-version].deb
```

### Testing
Expand All @@ -57,13 +57,11 @@ first need to install dependencies and enable testing:
```bash
sudo apt-get install libgtest-dev

cd build
cmake -GNinja -DENABLE_TESTING=ON ..
ninja
cmake -B build -GNinja -DENABLE_TESTING=ON
ninja -C build
ninja -C build test
```

You can then run the tests with just `ninja test`.

### Development

Adding support for other Windows and Linux kernels can be as simple as adding a new profile
Expand Down
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
set(GTEST_SRC_DIR "/usr/src/gtest" CACHE PATH "Path to google test source")
if (NOT EXISTS ${GTEST_SRC_DIR})
message(WARNING "Could not find ${GTEST_SRC_DIR}")
Expand Down
1 change: 1 addition & 0 deletions tests/iohal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
add_executable(test-sparsemem ${CMAKE_CURRENT_SOURCE_DIR}/sparse_pmem.h
${CMAKE_CURRENT_SOURCE_DIR}/sparse_pmem.cc
${CMAKE_CURRENT_SOURCE_DIR}/test_sparse_pmem.cc)
Expand Down
1 change: 1 addition & 0 deletions tests/offset/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
add_executable(test-offset-basic ${CMAKE_CURRENT_SOURCE_DIR}/test_basic.cc)
target_link_libraries(test-offset-basic offset-static gtest_main)
add_test(TestBasicOffsets test-offset-basic)
1 change: 1 addition & 0 deletions tests/wintrospection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
add_executable(test-basic test_basic.cc)
target_link_libraries(test-basic wintrospection gtest_main offset iohal)
add_test(Wintrospection test-basic)
Expand Down
2 changes: 2 additions & 0 deletions triggers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Trigger ldconfig after install
activate-noawait ldconfig