Skip to content

Commit

Permalink
Merge pull request #12 from OceanParcels/add_unittesting
Browse files Browse the repository at this point in the history
Add GitHub Action for unittesting CI
  • Loading branch information
erikvansebille authored May 2, 2024
2 parents a35f8d4 + 1ce8ac3 commit 03c068e
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/actions/install-plasticparcels/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Setup Conda and install plasticparcels
description: >
In-repo composite action to setup Conda and install parcels. Installation of parcels relies on
`setup.py` file being available in the root. For general setup of Anaconda environments, just use
the `mamba-org/setup-micromamba@v1` action (setting C variables as required), or the `conda-incubator/setup-miniconda` action.
inputs:
environment-file:
description: Conda environment file to use.
default: environment.yml
environment-name:
description: Name to use for the Conda environment
default: test
runs:
using: "composite"
steps:
- name: Install micromamba (${{ inputs.environment-file }})
uses: mamba-org/setup-micromamba@v1
with:
environment-file: ${{ inputs.environment-file }}
environment-name: ${{ inputs.environment-name }}
channels: conda-forge
cache-environment: true
cache-downloads: true
- name: Install parcels
run: pip install .
shell: bash -el {0}
19 changes: 19 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: linting
on:
pull_request:
push:
jobs:
linting:
name: Linting with flake8
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Python setup
run: |
pip install wheel
pip install flake8
- name: flake8
run: |
python -m flake8 plasticparcels
python -m flake8 tests
33 changes: 33 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: unit-tests
on:
push:
branches:
- "master"
- "test-me/*"
pull_request:
branches:
- "*"
schedule:
- cron: "0 7 * * 1" # Run every Monday at 7:00 UTC

defaults:
run:
shell: bash -el {0}

jobs:
unit-test:
name: Unittesting on ubuntu with python latest
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Conda and parcels
uses: ./.github/actions/install-plasticparcels
with:
environment-file: environment.yml
environment-name: py3_parcels
- name: Unit test
run: |
python -m pytest -v -s tests
8 changes: 8 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: plasticparcels
channels:
- conda-forge
dependencies:
- parcels>=3.0.2

# Testing
- pytest

0 comments on commit 03c068e

Please sign in to comment.