Skip to content

Commit

Permalink
Merge pull request #1 from nasa/gh-actions
Browse files Browse the repository at this point in the history
Github action for unit tests, README badges
  • Loading branch information
marclecerf authored Apr 26, 2023
2 parents 14022d8 + 6ffc7c3 commit 1a48470
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 0 deletions.
114 changes: 114 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Run the uPSP project build system and unit tests.
# Artifacts are installed into the runner's system Python 3 environment.
#
# Notes:
#
# - Initially considered installing all dependencies via system
# package manager, but encountered some GH-specific "pain points"
# (e.g., HDF5 v1.12 is not supported out-of-box by ubuntu-latest).
# Simpler and more robust to manage with third-party C/C++ package
# manager like vcpkg.
#
# - Some system dependencies may not be needed... accidentally tried
# vcpkg install without explicitly disabling default opencv4 features
# which include a LOT of extras with frontend library deps like x11.
# TODO consider pruning at a later date.
#
# - Making use of third-party actions for improved caching + invocation
# of CMake and vcpkg. Ref: https://github.com/marketplace/actions/run-vcpkg
# Recommendations from author highlight using vcpkg as a Git submodule...
# this is NOT desirable in our case because for native deployment to
# HPC clusters, oftentimes the user-supplied /home folder has quite limited
# storage and is not appropriate for caching lots of external submodules.
# Instead, we pin the vcpkg release here (vcpkgGitCommitId) and maintain
# consistency manually.
#
# - On NAS HECC systems, we build the C/C++ code with dynamic linkage due
# to the available system dependencies. This is *not* a default
# target supported by vcpkg, but it has a lot of community interest and
# "unofficial" testing support. Ref: https://github.com/microsoft/vcpkg/issues/15006
# We patch up some of the RPATH quirks using 'patchelf'.
#
name: unit-tests
on:
push:
workflow_dispatch:

jobs:
job:
name: ${{ matrix.os }}-${{ github.workflow }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
# Python v3.9 is latest version supported by NAS HECC systems
# Main obstacle to upgrading is "pinned" opencv 4.5.12 dependency
python-version: ['3.9.16']
env:
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg/installed
VCPKG_DEFAULT_TRIPLET: x64-linux-dynamic

steps:
- uses: actions/checkout@v3
- uses: lukka/get-cmake@latest
- name: Install dependencies (Linux)
run: |
sudo apt-get update -y
sudo apt-get install -y \
autoconf \
bison \
gperf \
nasm \
patchelf \
libdbus-1-dev \
libgles2-mesa-dev \
libopenmpi-dev \
libtool \
libx11-dev \
libxcursor-dev \
libxdamage-dev \
libxext-dev \
libxft-dev \
libxi-dev \
libxinerama-dev \
libxrandr-dev \
libxtst-dev
if: matrix.os == 'ubuntu-latest'
- name: Restore from cache and setup vcpkg executable and data files.
uses: lukka/run-vcpkg@v11
with:
vcpkgJsonGlob: '.github/workflows/vcpkg.json'
runVcpkgInstall: true
# Release 2023.04.15
vcpkgGitCommitId: '501db0f17ef6df184fcdbfbe0f87cde2313b6ab1'
- name: Patch vcpkg library headers with patchelf
run: |
cd vcpkg
${{ github.workspace }}/.github/workflows/vcpkg-fix-rpaths
cd ..
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Upgrade pip to v23+
run: |
pip install --upgrade pip
pip --version
python --version
- name: Run build+install with pip
run: |
SKBUILD_CONFIGURE_OPTIONS=\
" -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"\
" -DVCPKG_TARGET_TRIPLET=x64-linux-dynamic" pip install -v .
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Run C/C++ unit tests
# TODO this should be made cross-platform. Currently works only for ubuntu-latest
# TODO fix RUNPATH of built executables to avoid use of LD_LIBRARY_PATH
run: |
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${{ env.VCPKG_INSTALLED_DIR }}/${{ env.VCPKG_DEFAULT_TRIPLET }}/lib"
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
cd cpp/test
../../_skbuild/linux-x86_64-3.9/cmake-build/run_tests
54 changes: 54 additions & 0 deletions .github/workflows/vcpkg-fix-rpaths
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

# syntax: patchelf
# [--set-interpreter FILENAME]
# [--page-size SIZE]
# [--print-interpreter]
# [--print-soname] Prints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist
# [--set-soname SONAME] Sets 'DT_SONAME' entry to SONAME.
# [--set-rpath RPATH]
# [--remove-rpath]
# [--shrink-rpath]
# [--allowed-rpath-prefixes PREFIXES] With '--shrink-rpath', reject rpath entries not starting with the allowed prefix
# [--print-rpath]
# [--force-rpath]
# [--add-needed LIBRARY]
# [--remove-needed LIBRARY]
# [--replace-needed LIBRARY NEW_LIBRARY]
# [--print-needed]
# [--no-default-lib]
# [--clear-symbol-version SYMBOL]
# [--output FILE]
# [--debug]
# [--version]
# FILENAME...


if [ ! -f "vcpkg" ]; then
echo "ERROR: Must run from vcpkg dir"
exit 1
fi

# Find all libs, and patch w/ correct RUNPATH
# '$ORIGIN' is special entry in RUNPATH referring to "this solib's dir",
# shorthand for the LIB_DIR. Alternatively, we could add the actual vcpkg lib dir
# but this makes the vcpkg solib's bulk-relocatable, which is kind of nice.
RUNPATH='$ORIGIN'
TRIPLET=x64-linux-dynamic

LIB_DIR=$PWD/installed/$TRIPLET/lib
FILES=( $( find $LIB_DIR -type f -name 'lib*.so*' ) )
# will break on file names with whitespace
for f in "${FILES[@]}"; do
patchelf --set-rpath "$RUNPATH" "$f"
echo "patchelf --set-rpath \"$RUNPATH\" \"$f\""
done

LIB_DIR=$PWD/installed/$TRIPLET/debug/lib
FILES=( $( find $LIB_DIR -type f -name 'lib*.so*' ) )
# will break on file names with whitespace
for f in "${FILES[@]}"; do
patchelf --set-rpath "$RUNPATH" "$f"
echo "patchelf --set-rpath \"$RUNPATH\" \"$f\""
done

32 changes: 32 additions & 0 deletions .github/workflows/vcpkg-triplets/x64-linux-dynamic.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Custom triplet for building shared libraries (*.so) for
# x64 linux architectures. Default for vcpkg is to build
# static libraries (*.a) only.

set(VCPKG_TARGET_ARCHITECTURE x64)

set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

set(VCPKG_CXX_FLAGS "-Wl,-rpath,'$ORIGIN'")
set(VCPKG_C_FLAGS "-Wl,-rpath,'$ORIGIN'")
set(VCPKG_LINKER_FLAGS "-Wl,-rpath,'$ORIGIN'")

# use, i.e. don't skip the full RPATH for the build tree
# when building, don't use the install RPATH already
# (but later on when installing)
# set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

#set(CMAKE_SKIP_RPATH FALSE)
#set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH

# # the RPATH to be used when installing, but only if it's not a system directory
# list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
# if("${isSystemDir}" STREQUAL "-1")
# set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# endif("${isSystemDir}" STREQUAL "-1")

22 changes: 22 additions & 0 deletions .github/workflows/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "main",
"version-string": "latest",
"dependencies": [
{"name": "hdf5", "default-features": false, "features": ["cpp"]},
"eigen3",
{"name": "opencv4", "default-features": false, "features": ["contrib", "ffmpeg", "openexr"]},
"boost-iterator",
"boost-lexical-cast",
"boost-fusion",
"boost-format",
"boost-math",
"boost-tokenizer",
"ilmbase",
"gtest",
"pybind11"
],
"vcpkg-configuration": {
"overlay-triplets": ["./vcpkg-triplets"]
}
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

[![pages-build-deployment](https://github.com/nasa/upsp-processing/actions/workflows/pages/pages-build-deployment/badge.svg)](https://nasa.github.io/upsp-processing)
![Unit Tests](https://github.com/nasa/upsp-processing/actions/workflows/unit-tests.yml/badge.svg?event=push)

-----

# upsp-processing

Software for processing high-speed video recordings from Unsteady Pressure-Sensitive Paint (UPSP) measurement systems.
Expand Down

0 comments on commit 1a48470

Please sign in to comment.