From 2594c92e9ce4ef777e5bd2772403ee43d64f98c6 Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Thu, 2 May 2024 15:15:08 +0200 Subject: [PATCH 1/3] First implementation of unit testing --- .../actions/install-plasticparcels/action.yml | 26 +++++++++++++++ .github/workflows/unit_tests.yml | 33 +++++++++++++++++++ environment.yml | 8 +++++ 3 files changed, 67 insertions(+) create mode 100644 .github/actions/install-plasticparcels/action.yml create mode 100644 .github/workflows/unit_tests.yml create mode 100644 environment.yml diff --git a/.github/actions/install-plasticparcels/action.yml b/.github/actions/install-plasticparcels/action.yml new file mode 100644 index 0000000..a82c26f --- /dev/null +++ b/.github/actions/install-plasticparcels/action.yml @@ -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} diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 0000000..1c46b43 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -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: | + run -m pytest -v -s tests diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..8a576ae --- /dev/null +++ b/environment.yml @@ -0,0 +1,8 @@ +name: plasticparcels +channels: + - conda-forge +dependencies: + - parcels>=3.0.2 + + # Testing + - pytest From a413f3b7383bd31c7fcd4d5edc5651dc70d1cdeb Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Thu, 2 May 2024 15:21:40 +0200 Subject: [PATCH 2/3] Fixing run command in unit_tests.yml --- .github/workflows/unit_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 1c46b43..874a78f 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -30,4 +30,4 @@ jobs: environment-name: py3_parcels - name: Unit test run: | - run -m pytest -v -s tests + python -m pytest -v -s tests From 1ce8ac39b8da5806871cc5dbe764ec406faefb61 Mon Sep 17 00:00:00 2001 From: Erik van Sebille Date: Thu, 2 May 2024 15:36:18 +0200 Subject: [PATCH 3/3] Create linting.yml --- .github/workflows/linting.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/linting.yml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..2fefb9d --- /dev/null +++ b/.github/workflows/linting.yml @@ -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