From cf28a789c864bc666c06353eac4ca06ab3865368 Mon Sep 17 00:00:00 2001 From: Oscar Mojica Date: Mon, 26 Feb 2024 16:18:51 -0300 Subject: [PATCH] Create test_bindings.yml set right version local install build execs in CI Update test_bindings.yml run c examples use full path Update test_bindings.yml test copy file use default env GITHUB_WORKSPACE var add some explanatory comments use RUNNER_TEMP to transfer file from one workflow step to another. check more gcc versions use another action for install gcc Use an action that also installs gfortran clean CMakeLists.txt Build sperr.o object file only once Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt Update CMakeLists.txt Add CI workflow --- .github/workflows/test_bindings.yml | 86 +++++++++++++++++++++++++++++ CMakeLists.txt | 10 ---- 2 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/test_bindings.yml diff --git a/.github/workflows/test_bindings.yml b/.github/workflows/test_bindings.yml new file mode 100644 index 0000000..ca989b8 --- /dev/null +++ b/.github/workflows/test_bindings.yml @@ -0,0 +1,86 @@ +name: SPERR Fortran Bindings Testing + +# Define when to trigger the workflow +on: + push: + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: + +jobs: + test_bindings: + name: Test SPERR Fortran bindings on ubuntu-latest + runs-on: ubuntu-latest + + strategy: + matrix: + gcc-version: [9, 10, 11] + + steps: + # Setup GCC + - name: Get compiler + uses: fortran-lang/setup-fortran@v1 + with: + compiler: gcc + version: ${{ matrix.gcc-version }} + + # Clone the SPERR repository + - name: Clone SPERR repository + uses: GuillaumeFalourd/clone-github-repo-action@v2.3 + with: + depth: 1 + branch: 'v0.8.1' + owner: 'NCAR' + repository: 'SPERR' + + # Access the cloned repository content and build the library + - name: Access cloned repository content and build library + run: | + echo "ROOT" + ls -la + echo "CLONED REPO" + cd SPERR + cmake -S . -B build -DBUILD_CLI_UTILITIES=OFF -DBUILD_UNIT_TESTS=OFF -DCMAKE_VERBOSE_MAKEFILE=ON + cmake --build build + sudo cmake --install build + + # Run C examples to generate output files + - name: Run C examples + run: | + cd SPERR/examples/C_API + ln -s ../../test_data . + gcc -g -O3 2d.c -o 2d.out -I/usr/local/include -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSPERR + gcc -g -O3 3d.c -o 3d.out -I/usr/local/include -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lSPERR + ./2d.out ./test_data/lena512.float 512 512 1 2.5 + mv output.stream 2d-output.stream + mv output.data 2d-output.data + ./3d.out ./test_data/density_128x128x256.d64 128 128 256 1 2.6 -d + mv output.stream 3d-output.stream + mv output.data 3d-output.data + cp ${GITHUB_WORKSPACE}/SPERR/test_data/lena512.float ${RUNNER_TEMP} + cp ${GITHUB_WORKSPACE}/SPERR/test_data/density_128x128x256.d64 ${RUNNER_TEMP} + cp *.data *.stream ${RUNNER_TEMP} + + # Clone the own repository to access test data files + - name: Clone own repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # Build executables and compare output files + - name: Build executables and compare files + run: | + cmake -S . -B build -DCMAKE_VERBOSE_MAKEFILE=ON + cmake --build build + cp ${RUNNER_TEMP}/lena512.float build/ + cp ${RUNNER_TEMP}/density_128x128x256.d64 build/ + cd build + ./2d + cmp ${RUNNER_TEMP}/2d-output.stream output.stream && echo "Files are identical" || { echo "Files are different"; exit 1; } + cmp ${RUNNER_TEMP}/2d-output.data output.data && echo "Files are identical" || { echo "Files are different"; exit 1; } + rm -f output.data output.stream + ./3d + cmp ${RUNNER_TEMP}/3d-output.stream output.stream && echo "Files are identical" || { echo "Files are different"; exit 1; } + cmp ${RUNNER_TEMP}/3d-output.data output.data && echo "Files are identical" || { echo "Files are different"; exit 1; } + rm -f output.data output.stream diff --git a/CMakeLists.txt b/CMakeLists.txt index ff5fdb0..69c69fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,13 +22,6 @@ pkg_search_module(LIBRARY_NAME REQUIRED SPERR) include_directories(${LIBRARY_NAME_INCLUDE_DIRS}) link_directories(${LIBRARY_NAME_LIBRARY_DIRS}) -# External dependencies (provide default values, users can override) -#set(EXTERN_INCLUDE_DIR /path/to/lossy_compression/include CACHE PATH "Path to lossy_compression include directory") -#set(EXTERN_LIB_DIR /path/to/lossy_compression/lib CACHE PATH "Path to lossy_compression lib directory") - -#include_directories(${EXTERN_INCLUDE_DIR}) -#link_directories(${EXTERN_LIB_DIR}) - # List of source files set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) set(TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test) @@ -45,9 +38,6 @@ set(TEST_3D_FILES ${TEST_DIR}/test_sperr_3d.f90 ) -# Create an object library for common source files in the src folder -#add_library(sperr_object OBJECT ${SRC_FILES}) - # Create executables in the root directory and link with the object library add_executable(2d ${TEST_2D_FILES} ${SRC_FILES}) add_executable(3d ${TEST_3D_FILES} ${SRC_FILES})