From d78fb2cba166c21b7f65f79defdcd39e0997b662 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Thu, 29 Apr 2021 09:40:24 +0200 Subject: [PATCH 01/16] Reset version in develop branch --- CHANGELOG.md | 2 ++ CITATION.cff | 4 ++-- CMakeLists.txt | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e18a570..2d43d455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog][] by Olivier Lacan, and this project a [Keep a Changelog]: [Semantic Versioning]: +## [Unreleased] + ## [1.0.1] - 2021-04-29 ### Fixed diff --git a/CITATION.cff b/CITATION.cff index da4b9612..10ce0194 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -10,9 +10,9 @@ authors: affiliation: Senckenberg Biodiversity and Climate Research Centre orcid: https://orcid.org/0000-0003-4925-7248 title: "Modular Megafauna Model" -version: 1.0.1 +version: 0.0.0 # This DOI represents all versions, and will always resolve to the latest one. doi: 10.5281/zenodo.4710254 -date-released: 2021-04-29 +date-released: license: LGPL-3.0-or-later repository-code: https://github.com/wtraylor/modular_megafauna_model diff --git a/CMakeLists.txt b/CMakeLists.txt index c6685c8e..f70435cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ cmake_minimum_required (VERSION 3.10) project ("Modular Megafauna Model" # This version must match exactly the Git tag! # Compare the "check_version" job in ".gitlab-ci.yml". - VERSION 1.0.1 + VERSION 0.0.0 DESCRIPTION "A physiological, dynamic herbivore simulator in C++." LANGUAGES CXX ) From 7c50744e868b6b74e3d8f4ecf2c534f7a0882f58 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Thu, 29 Apr 2021 09:43:15 +0200 Subject: [PATCH 02/16] Check that release matches version in CITATION.cff --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d9d758d..46c6ded4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -37,6 +37,8 @@ check_version: script: - echo "If this fails, check that the Git tag matches VERSION in CMakeLists.txt." - test "$CI_COMMIT_TAG" == $(grep "^\s*VERSION" CMakeLists.txt | grep -oP '\d+\.\d+\.\d+.*') + - echo "If this fails, check that the Git tag matches version in CITATION.cff" + - test "$CI_COMMIT_TAG" == $(grep "^version\s*:" CITATION.cff | grep -oP '\d+\.\d+\.\d+.*') # Check that all files are correctly formatted according to ".clang-format". # Exclude the "external/" directory because they will use different formatting. From a335cef42c914a4af91eae090a261ae8eee9c3d5 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Thu, 29 Apr 2021 09:52:05 +0200 Subject: [PATCH 03/16] Check that versions are reset in develop branch --- .gitlab-ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 46c6ded4..2bf16dfa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,10 +24,26 @@ check_license: script: - reuse lint +# The develop branch should reset the version to "0.0.0" so that there can +# never be a confusion with a released version. Compare CONTRIBUTING.md. +check_develop_version: + image: ubuntu:latest + stage: lint + rules: + # Only execute on tags that look like a version, e.g.: "0.5.1" + - if: '$CI_COMMIT_BRANCH == "develop"' + when: always + script: + - echo "If this fails, check the version is reset to '0.0.0' in CITATION.cff and CMakeLists.txt." + - test "0.0.0" == $(grep "^\s*VERSION" CMakeLists.txt | grep -oP '\d+\.\d+\.\d+.*') + - test "0.0.0" == $(grep "^version\s*:" CITATION.cff | grep -oP '\d+\.\d+\.\d+.*') + - echo "'date-released:' in CITATION.cff should be unset." + - grep --silent "^date-released\s*:\s*$" CITATION.cff + # Check that the tag matches the version in the CMakeLists.txt file. # If the tag doesn’t match, you will need to change CMakeLists.txt and # forcefully move the tag to the corrected commit. -check_version: +check_release_version: image: ubuntu:latest stage: lint rules: From e92f0183eb0c12c9f9fb716a6236cfad12ca4e14 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Thu, 29 Apr 2021 15:32:03 +0200 Subject: [PATCH 04/16] Allow exponents <= 0 for allometric relationships --- src/Fauna/get_forage_demands.test.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Fauna/get_forage_demands.test.cpp b/src/Fauna/get_forage_demands.test.cpp index 115038e3..b519f4fb 100644 --- a/src/Fauna/get_forage_demands.test.cpp +++ b/src/Fauna/get_forage_demands.test.cpp @@ -22,9 +22,6 @@ TEST_CASE("Fauna::calc_allometry()") { // Typical case without error. REQUIRE_NOTHROW(calc_allometry(GivenPointAllometry({0.75, Y}), 10, 8)); - // Exponent <= 0 - CHECK_THROWS(calc_allometry(GivenPointAllometry({-0.1, Y}), 10, 10)); - CHECK_THROWS(calc_allometry(GivenPointAllometry({0, Y}), 10, 10)); // Body mass <= 0 CHECK_THROWS(calc_allometry(GivenPointAllometry({0.75, Y}), 0, 10)); CHECK_THROWS(calc_allometry(GivenPointAllometry({0.75, Y}), 10, 0)); From 4ec5d7e539131329dac852438611a2f5374c1d75 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Thu, 29 Apr 2021 15:32:52 +0200 Subject: [PATCH 05/16] Order allometry coefficient & exponent correctly --- src/Fauna/hft.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fauna/hft.h b/src/Fauna/hft.h index 67b44a99..11a1c18d 100644 --- a/src/Fauna/hft.h +++ b/src/Fauna/hft.h @@ -432,7 +432,7 @@ struct Hft { /** @{ \name "digestion": Digestion-related parameters. */ /// Parameters for \ref DigestiveLimit::Allometric /** See documentation in \ref DigestiveLimit::Allometric.*/ - GivenPointAllometry digestion_allometric = {0.05, -0.25}; + GivenPointAllometry digestion_allometric = {-0.25, 0.05}; /// Factor to change ruminant digestibility for other digestion types. /** @@ -530,7 +530,7 @@ struct Hft { * \see \ref ExpenditureComponent::FieldMetabolicRate * \see \ref DigestiveLimit::FixedFraction */ - GivenPointAllometry expenditure_basal_rate = {7.5, 0.75}; + GivenPointAllometry expenditure_basal_rate = {0.75, 7.5}; /// Energy expenditure components, summing up to actual expenditure. std::set expenditure_components = { From 0242e8d2d84eaf351cafc1149a03751045b2a420 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Thu, 29 Apr 2021 15:40:49 +0200 Subject: [PATCH 06/16] Add pipeline badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8134f64a..f1ca288b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ SPDX-License-Identifier: CC-BY-4.0 [![LGPL logo](docs/images/lgpl.svg)](https://choosealicense.com/licenses/lgpl-3.0/) [![REUSE-compliant](docs/images/reuse-compliant.svg)][REUSE] [![Documentation Status](https://readthedocs.org/projects/modular-megafauna-model/badge/?version=latest)](https://modular-megafauna-model.readthedocs.io/en/latest/?badge=latest) +[![Pipeline Status](https://gitlab.com/wtraylor/modular_megafauna_model/badges/master/pipeline.svg)](https://gitlab.com/wtraylor/modular_megafauna_model/-/commits/master) [![DOI](docs/images/zenodo_doi.svg)](https://zenodo.org/badge/latestdoi/228426088) [REUSE]: https://reuse.software From e3ab5bb40b6ed6f05a32fc628a783589599164ee Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Thu, 29 Apr 2021 15:43:39 +0200 Subject: [PATCH 07/16] Remove subfolder under `tests/` in repo structure Better overview if only top-level folders are listed --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index f1ca288b..e84e10e6 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,7 @@ This project follows the [Pitchfork Layout](https://github.com/vector-of-bool/pi - `include/`: Public API header files. - `LICENSES/`: Folder with licenses, compliant with [REUSE][]. - `src/`: Source and (private) header files of the project. Subdirectories correspond to C++ namespaces. -- `tests/`: Unit tests. - - `tests/bad_insfiles/`: Example erroneous example files, each of which should throw an error. +- `tests/`: Unit tests and test scripts. - `tools/`: Different helper tools for the developer. Usage From c92030b5072b89e5fa5ec79622ea3618b1692f30 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 08:51:53 +0200 Subject: [PATCH 08/16] Add changelog entry --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d43d455..c525bf09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ The format is based on [Keep a Changelog][] by Olivier Lacan, and this project a ## [Unreleased] +### Fixed +- The unit tests were broken after the last release. + ## [1.0.1] - 2021-04-29 ### Fixed From 228d2344ee5243a6f0de24f84c126f342918ae73 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 09:42:05 +0200 Subject: [PATCH 09/16] Add missing #include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit g++ 11.1.0 doesn’t automatically include anymore, it seems. --- CHANGELOG.md | 1 + external/cpptoml/include/cpptoml.h | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c525bf09..9f8dc49e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog][] by Olivier Lacan, and this project a ### Fixed - The unit tests were broken after the last release. +- cpptoml wouldn’t compile with latest `g++` (11.1.0). ## [1.0.1] - 2021-04-29 diff --git a/external/cpptoml/include/cpptoml.h b/external/cpptoml/include/cpptoml.h index 5a00da3b..1dc9fd18 100644 --- a/external/cpptoml/include/cpptoml.h +++ b/external/cpptoml/include/cpptoml.h @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include From dfc4bd5450f48b53e797a63cd625bb1514593900 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 10:09:08 +0200 Subject: [PATCH 10/16] Use gcc Docker image to run executables The `libstdc++.so` library must be the same between the system that compiled the binary and the one that executes it. --- .gitlab-ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2bf16dfa..cf6a42e5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,7 +95,7 @@ compile: expire_in: 20 minutes doxygen: - image: ubuntu:latest + image: gcc:latest stage: build before_script: - apt-get update -qq @@ -103,7 +103,6 @@ doxygen: cmake default-jre doxygen - g++ graphviz texlive-base script: @@ -120,7 +119,7 @@ doxygen: - build/docs/html/ unit_tests: - image: ubuntu:latest + image: gcc:latest stage: test needs: ["compile"] script: @@ -130,7 +129,7 @@ unit_tests: # Check that the linter works and that the example instruction files are # correct. linter: - image: ubuntu:latest + image: gcc:latest stage: test needs: ["compile"] script: @@ -156,7 +155,7 @@ linter: - (./build/megafauna_insfile_linter tests/bad_insfiles/two_hfts_with_same_name.toml 2>&1 || true) | grep -iq 'HFT.*is defined twice' memcheck: - image: ubuntu:latest + image: gcc:latest stage: test needs: ["compile"] before_script: @@ -185,7 +184,7 @@ memcheck: - build/memcheck.log demo_simulation: - image: ubuntu:latest + image: gcc:latest stage: test needs: ["compile"] script: From a414733a61f737be892495b7f330a69137db1936 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 10:18:12 +0200 Subject: [PATCH 11/16] Use readthedocs Docker image for doxygen --- .gitlab-ci.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf6a42e5..f264b9de 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -94,17 +94,12 @@ compile: - build/megafauna_unit_tests expire_in: 20 minutes +# Compare the Sphinx instructions in "docs/sphinx/conf.py". doxygen: - image: gcc:latest + image: readthedocs/build:latest stage: build before_script: - - apt-get update -qq - - apt-get install -y -qq - cmake - default-jre - doxygen - graphviz - texlive-base + - conda install --yes cmake script: - mkdir --parents build - cd build From cb226c25ddc7833fa77b1fe1354e201cbd38b408 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 10:19:58 +0200 Subject: [PATCH 12/16] Use slim Alpine Docker image for simple checks --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f264b9de..5e78cd16 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ check_license: # The develop branch should reset the version to "0.0.0" so that there can # never be a confusion with a released version. Compare CONTRIBUTING.md. check_develop_version: - image: ubuntu:latest + image: alpine:latest stage: lint rules: # Only execute on tags that look like a version, e.g.: "0.5.1" @@ -44,7 +44,7 @@ check_develop_version: # If the tag doesn’t match, you will need to change CMakeLists.txt and # forcefully move the tag to the corrected commit. check_release_version: - image: ubuntu:latest + image: alpine:latest stage: lint rules: # Only execute on tags that look like a version, e.g.: "0.5.1" From d2ba3d7866ed70c6abe072ddc5fbd201d12b5b19 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 10:23:06 +0200 Subject: [PATCH 13/16] Switch from Alpine to slim Debian Docker image MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alpine Linux doesn’t have the `grep` options I need. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5e78cd16..8b89b2d4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ check_license: # The develop branch should reset the version to "0.0.0" so that there can # never be a confusion with a released version. Compare CONTRIBUTING.md. check_develop_version: - image: alpine:latest + image: debian-slim:latest stage: lint rules: # Only execute on tags that look like a version, e.g.: "0.5.1" @@ -44,7 +44,7 @@ check_develop_version: # If the tag doesn’t match, you will need to change CMakeLists.txt and # forcefully move the tag to the corrected commit. check_release_version: - image: alpine:latest + image: debian-slim:latest stage: lint rules: # Only execute on tags that look like a version, e.g.: "0.5.1" From 0e15a8a120d4ec53e30a30998e56ff7a59c4bd11 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 10:23:57 +0200 Subject: [PATCH 14/16] Increase demo simulation years so we can see some population ups and downs. --- CHANGELOG.md | 3 +++ examples/demo_simulation.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f8dc49e..e1d4189f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ The format is based on [Keep a Changelog][] by Olivier Lacan, and this project a ## [Unreleased] +### Changed +- Increase demo simulation years so we can see some population ups and downs. + ### Fixed - The unit tests were broken after the last release. - cpptoml wouldn’t compile with latest `g++` (11.1.0). diff --git a/examples/demo_simulation.toml b/examples/demo_simulation.toml index 0a6b89cf..9d86d736 100644 --- a/examples/demo_simulation.toml +++ b/examples/demo_simulation.toml @@ -9,7 +9,7 @@ [general] # Number of simulation years. [1,∞) -years = 20 +years = 100 # Number of habitat groups. habitat_groups = 2 From 206950de1558f096526e2c027f54a7a385605308 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 10:27:26 +0200 Subject: [PATCH 15/16] Fix spelling of Debian image --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b89b2d4..043d7539 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ check_license: # The develop branch should reset the version to "0.0.0" so that there can # never be a confusion with a released version. Compare CONTRIBUTING.md. check_develop_version: - image: debian-slim:latest + image: debian:stable-slim stage: lint rules: # Only execute on tags that look like a version, e.g.: "0.5.1" @@ -44,7 +44,7 @@ check_develop_version: # If the tag doesn’t match, you will need to change CMakeLists.txt and # forcefully move the tag to the corrected commit. check_release_version: - image: debian-slim:latest + image: debian:stable-slim stage: lint rules: # Only execute on tags that look like a version, e.g.: "0.5.1" From 2166cbe9882bb68761da74dc33ae6e925c050756 Mon Sep 17 00:00:00 2001 From: Wolfgang Traylor Date: Wed, 5 May 2021 14:11:02 +0200 Subject: [PATCH 16/16] Revert to Ubuntu image for running Doxygen The readthedocs Docker image does not contain the required Doxygen version (1.8.16) yet. --- .gitlab-ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 043d7539..e5843eed 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -95,11 +95,22 @@ compile: expire_in: 20 minutes # Compare the Sphinx instructions in "docs/sphinx/conf.py". +# TODO: Currently (2021-05-05), the Docker image "readthedocs/build:latest" +# (7.0) is based on Ubuntu 18.04. It does not contain the required Doxygen +# version 1.8.16 yet. As soon as the readthedocs image is properly updated, +# we should use it here in the CI. doxygen: - image: readthedocs/build:latest + image: ubuntu:latest stage: build before_script: - - conda install --yes cmake + - apt-get update -qq + - apt-get install -y -qq + cmake + default-jre + doxygen + g++ + graphviz + texlive-base script: - mkdir --parents build - cd build