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

Multiplatform builds #36

Open
wants to merge 20 commits into
base: main
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
2 changes: 1 addition & 1 deletion .github/workflows/first_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Welcome
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
// Get a list of all issues created by the PR opener
Expand Down
131 changes: 100 additions & 31 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,48 +15,117 @@ jobs:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: block
allowed-endpoints: >
azure.archive.ubuntu.com:80
esm.ubuntu.com:443
files.pythonhosted.org:443
github.com:443
motd.ubuntu.com:443
packages.microsoft.com:443
pypi.org:443

- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install linters
run: |
sudo apt-get update
sudo apt-get install uncrustify cppcheck iwyu
- uses: actions/setup-python@v4
- name: Install pre-commit

- name: Set up Python3
uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: '3.x'

- name: Run pre-commit hooks
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

build-netcdf:
name: Build (${{ matrix.build_type }}; ${{ matrix.os }}; NetCDF=True)
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
build_type: [ Debug, Release ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
azure.archive.ubuntu.com:80
esm.ubuntu.com:443
github.com:443
motd.ubuntu.com:443
packages.microsoft.com:443
raw.githubusercontent.com:443

- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Fetch NetCDF CMake script
run: |
python -m pip install --upgrade pip
python -m pip install pre-commit
- name: Run pre-commit
wget https://raw.githubusercontent.com/Kitware/VTK/master/CMake/FindNetCDF.cmake -P cmake

- name: Build
id: build
continue-on-error: true
run: |
cmake .
cmake --build . --config ${{ matrix.build_type }} -j 3

- name: Run tests
if: steps.build.outcome == 'success'
run: |
pre-commit run --all-files
./Raven
./Raven -v

build:
name: Build RavenHydroFramework binary (${{ matrix.build_type }})
name: Build (${{ matrix.build_type }}; ${{ matrix.os }}; NetCDF=False)
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
build_type: [Debug, Release]
os: [ ubuntu-latest, macos-latest, windows-latest ]
build_type: [ Debug, Release ]
defaults:
run:
shell: bash
shell: bash -l {0}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install libnetcdf-dev build-essential cmake
- name: Fetch NetCDF CMake script
run: |
wget https://raw.githubusercontent.com/Kitware/VTK/master/CMake/FindNetCDF.cmake -P cmake
- name: Build
id: build
continue-on-error: true
run: |
cmake . -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
make -j4
- name: Run tests
if: steps.build.outcome == 'success'
run: |
./Raven
./Raven -v
- name: Harden Runner
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
azure.archive.ubuntu.com:80
esm.ubuntu.com:443
github.com:443
motd.ubuntu.com:443
objects.githubusercontent.com:443
packages.microsoft.com:443

- name: Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install dependencies (Windows)
if: matrix.os == 'windows-latest'
uses: lukka/get-cmake@2bcb1a4c14ab154443cc740dced0f9b6a8fb2b59 # v3.29.6

- name: Build
id: build
continue-on-error: true
run: |
cmake .
cmake --build . --config ${{ matrix.build_type }} -j 3

- name: Run tests
run: |
./Raven
./Raven -v
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

# Find NetCDF
find_package(NetCDF)

# find header & source
file(GLOB HEADER "src/*.h")
file(GLOB SOURCE "src/*.cpp")
Expand Down Expand Up @@ -45,15 +46,16 @@ if(COMPILE_EXE)
target_compile_definitions(Raven PUBLIC STANDALONE)
set_target_properties(Raven PROPERTIES LINKER_LANGUAGE CXX)
endif()
source_group("Header Files" FILES ${HEADER})
source_group("Source Files" FILES ${SOURCE})

IF(NETCDF_FOUND)
add_definitions(-Dnetcdf)
include_directories(${NetCDF_INCLUDE_DIRS})
target_link_libraries(Raven NetCDF::NetCDF)
ENDIF()

source_group("Header Files" FILES ${HEADER})
source_group("Source Files" FILES ${SOURCE})

# unset cmake variables to avoid polluting the cache
unset(COMPILE_LIB CACHE)
unset(COMPILE_EXE CACHE)
1 change: 0 additions & 1 deletion src/DemandOptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2304,7 +2304,6 @@ void CDemandOptimizer::WriteMinorOutput(const optStruct &Options,const time_stru

//first slack terms are due to environmental flow constraints (_nEnviroFlowGoals) and reservoir outflow targets (2*_nReservoirs)
//this is first index of user-specified slack variable

int s=_nEnviroFlowGoals+2*_nReservoirs;
if (!_stage_discharge_as_goal) {
//s=_nEnviroFlowGoals; //No slack variables for reservoirs (currently retained regardless of stage discharge status)
Expand Down