Skip to content

Commit

Permalink
Merge pull request #58 from WrenRaming/main
Browse files Browse the repository at this point in the history
CI/CD update: build tRIBS packages with github actions workflow.
  • Loading branch information
WrenRaming authored Apr 19, 2024
2 parents acddb86 + eaf32fd commit 3a93676
Show file tree
Hide file tree
Showing 14 changed files with 515 additions and 63 deletions.
44 changes: 27 additions & 17 deletions .github/workflows/compile_and_test_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,40 @@ on:

jobs:
build_and_test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
compiler: [g++-11]
include:
- os: ubuntu-latest
compiler: g++-11
target: Linux

runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

# Install MPI Development Files
- name: Install MPI Development Files
run: sudo apt-get install -y libopenmpi-dev

# Set CMAKE_PREFIX_PATH
- name: Set CMAKE_PREFIX_PATH
run: export CMAKE_PREFIX_PATH=/usr/lib/openmpi:$CMAKE_PREFIX_PATH
#- name: Set CMAKE_PREFIX_PATH
# run: export CMAKE_PREFIX_PATH=/usr/lib/openmpi:$CMAKE_PREFIX_PATH

# Build Parallel Version of tRIBS
- name: Create build directory and run CMake for parallel version
run: cmake -S . -B cmake-build-parallel -DCMAKE_BUILD_TYPE=Release -Dparallel=ON -Dpackaging=ON -Dos=Linux

- name: Build Project Parallel
run: cmake --build cmake-build-parallel --target all

# Build Serial Version of tRIBS
- name: Create build directory and run CMake for serial version
run: cmake -S . -B cmake-build-serial -DCMAKE_BUILD_TYPE=Release -Dparallel=OFF -Dpackaging=ON -Dos=Linux

- name: Build Project Serial
run: cmake --build cmake-build-serial --target all

- name: Create build directory and run CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
# Run CPack
- name: Package tRIBS
run: cpack --config packaging/utilities/MultiCPackConfig.cmake

- name: Build Project
run: cmake --build build --target all
# Upload STGZ package
- name: Package artifacts
uses: actions/upload-artifact@v4
with:
name: tRIBS-STGZ-linux
path: "packaging/Linux/TIN-based Real-time Integrated Basin Simulator-5.2.0.sh"
35 changes: 27 additions & 8 deletions .github/workflows/compile_and_test_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,40 @@ on:

jobs:
build_and_test:
runs-on: macos-latest
runs-on: macos-14
steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

# Install MPI Development Files
- name: Install MPI Development Files
run: brew install open-mpi

# Set CMAKE_PREFIX_PATH
- name: Set CMAKE_PREFIX_PATH
run: export CMAKE_PREFIX_PATH=/usr/local/opt/open-mpi:$CMAKE_PREFIX_PATH
#- name: Set CMAKE_PREFIX_PATH
# run: export CMAKE_PREFIX_PATH=/usr/local/opt/open-mpi:$CMAKE_PREFIX_PATH

- name: Create build directory and run CMake
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug
# Build Parallel Version of tRIBS
- name: Create build directory and run CMake for parallel version
run: cmake -S . -B cmake-build-parallel -DCMAKE_BUILD_TYPE=Release -Dparallel=ON -Dpackaging=ON -Dos=macOS/Silicon

- name: Build Project
run: cmake --build build --target all
- name: Build Project Parallel
run: cmake --build cmake-build-parallel --target all

# Build Serial Version of tRIBS
- name: Create build directory and run CMake for serial version
run: cmake -S . -B cmake-build-serial -DCMAKE_BUILD_TYPE=Release -Dparallel=OFF -Dpackaging=ON -Dos=macOS/Silicon

- name: Build Project Serial
run: cmake --build cmake-build-serial --target all

# Run CPack
- name: Package tRIBS
run: cpack --config packaging/utilities/MultiCPackConfig.cmake

# Upload STGZ package
- name: Package artifacts
uses: actions/upload-artifact@v4
with:
name: tRIBS-STGZ-macos-Silicon
path: "packaging/macOS/Silicon/TIN-based Real-time Integrated Basin Simulator-5.2.0.sh"
50 changes: 50 additions & 0 deletions .github/workflows/compile_and_test_macos_intel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: compile_and_test_macos_intel
run-name: ${{github.actor}} is conducting a tRIBS build test for MacOS.

on:
workflow_dispatch:
push:
paths:
- "**.cpp"
- "**.h"
- "**/CMakeLists.txt"

jobs:
build_and_test:
runs-on: macos-13 #Intel Chip
steps:
- name: Checkout Repository
uses: actions/checkout@v4

# Install MPI Development Files
- name: Install MPI Development Files
run: brew install open-mpi

# Set CMAKE_PREFIX_PATH
#- name: Set CMAKE_PREFIX_PATH
# run: export CMAKE_PREFIX_PATH=/usr/local/opt/open-mpi:$CMAKE_PREFIX_PATH

# Build Parallel Version of tRIBS
- name: Create build directory and run CMake for parallel version
run: cmake -S . -B cmake-build-parallel -DCMAKE_BUILD_TYPE=Release -Dparallel=ON -Dpackaging=ON -Dos=macOS/Intel

- name: Build Project Parallel
run: cmake --build cmake-build-parallel --target all

# Build Serial Version of tRIBS
- name: Create build directory and run CMake for serial version
run: cmake -S . -B cmake-build-serial -DCMAKE_BUILD_TYPE=Release -Dparallel=OFF -Dpackaging=ON -Dos=macOS/Intel

- name: Build Project Serial
run: cmake --build cmake-build-serial --target all

# Run CPack
- name: Package tRIBS
run: cpack --config packaging/utilities/MultiCPackConfig.cmake

# Upload STGZ package
- name: Package artifacts
uses: actions/upload-artifact@v4
with:
name: tRIBS-STGZ-macos-Intel
path: "packaging/macOS/Intel/TIN-based Real-time Integrated Basin Simulator-5.2.0.sh"
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
.idea
.run
cmake-build-debug*
cmake-build-release
cmake-build-parallel
cmake-build-serial
build
_CPack_Packages
76 changes: 51 additions & 25 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") #needed for testing cross compilation see: https://stackoverflow.com/questions/53633705/cmake-the-c-compiler-is-not-able-to-compile-a-simple-test-program

#variables that can be specified using tP4
set(exe "tRIBS")

set(parallel ON)
set(cxx_flags "-O2")
#set(parallel ON) # currently set through -Dparallel, but can be manually set by uncommenting
set(cxx_flags "-O2") #release mode overwrites with "-O3"
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flags}") # -O2 appears to be the fastest option
set(CMAKE_INCLUDE_CURRENT_DIR ON)

#set compiler if necessary, this has to be done before project()
#set (CMAKE_CXX_COMPILER <specify compiler here>)
Expand All @@ -19,24 +18,15 @@ set(CMAKE_VERBOSE_MAKEFILE ON)
# message(STATUS "${CMAKE_CXX_COMPILER_VERSION}}")
#endif()

project(${exe})
add_executable(${exe} src/main.cpp)

# project files
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# used while testing and developing
#set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${cxx_flags}") # -O2 appears to be the fastest option

### sanitizer finds leaks in parallel version--open mpi is known to have leaks
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-scope -g") # different options available for using Sanitizer

#################### BELOW SPECIFIES COMPILATION FOR SERIAL OR PARALLEL VERSION OF TRIBS ###############################

# set to ON to compile parallel version, set to OFF to compile serial version
if(parallel)
set(exe "tRIBSpar")
project(${exe}
DESCRIPTION "Parallel Distribution of the TIN-based Real-time Integrated Basin Simulator Distributed Hydrological Model"
VERSION 5.2.0
)
add_executable(${exe} src/main.cpp)

message(WARNING "Compiling parallel version of tRIBS")

target_compile_definitions(${exe}
Expand All @@ -46,7 +36,7 @@ if(parallel)
GRAPH_TRIBS
PRIVATE
LINUX_32
)
)

find_package(MPI REQUIRED) #Note: changes to MPI path etc may require reset of CMakeCache.txt
if (MPI_FOUND) #Note:this should find whichever implementation of MPI is installed (i.e. Open MPI, Intel, mpich)
Expand Down Expand Up @@ -159,19 +149,23 @@ if(parallel)
)

else()
# currently only tested on new macs (M1 and M2 chips)
set(exe "tRIBS")
project(${exe}
DESCRIPTION "Serial Distribution of the TIN-based Real-time Integrated Basin Simulator Distributed Hydrological Model"
VERSION 5.2.0)
add_executable(${exe} src/main.cpp)
message(WARNING "Compiling serial version of tRIBS")

if(APPLE) # not sure though if loading libraries are any different for linux--windows don't know
target_compile_definitions(${exe}
PRIVATE
MAC
)
)
else()
target_compile_definitions(${exe}
PRIVATE
LINUX_32
)
)
endif()

target_sources(
Expand Down Expand Up @@ -270,3 +264,35 @@ else()
)

endif()

# can be passed via the command line with -Dpackaging=ON
#set(packaging ON)

if (packaging)

if (NOT DEFINED os)
set(os "macOS/Silicon") # options: macOS/Silicon, macOS/Intel, or Linux
endif ()

install(
TARGETS ${PROJECT_NAME}
)

set(CPACK_VERBOSE ON)
set(CPACK_PACKAGE_NAME "TIN-based Real-time Integrated Basin Simulator")
set(CPACK_PACKAGE_FILE_NAME "TIN-based Real-time Integrated Basin Simulator-5.2.0")
set(CPACK_PACKAGE_VENDOR "tRIBS developers")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/LICENSE.txt")
# Set the custom script for the STGZ generator
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/packaging/utilities/CPack.STGZ_Header.sh.in")
#set(CPACK_STGZ_HEADER_FILE "${CMAKE_SOURCE_DIR}/packaging/utilities/CPack.STGZ_Header.sh.in")

set(CPACK_GENERATOR "STGZ")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_SOURCE_DIR}/packaging/${os}")
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/packaging/${os}")

include(CPack)
cpack_add_component(CPACK_COMPONENTS_ALL)

endif ()

17 changes: 7 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
![](https://img.shields.io/readthedocs/tribshms)

# TIN-based Real-time Integrated Basin Simulator: Version 5.2
This repository contains source code for the fully distributed hydrological model: TIN-based Real-time Integrated Basin Simulator (tRIBS). Details on running the model and its applications can be found [here](https://tribshms.readthedocs.io/en/latest/).
This repository contains source code for the fully distributed hydrological model: TIN-based Real-time Integrated Basin Simulator (tRIBS). We provide extensive documention of the model with additional resources [here](https://tribshms.readthedocs.io/en/latest/).

Licensing information can be found in [LICENSE.txt](./LICENSE.txt).
Licensing information can be found in [LICENSE.txt](./LICENSE.txt).git

## Installation and Compilation
tRIBS is an object-oriented based code written in c++. In order to run tRIBS you must download and compile the source code from this GitHub repository.
Instructions for using CMake to compile tRIBS can be found [here.](./doc/md/CMake.md)
## Installation
We provide three options for accessing the tRIBS model:

Alternatively, a Docker image of tRIBS is maintained on [Docker Hub](https://hub.docker.com/repositories/tribs).
Further information can be found [here](doc/md/DOCKER.md).


**For additional details in working with source code, including pertinent git commands, see the following instructions [here](./doc/md/DEV_INST.md). Additional information about debugging tRIBS can be found [here](./doc/md/DEBUG.md)**
1) Compiled executables for latest [macOS]() and [Ubuntu]() systems
2) [Docker](https://tribshms.readthedocs.io/en/latest/man/Docker.html)
3) [CMake build system](https://tribshms.readthedocs.io/en/latest/man/Model_Execution.html#cmake)
Binary file added packaging/Ubuntu/tRIBS-5.2.0-Ubuntu.sh
Binary file not shown.
Binary file added packaging/macOS/Intel/tRIBS-5.2.0-Intel.sh
Binary file not shown.
Binary file added packaging/macOS/Silicon/tRIBS-5.2.0-Silicon.sh
Binary file not shown.
Loading

0 comments on commit 3a93676

Please sign in to comment.