Skip to content

Commit 1a48470

Browse files
authored
Merge pull request #1 from nasa/gh-actions
Github action for unit tests, README badges
2 parents 14022d8 + 6ffc7c3 commit 1a48470

File tree

5 files changed

+228
-0
lines changed

5 files changed

+228
-0
lines changed

.github/workflows/unit-tests.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
# Run the uPSP project build system and unit tests.
2+
# Artifacts are installed into the runner's system Python 3 environment.
3+
#
4+
# Notes:
5+
#
6+
# - Initially considered installing all dependencies via system
7+
# package manager, but encountered some GH-specific "pain points"
8+
# (e.g., HDF5 v1.12 is not supported out-of-box by ubuntu-latest).
9+
# Simpler and more robust to manage with third-party C/C++ package
10+
# manager like vcpkg.
11+
#
12+
# - Some system dependencies may not be needed... accidentally tried
13+
# vcpkg install without explicitly disabling default opencv4 features
14+
# which include a LOT of extras with frontend library deps like x11.
15+
# TODO consider pruning at a later date.
16+
#
17+
# - Making use of third-party actions for improved caching + invocation
18+
# of CMake and vcpkg. Ref: https://github.com/marketplace/actions/run-vcpkg
19+
# Recommendations from author highlight using vcpkg as a Git submodule...
20+
# this is NOT desirable in our case because for native deployment to
21+
# HPC clusters, oftentimes the user-supplied /home folder has quite limited
22+
# storage and is not appropriate for caching lots of external submodules.
23+
# Instead, we pin the vcpkg release here (vcpkgGitCommitId) and maintain
24+
# consistency manually.
25+
#
26+
# - On NAS HECC systems, we build the C/C++ code with dynamic linkage due
27+
# to the available system dependencies. This is *not* a default
28+
# target supported by vcpkg, but it has a lot of community interest and
29+
# "unofficial" testing support. Ref: https://github.com/microsoft/vcpkg/issues/15006
30+
# We patch up some of the RPATH quirks using 'patchelf'.
31+
#
32+
name: unit-tests
33+
on:
34+
push:
35+
workflow_dispatch:
36+
37+
jobs:
38+
job:
39+
name: ${{ matrix.os }}-${{ github.workflow }}
40+
runs-on: ${{ matrix.os }}
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
os: [ubuntu-latest]
45+
# Python v3.9 is latest version supported by NAS HECC systems
46+
# Main obstacle to upgrading is "pinned" opencv 4.5.12 dependency
47+
python-version: ['3.9.16']
48+
env:
49+
VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg/installed
50+
VCPKG_DEFAULT_TRIPLET: x64-linux-dynamic
51+
52+
steps:
53+
- uses: actions/checkout@v3
54+
- uses: lukka/get-cmake@latest
55+
- name: Install dependencies (Linux)
56+
run: |
57+
sudo apt-get update -y
58+
sudo apt-get install -y \
59+
autoconf \
60+
bison \
61+
gperf \
62+
nasm \
63+
patchelf \
64+
libdbus-1-dev \
65+
libgles2-mesa-dev \
66+
libopenmpi-dev \
67+
libtool \
68+
libx11-dev \
69+
libxcursor-dev \
70+
libxdamage-dev \
71+
libxext-dev \
72+
libxft-dev \
73+
libxi-dev \
74+
libxinerama-dev \
75+
libxrandr-dev \
76+
libxtst-dev
77+
if: matrix.os == 'ubuntu-latest'
78+
- name: Restore from cache and setup vcpkg executable and data files.
79+
uses: lukka/run-vcpkg@v11
80+
with:
81+
vcpkgJsonGlob: '.github/workflows/vcpkg.json'
82+
runVcpkgInstall: true
83+
# Release 2023.04.15
84+
vcpkgGitCommitId: '501db0f17ef6df184fcdbfbe0f87cde2313b6ab1'
85+
- name: Patch vcpkg library headers with patchelf
86+
run: |
87+
cd vcpkg
88+
${{ github.workspace }}/.github/workflows/vcpkg-fix-rpaths
89+
cd ..
90+
- uses: actions/setup-python@v4
91+
with:
92+
python-version: ${{ matrix.python-version }}
93+
cache: 'pip'
94+
- name: Upgrade pip to v23+
95+
run: |
96+
pip install --upgrade pip
97+
pip --version
98+
python --version
99+
- name: Run build+install with pip
100+
run: |
101+
SKBUILD_CONFIGURE_OPTIONS=\
102+
" -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"\
103+
" -DVCPKG_TARGET_TRIPLET=x64-linux-dynamic" pip install -v .
104+
# - name: Setup upterm session
105+
# uses: lhotari/action-upterm@v1
106+
- name: Run C/C++ unit tests
107+
# TODO this should be made cross-platform. Currently works only for ubuntu-latest
108+
# TODO fix RUNPATH of built executables to avoid use of LD_LIBRARY_PATH
109+
run: |
110+
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${{ env.VCPKG_INSTALLED_DIR }}/${{ env.VCPKG_DEFAULT_TRIPLET }}/lib"
111+
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
112+
cd cpp/test
113+
../../_skbuild/linux-x86_64-3.9/cmake-build/run_tests
114+

.github/workflows/vcpkg-fix-rpaths

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
# syntax: patchelf
4+
# [--set-interpreter FILENAME]
5+
# [--page-size SIZE]
6+
# [--print-interpreter]
7+
# [--print-soname] Prints 'DT_SONAME' entry of .dynamic section. Raises an error if DT_SONAME doesn't exist
8+
# [--set-soname SONAME] Sets 'DT_SONAME' entry to SONAME.
9+
# [--set-rpath RPATH]
10+
# [--remove-rpath]
11+
# [--shrink-rpath]
12+
# [--allowed-rpath-prefixes PREFIXES] With '--shrink-rpath', reject rpath entries not starting with the allowed prefix
13+
# [--print-rpath]
14+
# [--force-rpath]
15+
# [--add-needed LIBRARY]
16+
# [--remove-needed LIBRARY]
17+
# [--replace-needed LIBRARY NEW_LIBRARY]
18+
# [--print-needed]
19+
# [--no-default-lib]
20+
# [--clear-symbol-version SYMBOL]
21+
# [--output FILE]
22+
# [--debug]
23+
# [--version]
24+
# FILENAME...
25+
26+
27+
if [ ! -f "vcpkg" ]; then
28+
echo "ERROR: Must run from vcpkg dir"
29+
exit 1
30+
fi
31+
32+
# Find all libs, and patch w/ correct RUNPATH
33+
# '$ORIGIN' is special entry in RUNPATH referring to "this solib's dir",
34+
# shorthand for the LIB_DIR. Alternatively, we could add the actual vcpkg lib dir
35+
# but this makes the vcpkg solib's bulk-relocatable, which is kind of nice.
36+
RUNPATH='$ORIGIN'
37+
TRIPLET=x64-linux-dynamic
38+
39+
LIB_DIR=$PWD/installed/$TRIPLET/lib
40+
FILES=( $( find $LIB_DIR -type f -name 'lib*.so*' ) )
41+
# will break on file names with whitespace
42+
for f in "${FILES[@]}"; do
43+
patchelf --set-rpath "$RUNPATH" "$f"
44+
echo "patchelf --set-rpath \"$RUNPATH\" \"$f\""
45+
done
46+
47+
LIB_DIR=$PWD/installed/$TRIPLET/debug/lib
48+
FILES=( $( find $LIB_DIR -type f -name 'lib*.so*' ) )
49+
# will break on file names with whitespace
50+
for f in "${FILES[@]}"; do
51+
patchelf --set-rpath "$RUNPATH" "$f"
52+
echo "patchelf --set-rpath \"$RUNPATH\" \"$f\""
53+
done
54+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Custom triplet for building shared libraries (*.so) for
2+
# x64 linux architectures. Default for vcpkg is to build
3+
# static libraries (*.a) only.
4+
5+
set(VCPKG_TARGET_ARCHITECTURE x64)
6+
7+
set(VCPKG_CRT_LINKAGE dynamic)
8+
set(VCPKG_LIBRARY_LINKAGE dynamic)
9+
10+
set(VCPKG_CMAKE_SYSTEM_NAME Linux)
11+
12+
set(VCPKG_CXX_FLAGS "-Wl,-rpath,'$ORIGIN'")
13+
set(VCPKG_C_FLAGS "-Wl,-rpath,'$ORIGIN'")
14+
set(VCPKG_LINKER_FLAGS "-Wl,-rpath,'$ORIGIN'")
15+
16+
# use, i.e. don't skip the full RPATH for the build tree
17+
# when building, don't use the install RPATH already
18+
# (but later on when installing)
19+
# set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
20+
21+
#set(CMAKE_SKIP_RPATH FALSE)
22+
#set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
23+
24+
# add the automatically determined parts of the RPATH
25+
# which point to directories outside the build tree to the install RPATH
26+
27+
# # the RPATH to be used when installing, but only if it's not a system directory
28+
# list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
29+
# if("${isSystemDir}" STREQUAL "-1")
30+
# set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
31+
# endif("${isSystemDir}" STREQUAL "-1")
32+

.github/workflows/vcpkg.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
3+
"name": "main",
4+
"version-string": "latest",
5+
"dependencies": [
6+
{"name": "hdf5", "default-features": false, "features": ["cpp"]},
7+
"eigen3",
8+
{"name": "opencv4", "default-features": false, "features": ["contrib", "ffmpeg", "openexr"]},
9+
"boost-iterator",
10+
"boost-lexical-cast",
11+
"boost-fusion",
12+
"boost-format",
13+
"boost-math",
14+
"boost-tokenizer",
15+
"ilmbase",
16+
"gtest",
17+
"pybind11"
18+
],
19+
"vcpkg-configuration": {
20+
"overlay-triplets": ["./vcpkg-triplets"]
21+
}
22+
}

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2+
[![pages-build-deployment](https://github.com/nasa/upsp-processing/actions/workflows/pages/pages-build-deployment/badge.svg)](https://nasa.github.io/upsp-processing)
3+
![Unit Tests](https://github.com/nasa/upsp-processing/actions/workflows/unit-tests.yml/badge.svg?event=push)
4+
5+
-----
6+
17
# upsp-processing
28

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

0 commit comments

Comments
 (0)