Skip to content

Commit

Permalink
Merge pull request #252 from VirtualPlanetaryLaboratory/os-tests
Browse files Browse the repository at this point in the history
Added workflows to test Linux and Mac builds. Windows users will have to use the Windows Subsystem for Linux: https://learn.microsoft.com/en-us/windows/wsl/install.

The code is now checked on Ubuntu 20.04 and 22.04, MacOS 11, 12 and 13.
  • Loading branch information
RoryBarnes authored Nov 1, 2023
2 parents ef85dbf + 161ff39 commit a239fb8
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pip-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-latest]
python: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
Expand Down
52 changes: 25 additions & 27 deletions .github/workflows/tests.yml → .github/workflows/tests-linux.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
name: tests
name: tests-linux

on:
push:
branches: [master, main]
branches: [main]
pull_request:
branches: [master, main]
branches: [main]
workflow_dispatch:

jobs:
tests:
name: 'Run tests on py${{ matrix.python-version }}'
runs-on: ubuntu-latest
name: '${{ matrix.os }}:python-${{ matrix.python-version }}'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- python-version: '3.6'
- python-version: '3.7'
- python-version: '3.8'
- python-version: '3.9'
- python-version: '3.10'
- python-version: '3.11'
os: [ubuntu-20.04, ubuntu-22.04]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
exclude:
- os: ubuntu-22.04
python-version: '3.6'
fail-fast: false

steps:
- uses: actions/checkout@v3
Expand All @@ -29,10 +27,8 @@ jobs:

- name: Set up Python
id: setup_python
uses: conda-incubator/setup-miniconda@v2
uses: actions/setup-python@v4
with:
activate-environment: vplanet
environment-file: environment.yml
python-version: ${{ matrix.python-version }}

- name: Install
Expand All @@ -42,30 +38,32 @@ jobs:
run: |
python -m pip install -U pip
python -m pip install -e .
pip install pytest pytest-cov
sudo apt install lcov
- name: Run tests and generate coverage
if: steps.install.outcome == 'success'
shell: bash -l {0}
run: |
make coverage
run: make coverage

- name: Check test ouptut created
id: check_test_file
uses: andstor/file-existence-action@v2
with:
files: "/home/runner/work/vplanet/vplanet/junit/test-results.xml"
fail: true

- name: Get unique id
id: unique-id
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: |
export JOB_ID=`echo $STRATEGY_CONTEXT | md5sum`
echo "::set-output name=id::$JOB_ID"
uses: Tiryoh/gha-jobid-action@v1
id: jobs

- name: Publish unit test results
uses: EnricoMi/publish-unit-test-result-action@v1
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: junit/test-*.xml
comment_mode: update last

- name: CodeCov
uses: codecov/codecov-action@v2.1.0
uses: codecov/codecov-action@v3
with:
files: ./.coverage
55 changes: 55 additions & 0 deletions .github/workflows/tests-macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: tests-macos
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
tests:
name: '${{ matrix.os }}:python-${{ matrix.python-version }}'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11, macos-12, macos-13]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
fail-fast: false
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python
id: setup_python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
if: steps.setup_python.outcome == 'success'
run: |
python -m pip install -U pip
python -m pip install -e .
python -m pip install pytest pytest-cov
- name: Run tests
if: steps.setup_python.outcome == 'success'
run: make test

- name: Check test ouptut created
id: check_test_file
uses: andstor/file-existence-action@v2
with:
files: "/home/runner/work/vplanet/vplanet/junit/test-results.xml"
fail: true

- name: Get unique id
uses: Tiryoh/gha-jobid-action@v1
id: jobs

- name: Publish unit test results
uses: EnricoMi/publish-unit-test-result-action/composite@v2
if: always()
with:
files: junit/test-*.xml
74 changes: 51 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,60 @@
<h1 align="center">VPLanet: The Virtual Planet Simulator</h1>

<p align="center">
<a href="https://VirtualPlanetaryLaboratory.github.io/vplanet"><img src="https://img.shields.io/badge/Read-the_docs-blue.svg?style=flat"></a>
<a href="https://VirtualPlanetaryLaboratory.github.io/vplanet">
<img src="https://img.shields.io/badge/Read-the_docs-blue.svg?style=flat">
</a>
<a href="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/docs.yml">
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/docs.yml/badge.svg"></a>
<a href="https://ui.adsabs.harvard.edu/abs/2019arXiv190506367B/abstract"><img src="https://img.shields.io/badge/Read-the_paper-darkgreen.svg?style=flat"></a>
<a href="https://VirtualPlanetaryLaboratory.github.io/vplanet/conduct.html"><img src="https://img.shields.io/badge/Code%20of-Conduct-7d93c7.svg"></a>
<a href="https://www.youtube.com/@VPLanetCode/playlists"><img src="https://img.shields.io/badge/You-Tube-darkred.svg"></a><br>
<img src="https://img.shields.io/badge/Unit%20Tests-14,440-darkblue.svg"></a>
<a href="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/tests.yml">
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/tests.yml/badge.svg"></a>
<img src="https://img.shields.io/badge/Memory%20Checks-43-darkblue.svg"></a>
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/docs.yml/badge.svg">
</a>
<a href="https://ui.adsabs.harvard.edu/abs/2019arXiv190506367B/abstract">
<img src="https://img.shields.io/badge/Read-the_paper-darkgreen.svg?style=flat">
</a>
<a href="https://VirtualPlanetaryLaboratory.github.io/vplanet/conduct.html">
<img src="https://img.shields.io/badge/Code%20of-Conduct-7d93c7.svg">
</a>
<a href="https://www.youtube.com/@VPLanetCode/playlists">
<img src="https://img.shields.io/badge/You-Tube-darkred.svg">
</a>
<br>
<img src="https://img.shields.io/badge/Unit%20Tests-14,440-darkblue.svg">
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/tests-linux.yml/badge.svg">
<img src="https://img.shields.io/badge/Ubuntu%2020-Python%203.6%20--%203.11-7d93c7.svg">
<img src="https://img.shields.io/badge/Ubuntu%2022-Python%203.7%20--%203.11-7d93c7.svg">
<br>
<a href="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/tests-macos.yml">
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/tests-macos.yml/badge.svg">
</a>
<img src="https://img.shields.io/badge/Mac%20OS11-Python%203.6%20--%203.11-7d93c7.svg">
<img src="https://img.shields.io/badge/Mac%20OS12-Python%203.6%20--%203.11-7d93c7.svg">
<img src="https://img.shields.io/badge/Mac%20OS13-Python%203.6%20--%203.11-7d93c7.svg">
<br>
<img src="https://img.shields.io/badge/Memory%20Checks-43-darkblue.svg">
<a href="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/memcheck.yml">
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/memcheck.yml/badge.svg"></a>
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/memcheck.yml/badge.svg">
</a>
<a href="https://codecov.io/gh/VirtualPlanetaryLaboratory/vplanet">
<img src="https://codecov.io/gh/VirtualPlanetaryLaboratory/vplanet/branch/master/graph/badge.svg?token=3LFJQO1M6H"><br>
<a href="examples"><img src="https://img.shields.io/badge/Examples-42-darkblue.svg"></a>
<img src="https://codecov.io/gh/VirtualPlanetaryLaboratory/vplanet/branch/main/graph/badge.svg?token=3LFJQO1M6H">
</a>
<br>
<a href="examples">
<img src="https://img.shields.io/badge/Examples-42-darkblue.svg">
</a>
<a href="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/examples.yml">
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/examples.yml/badge.svg"></a>
<img src="https://img.shields.io/badge/Python-3.6%20--%203.11-7d93c7.svg"></a>
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/examples.yml/badge.svg">
</a>
<img src="https://img.shields.io/badge/Python-3.6%20--%203.11-7d93c7.svg">
<a href="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/pip-install.yml">
<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/pip-install.yml/badge.svg"></a><br>
<img src = "https://img.shields.io/badge/Platforms-Linux_|%20macOS_|%20Windows10-darkgreen.svg?style=flat">
<a href="http://ascl.net/1811.017"><img src="https://img.shields.io/badge/ASCL-1811.017-orange.svg?colorB=orange" alt="ascl:1811.017" /></a>
<a href="https://emac.gsfc.nasa.gov"><img src="https://img.shields.io/badge/EMAC-2207%E2%80%94138-blue.svg"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-purple.svg"/></a><br>


<img src="https://github.com/VirtualPlanetaryLaboratory/vplanet/actions/workflows/pip-install.yml/badge.svg">
</a>
<br>
<a href="http://ascl.net/1811.017">
<img src="https://img.shields.io/badge/ASCL-1811.017-orange.svg?colorB=orange" alt="ascl:1811.017">
</a>
<a href="https://emac.gsfc.nasa.gov">
<img src="https://img.shields.io/badge/EMAC-2207%E2%80%94138-blue.svg">
</a>
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-purple.svg"/>
</a>
</p>

Expand Down Expand Up @@ -83,11 +111,11 @@ Many of these modules can be combined together to simulate numerous phenomena an

The [examples/](examples) directory contains input files and scripts for generating the figures in [Barnes et al. (2020)](https://ui.adsabs.harvard.edu/abs/2020PASP..132b4502B/abstract) and subsequent publications. The "examples" badge shows if all the examples can be built with the most recent version. The [Manual/](Manual) directory contains the pdf of [Barnes et al. (2020)](https://ui.adsabs.harvard.edu/abs/2020PASP..132b4502B/abstract), which describes the physics of the first 11 modules, validates the software against observations and/or past results, and uses figures from the [examples/](examples) directory.

An ecosystem of support software is also publicly available. [VPLot](https://github.com/VirtualPlanetaryLaboratory/vplot) is both a command line tool to quickly plot the evolution of a single integration, and also includes matplotlib functions to generate publication-worthy figures. The [VSPACE](https://github.com/VirtualPlanetaryLaboratory/vspace) script generates input files for a parameter space sweep, which can then be performed on an arbitrary number of cores with [MultiPlanet](https://github.com/VirtualPlanetaryLaboratory/multi-planet). For large parameter sweeps, an enormous amount of data can be generated, which can slow analyses. To overcome this barrier, the [BigPlanet](https://github.com/VirtualPlanetaryLaboratory/bigplanet) code can both compress datasets into HDF5 format, including statistics of an integration, and tools to facilitate plotting. These three scripts can be executed from the command line to seamlessly [perform parameter sweeps](https://virtualplanetarylaboratory.github.io/vplanet/parametersweep.html). These Python scripts are optimized for [anaconda](https://www.anaconda.com/) distributions versions 3.5-3.9. The "wheels" badge indicates if you can download and install the executables with pip for these Python distributions.
An ecosystem of support software is also publicly available. [VPLot](https://github.com/VirtualPlanetaryLaboratory/vplot) is both a command line tool to quickly plot the evolution of a single integration, and also includes matplotlib functions to generate publication-worthy figures. The [VSPACE](https://github.com/VirtualPlanetaryLaboratory/vspace) script generates input files for a parameter space sweep, which can then be performed on an arbitrary number of cores with [MultiPlanet](https://github.com/VirtualPlanetaryLaboratory/multi-planet). For large parameter sweeps, an enormous amount of data can be generated, which can slow analyses. To overcome this barrier, the [BigPlanet](https://github.com/VirtualPlanetaryLaboratory/bigplanet) code can both compress datasets into HDF5 format, including statistics of an integration, and tools to facilitate plotting. These three scripts can be executed from the command line to seamlessly [perform parameter sweeps](https://virtualplanetarylaboratory.github.io/vplanet/parametersweep.html). These Python scripts are optimized for [anaconda](https://www.anaconda.com/) distributions versions 3.7-3.9. The "wheels" badge indicates if you can download and install the executables with pip for these Python distributions on the latest Linux and Mac operating systems.

### Code Integrity

Behind the scenes, the VPLanet team maintains code integrity through via various automatic checks at every merge into the main branch. You can see the status of these checks via the "badges" the GitHub logo above. Currently we perform 5 checks: documentation ("docs"), units tests ("tests"), memory checks via [valgrind](http://valgrind.org) ("memcheck"), confirmation that all [examples](examples/) are working ("examples"), and that the code is pip-installable on Linux, Mac, and Windows machines ("pip-install") for the Python distributions listed. The "coverage" badge shows the percentage of the code (by line number) that is currently tested by <a href="https://codecov.io/gh/VirtualPlanetaryLaboratory/vplanet">Codecov</a> at every commit. We are committed to maintaining a stable tool for scientists to analyze any planetary system.
Behind the scenes, the VPLanet team maintains code integrity through via various automatic checks at every merge into the main branch. You can see the status of these checks via the "badges" the GitHub logo above. Currently we perform 5 checks: documentation ("docs"), units tests ("tests"), memory checks via [valgrind](http://valgrind.org) ("memcheck"), confirmation that all [examples](examples/) are working ("examples"), and that the code is pip-installable on the latest Linux and Mac operating systems ("pip-install") for the Python distributions listed after the GitHub Actions badge. The percentage of the lines of code that are executed by the unit tests is shown with the "codecov" badge, with details available at our <a href="https://codecov.io/gh/VirtualPlanetaryLaboratory/vplanet">Codecov</a> account. We are committed to maintaining a stable tool for scientists to analyze any planetary system.

### Community

Expand Down
47 changes: 2 additions & 45 deletions src/flare.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,49 +97,6 @@ void ReadFlareFFD(BODY *body,
} else if (iFile > 0)
body[iFile - 1].iFlareFFD = FLARE_FFD_DAVENPORT;
}
/*
void ReadFlareSlopeUnits(BODY *body,
CONTROL *control,
FILES *files,
OPTIONS *options,
SYSTEM *system,
int iFile) {
/* This parameter cannot exist in primary file */
/*int lTmp = -1;
char cTmp[OPTLEN];
AddOptionString(files->Infile[iFile].cIn,
options->cName,
cTmp,
&lTmp,
control->Io.iVerbose);
if (lTmp >= 0) {
NotPrimaryInput(iFile,
options->cName,
files->Infile[iFile].cIn,
lTmp,
control->Io.iVerbose);
if (!memcmp(sLower(cTmp), "se", 2)) {
body[iFile - 1].iFlareSlopeUnits = FLARE_SLOPE_SEC;
} else if (!memcmp(sLower(cTmp), "mi", 2)) {
body[iFile - 1].iFlareSlopeUnits = FLARE_SLOPE_MINUTE;
} else if (!memcmp(sLower(cTmp), "ho", 2)) {
body[iFile - 1].iFlareSlopeUnits = FLARE_SLOPE_HOUR;
} else if (!memcmp(sLower(cTmp), "da", 2)) {
body[iFile - 1].iFlareSlopeUnits = FLARE_SLOPE_DAY;
} else {
if (control->Io.iVerbose >= VERBERR)
fprintf(stderr,
"ERROR: Unknown argument to %s: %s. Options are SEC, MIN, HOUR "
"or DAY.\n",
options->cName,
cTmp);
LineExit(files->Infile[iFile].cIn, lTmp);
}
UpdateFoundOption(&files->Infile[iFile], options, lTmp, iFile);
} else if (iFile > 0)
body[iFile - 1].iFlareSlopeUnits = FLARE_SLOPE_DAY;
}*/

void ReadFlareBandPass(BODY *body,
CONTROL *control,
Expand Down Expand Up @@ -1018,8 +975,8 @@ void FinalizeUpdateLXUVFlare(BODY *body, UPDATE *update, int *iEqn, int iVar,
// not need this.
/*void FinalizeUpdateFlareFreqMax(BODY *body, UPDATE *update, int *iEqn, int
iVar, int iBody, int iFoo) {
/* No primary variables for FLARE yet*/
/* update[iBody].iaModule[iVar][*iEqn] = FLARE;
// No primary variables for FLARE yet
// update[iBody].iaModule[iVar][*iEqn] = FLARE;
update[iBody].iNumFlareFreqMax = (*iEqn)++;
}
*/
Expand Down
17 changes: 0 additions & 17 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,18 +436,14 @@ int iGetNumLines(char cFile[]) {
FILE *fp;
char cLine[LINE];

fprintf(stderr,"File: %s\n",cFile);

fp = fopen(cFile, "r");
if (fp == NULL) {
fprintf(stderr, "Unable to open %s.\n", cFile);
exit(EXIT_INPUT);
}

memset(cLine, '\0', LINE);
// fprintf(stderr,"File: %s\n",cFile);
while (fgets(cLine, LINE, fp) != NULL) {
// fprintf(stderr,"iLine: %d, %s",iNumLines,cLine);
iNumLines++;

/* Check to see if line is too long. The maximum length of a line is set
Expand Down Expand Up @@ -489,8 +485,6 @@ void InitializeInput(INFILE *input) {
FILE *fp;
char cLine[LINE];

fprintf(stderr,"File: %s\n",input->cIn);

fp = fopen(input->cIn, "r");
if (fp == NULL) {
fprintf(stderr, "Unable to open %s.\n", input->cIn);
Expand All @@ -503,23 +497,12 @@ fprintf(stderr,"File: %s\n",input->cIn);
input->cReactions[0] = 0;
*/

// fprintf(stderr,"File: %s\n",input->cIn);
for (iLine = 0; iLine < input->iNumLines; iLine++) {
/* Initialize bLineOK */
input->bLineOK[iLine] = 0;

/* Now find those lines that are comments or blank
for (iPos = 0; iPos < LINE; iPos++) {
cLine[iPos] = '\0';
}
*/
memset(cLine, '\0', LINE);

fgets(cLine, LINE, fp);
// fprintf(stderr,"iLine: %d, %s",iLine,cLine);
/* Check for # sign or blank line */
if (CheckComment(cLine, LINE)) {
/* Line is OK */
input->bLineOK[iLine] = 1;
} else {
// Is it a blank line?
Expand Down
3 changes: 3 additions & 0 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -2166,8 +2166,11 @@ void WriteLog(BODY *body, CONTROL *control, FILES *files, MODULE *module,
double dDt, dTotTime;

/* Get derivatives */
fprintf(stderr,"In WriteLog.\n");
PropertiesAuxiliary(body, control, system, update);
fprintf(stderr,"After PropsAux.\n");
dDt = fdGetTimeStep(body, control, system, update, fnUpdate);
fprintf(stderr,"After GetTimeStep.\n");

if (iEnd == 0) {
sprintf(cTime, "Input");
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
def vplanet_output(request):
path = os.path.abspath(os.path.dirname(request.fspath))
infile = os.path.join(path, "vpl.in")
output = vplanet.run(infile, quiet=True, clobber=True, C=True)
output = vplanet.run(infile, quiet=False, clobber=True, C=True)
yield output
if CLEAN_OUTPUTS:
for file in (
Expand Down
Loading

0 comments on commit a239fb8

Please sign in to comment.