Skip to content

Commit

Permalink
Merge branch 'master' into doxygen
Browse files Browse the repository at this point in the history
  • Loading branch information
dlebauer authored Feb 7, 2025
2 parents 157f151 + 8ff893e commit d611011
Show file tree
Hide file tree
Showing 25 changed files with 1,254 additions and 113 deletions.
104 changes: 69 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,86 @@ on:
push:
branches:
- master

pull_request:

jobs:

# try to build SIPNET on Ubuntu & MacOS
# Build and Integration Test
build:
strategy:
fail-fast: false
matrix:
OS:
OS:
- macos-latest
- ubuntu-latest
- ubuntu-20.04
runs-on: ${{ matrix.OS }}

steps:
# checkout source code
- uses: actions/checkout@v2

# install doxygen
- name: Install Doxygen
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get install doxygen -y
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew install --formula doxygen
fi
# compile SIPNET
- name: compile sipnet
run: make

# remove existing test output file
- name: Remove Niwout Output File
run: rm Sites/Niwot/niwot.out

# run single sipnet run
- name: Run SIPNET on Sites/Niwot/niwot
run: ./sipnet

# check for correct output of Niwot run
- name: Check if niwot.out is generated
shell: bash
run: |
if [ ! -f Sites/Niwot/niwot.out ]; then
echo "::error title={No Output}::Test run for Niwot site failed to produce output"
exit 1
fi
# Check if niwot.out has changed
- name: Check whether niwot.out has changed
shell: bash
run: |
if git diff --exit-code Sites/Niwot/niwot.out; then
echo "Success: Niwot.out created and has not changed"
else
echo "::error title={Output Changed}::The test file niwot.out has changed. This is expected to fail with some changes to SIPNET. When this happens, assess correctness and then update the reference niwot.out."
exit 1
fi
# Run Unit Tests
test:
needs: build
strategy:
fail-fast: false
matrix:
OS:
- macos-latest
- ubuntu-latest
- ubuntu-20.04
runs-on: ${{ matrix.OS }}

steps:
# checkout source code
- uses: actions/checkout@v2

# compile sipnet
- name: compile sipnet
run: make

# remove existing test output file
- name: Remove Niwout Output File
run: rm Sites/Niwot/niwot.out

# run single sipnet run
- name: sipnet on Sites/Niwot/niwot
run: ./sipnet

# check output of test
- name: fail if no niwot output exists
if: ${{ hashFiles('Sites/Niwot/niwot.out') == '' }}
run: |
echo "::error title={No Output}::Test run for Niwot site failed to produce output"
exit 1
# check whether niwot.out has changed
- name: Check whether niwot.out has changed
shell: bash
run: |
if git diff --exit-code Sites/Niwot/niwot.out; then
echo "Success: Niwot.out created and has not changed"
else
echo "::error title={Output Changed}::The test file niwot.out has changed"
exit 1
fi
# checkout source code
- uses: actions/checkout@v2

# compile unit tests
- name: compile tests
run: make test

# run tests
- name: Run Unit Tests
run: make testrun

14 changes: 0 additions & 14 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ docs/latex
.Rproj.user
.Rhistory


# build artifacts and executables
*.o
estimate
sipnet
subsetData
transpose
.doxygen.stamp

# documentation
docs/html/
docs/latex/


# System-specific files
.DS_Store
.Rproj.user
Expand Down
19 changes: 18 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

## Compiling

SIPNET uses `make` build the model and documentation. There are also miscellaneous targets for running analysis workflows:
SIPNET uses `make` to build the model and documentation. There are also miscellaneous targets for running analysis workflows:

```sh
# build SIPNET executable
Expand All @@ -15,3 +15,20 @@ make clean
# list all make commands
make help
```
## Testing

SIPNET also uses `make` to build and run its unit tests. This can be done with the following commands:
```shell
# Compile tests
make test
# Run tests
make testrun
# Clean after tests are run
make testclean
```

If changes are made to the `modelStructure.h` file and unit tests are failing, try running the update script as shown below. Consider running this script even if unit tests _are not_ failing.
```shell
# Run this command from the root directory to update unit test versions of modelStructures.h
tests/update_model_structures.sh
```
55 changes: 44 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
CC=gcc
LD=gcc
AR=ar
CFLAGS=-Wall
LIBLINKS=-lm

ESTIMATE_CFILES=sipnet.c ml-metro5.c ml-metrorun.c paramchange.c runmean.c util.c spatialParams.c namelistInput.c outputItems.c
ESTIMATE_CFILES=sipnet.c ml-metro5.c ml-metrorun.c paramchange.c runmean.c util.c spatialParams.c namelistInput.c outputItems.c events.c
ESTIMATE_OFILES=$(ESTIMATE_CFILES:.c=.o)

SENSTEST_CFILES=sipnet.c sensTest.c paramchange.c runmean.c util.c spatialParams.c namelistInput.c outputItems.c
SENSTEST_CFILES=sipnet.c sensTest.c paramchange.c runmean.c util.c spatialParams.c namelistInput.c outputItems.c events.c
SENSTEST_OFILES=$(SENSTEST_CFILES:.c=.o)

SIPNET_CFILES=sipnet.c frontend.c runmean.c util.c spatialParams.c namelistInput.c outputItems.c
SIPNET_CFILES=sipnet.c frontend.c runmean.c util.c spatialParams.c namelistInput.c outputItems.c events.c
SIPNET_OFILES=$(SIPNET_CFILES:.c=.o)

TRANSPOSE_CFILES=transpose.c util.c
Expand All @@ -25,13 +26,9 @@ DOXYFILE = docs/Doxyfile
DOXYGEN_HTML_DIR = docs/html
DOXYGEN_LATEX_DIR = docs/latex

# .PHONY indicates target names that are not file names, preventing conflicts if these names are used for filenames
.PHONY: all clean document estimate sipnet transpose subsetData doxygen

# all: estimate sensTest sipnet transpose subsetData
all: estimate sipnet transpose subsetData document


# Only update docs if source files or Doxyfile have changed
document: .doxygen.stamp

Expand All @@ -58,8 +55,45 @@ subsetData: $(SUBSET_DATA_OFILES)
clean:
rm -f $(ESTIMATE_OFILES) $(SIPNET_OFILES) $(TRANSPOSE_OFILES) $(SUBSET_DATA_OFILES) estimate sensTest sipnet transpose subsetData
rm -rf $(DOXYGEN_HTML_DIR) $(DOXYGEN_LATEX_DIR)
#clean:
# rm -f $(ESTIMATE_OFILES) $(SENSTEST_OFILES) $(SIPNET_OFILES) $(TRANSPOSE_OFILES) $(SUBSET_DATA_OFILES) estimate sensTest sipnet transpose subsetData

# UNIT TESTS
SIPNET_TEST_DIRS:=$(shell find tests/sipnet -type d -mindepth 1 -maxdepth 1)
SIPNET_TEST_DIRS_RUN:= $(addsuffix .run, $(SIPNET_TEST_DIRS))
SIPNET_TEST_DIRS_CLEAN:= $(addsuffix .clean, $(SIPNET_TEST_DIRS))
SIPNET_LIB=libsipnet.a

$(SIPNET_LIB): $(SIPNET_LIB)($(SIPNET_OFILES))
ranlib $(SIPNET_LIB)

test: pretest $(SIPNET_TEST_DIRS) posttest $(SIPNET_LIB)

pretest:
cp modelStructures.h modelStructures.orig.h

# The dash in the build command tells make to continue if there are errors, allowing cleanup
$(SIPNET_TEST_DIRS): pretest $(SIPNET_LIB)
cp $@/modelStructures.h modelStructures.h
-$(MAKE) -C $@

# This is far from infallible, as model_structures.h will be in a bad place if a test
# build step fails in a non-catchable way
posttest: $(SIPNET_TEST_DIRS)
mv modelStructures.orig.h modelStructures.h

testrun: $(SIPNET_TEST_DIRS_RUN)

$(SIPNET_TEST_DIRS_RUN):
$(MAKE) -C $(basename $@) run

testclean: $(SIPNET_TEST_DIRS_CLEAN)
rm -f $(SIPNET_LIB)

$(SIPNET_TEST_DIRS_CLEAN):
$(MAKE) -C $(basename $@) clean

.PHONY: all clean document estimate sipnet transpose subsetData doxygen
test $(SIPNET_TEST_DIRS) pretest posttest $(SIPNET_LIB) testrun
$(SIPNET_TEST_DIRS_RUN) testclean $(SIPNET_TEST_DIRS_CLEAN)

help:
@echo "Available targets:"
Expand All @@ -68,7 +102,7 @@ help:
@echo " all - Builds all components."
@echo " document - Generate documentation."
@echo " sipnet - Builds the 'sipnet' executable."
@echo " clean - Removes compiled files and executables."
@echo " clean - Removes compiled files, executables, and documentation."
@echo " depend - Automatically generates dependency information for source files."
@echo " === additional tools ==="
@echo " estimate - Builds 'estimate' executable to estimate parameters using MCMC."
Expand All @@ -80,4 +114,3 @@ depend::

# DO NOT DELETE THIS LINE -- make depend depends on it.


Loading

0 comments on commit d611011

Please sign in to comment.