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

Set up automated tests via Github Actions #128

Merged
merged 9 commits into from
Aug 8, 2024
Merged
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
72 changes: 72 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Tests for PROTEUS

on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch:

jobs:
test:
if: github.event.pull_request.draft == false
name: Run Coverage and Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.10']

steps:
- uses: actions/checkout@v3
with:
submodules: 'true'

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

- uses: actions/cache@v3
id: cache-virtualenv
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Install dependencies
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
run: |
python -m pip install -e .[develop]

- name: Test with pytest
run: |
coverage run -m pytest

- name: Report coverage
run: |
coverage json
export TOTAL=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
echo $'\n```' >> $GITHUB_STEP_SUMMARY
coverage report >> $GITHUB_STEP_SUMMARY
echo $'\n```' >> $GITHUB_STEP_SUMMARY

- name: Make coverage badge
if: ${{ github.ref == 'refs/heads/master' && matrix.python-version == '3.10' }}
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_TOKEN }}
gistID: b4ee7dab92e20644bcb3a5ad09f71165
filename: covbadge.svg
label: Coverage
message: ${{ env.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ env.total }}
19 changes: 18 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git clone https://github.com/FormingWorlds/PROTEUS proteus
Install using `virtualenv`:

```console
cd gemdat
cd proteus
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -e .[develop]
Expand All @@ -28,6 +28,23 @@ conda activate proteus
pip install -e .[develop]
```

### Running tests

PROTEUS uses [pytest](https://docs.pytest.org/en/latest/) to run the tests.
You can run the tests for yourself using:

```console
pytest
```

To check coverage:

```console
coverage run -m pytest
coverage report # to output to terminal
coverage html # to generate html report
```

### Building the documentation

The documentation is written in [markdown](https://www.markdownguide.org/basic-syntax/), and uses [mkdocs](https://www.mkdocs.org/) to generate the pages.
Expand Down
29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![Documentation Status](https://readthedocs.org/projects/fwl-proteus/badge/?version=latest)](https://fwl-proteus.readthedocs.io/en/latest/?badge=latest)
[![Tests for PROTEUS](https://github.com/FormingWorlds/actions/workflows/tests.yaml/badge.svg)](https://github.com/FormingWorlds/actions/workflows/tests.yaml)
![Coverage](https://gist.githubusercontent.com/stefsmeets/b4ee7dab92e20644bcb3a5ad09f71165/raw/covbadge.svg)
[![Documentation Status](https://readthedocs.org/projects/fwl-proteus/badge/?version=latest)](https://fwl-proteus.readthedocs.io/en/latest/?badge=latest)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

![PROTEUS banner](https://raw.githubusercontent.com/FormingWorlds/PROTEUS/master/docs/images/PROTEUS_white.png#gh-light-mode-only)
Expand All @@ -9,17 +11,17 @@
**PROTEUS** is a Python framework that simulates the coupled evolution
of the atmospheres and interiors of rocky planets.

## Installation instructions
## Installation instructions

Click [here](https://fwl-proteus.readthedocs.io/en/latest/installation.html) for steps and troubleshooting advice.

## Run instructions

Only attempt to run PROTEUS after you have followed all of the installation instructions.
If using a fresh shell, it is necessary to perform the following steps:
1. `conda activate proteus` (if using Anaconda/Miniconda)
2. `source PROTEUS.env`
Then you can start the model by running: `proteus.py`. See the ReadTheDocs pages for more information.
Only attempt to run PROTEUS after you have followed all of the installation instructions.
If using a fresh shell, it is necessary to perform the following steps:
1. `conda activate proteus` (if using Anaconda/Miniconda)
2. `source PROTEUS.env`
Then you can start the model by running: `start_proteus.py`. See the ReadTheDocs pages for more information.

## Updating the code

Expand All @@ -29,7 +31,7 @@ Run `git submodule update --recursive --remote`

| Name | Email address |
| - | - |
Tim Lichtenberg | tim.lichtenberg[at]rug.nl |
Tim Lichtenberg | tim.lichtenberg[at]rug.nl |
Harrison Nicholls | harrison.nicholls[at]physics.ox.ac.uk |
Laurent Soucasse | l.soucasse[at]esciencecenter.nl |
Stef Smeets | s.smeets[at]esciencecenter.nl |
Expand All @@ -45,18 +47,19 @@ Hamish Innes | hamish.innes[at]fu-berlin.de |

| Object | Description |
| - | - |
| `proteus.py` | Main PROTEUS Python script |
| `start_proteus.py` | Main PROTEUS Python script |
| `README.md` | Overview file |
| `pyproject.toml` | Documentation file |
| `pyproject.toml` | Project configuration file |
| `CODE_OF_CONDUCT.md` | Project code of conduct |
| `LICENSE.txt` | Project license |
| `JANUS/` | Submodule JANUS |
| `src/proteus` | Source code for PROTEUS |
| `JANUS/` | Submodule JANUS |
| `SPIDER/` | Submodule SPIDER |
| `VULCAN/` | Submodule VULCAN |
| `Mors/` | Submodule Mors |
| `utils/` | Code used for running PROTEUS and its submodules |
| `plot/` | Code used for plotting results |
| `output/` | Output folder with subfolders for each model run |
| `input/` | Input folder (e.g. stellar spectra, example configs) |
| `docs/` | Documentation source files |
| `examples/` | Example cases that the model should be able to reproduce |
| `docs/` | Documentation source files |
| `examples/` | Example cases that the model should be able to reproduce |
Loading
Loading