Skip to content

Commit

Permalink
Merge pull request pyswmm#45 from SWMM-Project/upstream-dev
Browse files Browse the repository at this point in the history
Upstream dev
  • Loading branch information
michaeltryby authored May 30, 2020
2 parents 24b6746 + e320cc8 commit a361419
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 40 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Test

on:
push:
branches: [ upstream-dev ]
pull_request:
branches: [ upstream-dev ]

jobs:
win_build:
runs-on: windows-2016
defaults:
run:
shell: cmd
env:
PROJECT: swmm
BUILD_HOME: build
TEST_HOME: nrtests

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup python
uses: actions/setup-python@v2
with:
python-version: '3.7'

- name: Install requirements
run: |
python -m pip install --upgrade pip
python -m pip install -r tools/requirements-win.txt
- name: Build and unit test
run: tools/make.cmd /t

- name: Build for reg test
run: tools/make.cmd

- name: Before reg test
run: tools/before-nrtest.cmd

- name: Run reg test
run: tools/run-nrtests.cmd %GITHUB_SHA% %GITHUB_RUN_ID%_%GITHUB_RUN_NUMBER%

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: nrtest-artifacts
path: upload/
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@


build/

.DS_Store

build*/
nrtest*/

*_export.h

src/outfile/include/*_export.h
src/solver/include/*_export.h
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# CMakeLists.txt - CMake configuration file for swmm-solver
#
# Created: July 11, 2019
# Modified: Nov 25, 2019
# Updated: May 29, 2020
#
# Author: Michael E. Tryby
# US EPA ORD/CESER
Expand All @@ -22,7 +22,7 @@ project(swmm-solver
)

# Append local dir to module search path
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

# Sets the position independent code property for all targets
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Expand All @@ -40,8 +40,7 @@ set(LIBRARY_DIST "lib")
set(CONFIG_DIST "cmake")


option(BUILD_TESTS "Builds component tests (requires Boost)" OFF)
option(BUILD_DEF "Builds library with def file interface" OFF)
option(BUILD_TESTS "Build component tests (requires Boost)" OFF)


# Add project subdirectories
Expand Down Expand Up @@ -74,6 +73,7 @@ install(
swmm-output-config.cmake
)


# Create install rules for vcruntime.dll, msvcp.dll, vcomp.dll etc.
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
include(InstallRequiredSystemLibraries)
Expand Down
35 changes: 35 additions & 0 deletions extern/boost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#
# CMakeLists.txt - CMake configuration file for swmm-solver/extern
#
# Created: March 16, 2020
# Updated: May 21, 2020
#
# Author: Michael E. Tryby
# US EPA - ORD/CESER
#


if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
else()
set(Boost_USE_STATIC_LIBS OFF)
add_definitions(-DBOOST_ALL_DYN_LINK)
endif()


# Environment variable "BOOST_ROOT_X_XX_X" points to local install location
if (DEFINED ENV{BOOST_ROOT_1_72_0})
set(BOOST_ROOT $ENV{BOOST_ROOT_1_72_0})

elseif(DEFINED ENV{BOOST_ROOT_1_67_0})
set(BOOST_ROOT $ENV{BOOST_ROOT_1_67_0})

endif()


find_package(Boost 1.67.0
COMPONENTS
unit_test_framework
)

include_directories (${Boost_INCLUDE_DIRS})
14 changes: 14 additions & 0 deletions src/solver/swmm5.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
LIBRARY SWMM5.DLL

EXPORTS
swmm_close = _swmm_close@0
swmm_end = _swmm_end@0
swmm_getError = _swmm_getError@8
swmm_getMassBalErr = _swmm_getMassBalErr@12
swmm_getVersion = _swmm_getVersion@0
swmm_getWarnings = _swmm_getWarnings@0
swmm_open = _swmm_open@12
swmm_report = _swmm_report@0
swmm_run = _swmm_run@12
swmm_start = _swmm_start@4
swmm_step = _swmm_step@4
18 changes: 8 additions & 10 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#
# CMakeLists.txt - CMake configuration file for epanet/tests
# CMakeLists.txt - CMake configuration file for swmm-solver/tests
#
# Created: Mar 4, 2020
# Updated: May 21, 2020
#
# Author: Michael E. Tryby
# US EPA ORD/CESER
#


#Prep ourselves for compiling with boost
if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
else()
set(Boost_USE_STATIC_LIBS OFF)
add_definitions(-DBOOST_ALL_DYN_LINK)
endif()

find_package(Boost COMPONENTS unit_test_framework system thread filesystem)
include_directories (${Boost_INCLUDE_DIRS})
include(../extern/boost.cmake)


add_subdirectory(outfile)
Expand Down
7 changes: 5 additions & 2 deletions tools/before-nrtest.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
::
:: before-test.cmd - Stages test and benchmark files for nrtest
::
:: Date Created: 10/16/2019
:: Date Updated:
:: Created: Oct 16, 2019
:: Updated: May 29, 2020
::
:: Author: Michael E. Tryby
:: US EPA - ORD/CESER
Expand Down Expand Up @@ -111,6 +111,9 @@ for /F delims^=^"^ tokens^=4 %%d in ( 'findstr %PLATFORM% %TEST_HOME%\manifest.j
)
if not defined REF_BUILD_ID ( echo "ERROR: REF_BUILD_ID could not be determined" & exit /B 1 )

:: GitHub Actions
echo ::set-env name=REF_BUILD_ID::%REF_BUILD_ID%


:: return to users current directory
cd %CUR_DIR%
31 changes: 16 additions & 15 deletions tools/make.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
::
:: make.cmd - builds project
::
:: Date Created: 10/15/2019
:: Date Updated:
:: Created: Oct 15, 2019
:: Updated: May 29, 2020
::
:: Author: Michael E. Tryby
:: US EPA - ORD/CESER
Expand All @@ -28,6 +28,7 @@ set "PROJECT=swmm"
set "BUILD_HOME=build"
set "PLATFORM=win32"


:: determine project directory
set "CUR_DIR=%CD%"
set "SCRIPT_HOME=%~dp0"
Expand Down Expand Up @@ -69,26 +70,22 @@ if exist %BUILD_HOME% (
for /F "tokens=*" %%f in ( 'findstr CMAKE_GENERATOR:INTERNAL %BUILD_HOME%\CmakeCache.txt' ) do (
for /F "delims=:= tokens=3" %%m in ( 'echo %%f' ) do (
set CACHE_GEN=%%m
if not "!CACHE_GEN!" == "!GENERATOR!" ( rmdir /s /q %BUILD_HOME% & mkdir %BUILD_HOME% )
if not "!CACHE_GEN!" == "!GENERATOR!" ( rmdir /s /q %BUILD_HOME% )
)
)
) else (
mkdir %BUILD_HOME%^
& if %ERRORLEVEL% NEQ 0 ( echo "ERROR: unable to make %BUILD_HOME% dir" & exit /B 1 )
)


:: perform the build
cd %BUILD_HOME%
if %ERRORLEVEL% NEQ 0 ( echo "ERROR: unable to cd %BUILD_HOME% dir" & exit /B 1 )
cmake -E make_directory %BUILD_HOME%


if %TESTING% EQU 1 (
cmake -G"%GENERATOR%" -DBUILD_TESTS=ON -DBOOST_ROOT=C:\local\boost_1_67_0 ..^
&& cmake --build . --config Debug^
& echo. && ctest -C Debug --output-on-failure
cmake -E chdir ./%BUILD_HOME% cmake -G"%GENERATOR%" -DBUILD_TESTS=ON ..^
&& cmake --build ./%BUILD_HOME% --config Debug^
& echo. && cmake -E chdir ./%BUILD_HOME% ctest -C Debug --output-on-failure
) else (
cmake -G"%GENERATOR%" -DBUILD_TESTS=OFF ..^
&& cmake --build . --config Release --target install
cmake -E chdir ./%BUILD_HOME% cmake -G"%GENERATOR%" -DBUILD_TESTS=OFF ..^
&& cmake --build ./%BUILD_HOME% --config Release --target package
)


Expand All @@ -104,5 +101,9 @@ for /F "tokens=*" %%f in ( 'findstr CMAKE_SHARED_LINKER_FLAGS:STRING %BUILD_HOME
if not defined PLATFORM ( echo "ERROR: PLATFORM could not be determined" & exit /B 1 )


:: GitHub Actions
echo ::set-env name=PLATFORM::%PLATFORM%


:: return to users current dir
:: cd %CUR_DIR%
cd %CUR_DIR%
10 changes: 5 additions & 5 deletions tools/requirements-win.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#
# requirements-win.txt - Python requirements for running nrtest on Win32/Win64
#
# Date Created: 10/17/2019
# Date Updated: 11/26/2019
# Date Created: Oct 17, 2019
# Date Updated: May 21, 2020
#
# Author: Michael E. Tryby
# US EPA ORD/CESER
Expand All @@ -15,8 +15,8 @@

nrtest

-f https://github.com/michaeltryby/swmm-python/releases/download/v0.3.0-dev3/swmm.output-0.4.0.dev3-cp36-cp36m-win_amd64.whl
swmm.output
-f https://github.com/SWMM-Project/swmm-python/releases/download/v0.6.0-rc.2/swmm_toolkit-0.5.0-cp37-cp37m-win_amd64.whl
swmm-toolkit

-f https://github.com/michaeltryby/swmm-python/releases/download/v0.3.0-dev3/nrtest_swmm-0.5.0-py3-none-any.whl
-f https://github.com/SWMM-Project/swmm-python/releases/download/v0.6.0-rc.1/nrtest_swmm-0.6.0-py3-none-any.whl
nrtest-swmm
32 changes: 29 additions & 3 deletions tools/run-nrtests.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
::
:: run_nrtest.cmd - Runs numerical regression test
::
:: Date Created: 10/16/2019
:: Date Updated:
:: Created: Oct 16, 2019
:: Updated: May 29, 2020
::
:: Author: Michael E. Tryby
:: US EPA - ORD/CESER
Expand All @@ -26,6 +26,11 @@
setlocal EnableDelayedExpansion


:: check that dependencies are installed
where 7z > nul
if %ERRORLEVEL% neq 0 ( echo "ERROR: 7zip not installed" & exit /B 1 )


:: Check that required environment variables are set
if not defined PROJECT ( echo "ERROR: PROJECT must be defined" & exit /B 1 )
if not defined BUILD_HOME ( echo "ERROR: BUILD_HOME must be defined" & exit /B 1 )
Expand All @@ -39,7 +44,7 @@ set "CUR_DIR=%CD%"
set "SCRIPT_HOME=%~dp0"
cd %SCRIPT_HOME%
pushd ..
set PROJ_DIR=%CD%
set "PROJ_DIR=%CD%"
popd


Expand All @@ -62,6 +67,7 @@ if not exist apps\%PROJECT%-%SUT_BUILD_ID%.json (


:: recursively build test list
:: set "TESTS=tests\examples"
set TESTS=
for /F "tokens=*" %%T in ('dir /b /s /a:d tests') do (
set FULL_PATH=%%T
Expand Down Expand Up @@ -110,5 +116,25 @@ echo INFO: Comparing SUT artifacts to REF %REF_BUILD_ID%
set NRTEST_COMMAND=%NRTEST_COMPARE_CMD% %TEST_OUTPUT_PATH% %REF_OUTPUT_PATH% --rtol %RTOL_VALUE% --atol %ATOL_VALUE% -o benchmark\receipt.json
%NRTEST_COMMAND%

echo.

:: create SUT benchmark archive
echo INFO: Staging nrtest artifacts for upload
cd .\benchmark
7z a benchmark-%PLATFORM%.zip .\%PROJECT%-%SUT_BUILD_ID% > nul

if not exist %PROJ_DIR%\upload (
mkdir %PROJ_DIR%\upload
)
move /Y receipt.json %PROJ_DIR%\upload\receipt.json > nul
move /Y benchmark-%PLATFORM%.zip %PROJ_DIR%\upload\benchmark-%PLATFORM%.zip > nul

:: echo INFO: Artifacts staged at %PROJ_DIR%\upload


:: GitHub Actions
echo ::set-env name=SUT_BUILD_ID::%SUT_BUILD_ID%


:: Return user to their current dir
cd %CUR_DIR%

0 comments on commit a361419

Please sign in to comment.