Skip to content

Commit

Permalink
Merge pull request #183 from MetOffice/develop
Browse files Browse the repository at this point in the history
Update master for V1
  • Loading branch information
zmaalick authored Mar 12, 2021
2 parents df56b8f + 7f48d13 commit 721b47a
Show file tree
Hide file tree
Showing 35 changed files with 22,272 additions and 612 deletions.
6 changes: 4 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@ ignore = E123, E133, E226, W503, F405, E721, E402, F403, F401
max-line-length = 88
extend-ignore = E203


count = True
max-doc-length = 79
max-doc-length = 88
statistics = True
doctests = True
include_in_doctest =
lib/catnip/preparation.py,
lib/catnip/analysis.py,
lib/catnip/utils.py

exclude =
exclude =
# ignore the following directories/files
docs,
docsrc,
Expand All @@ -52,3 +53,4 @@ exclude =
*.pyc,
runAll.py,
testconf.py
setup.py
42 changes: 42 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
env: [current, next]
steps:
- uses: actions/checkout@v2
- name: update conda env
shell: bash
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda install -c conda-forge mamba
mamba env update -q --file envs/default-${{ matrix.env }}.yml --name default-${{ matrix.env }}
- name: conda info
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate default-${{ matrix.env }}
conda info
conda list
- name: pytest
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate default-${{ matrix.env }}
cd lib
pytest -p no:warnings -v
- name: flake8
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate default-${{ matrix.env }}
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exit-zero --max-complexity=10 --max-line-length=127
- name: Sphinx
run: |
source '/usr/share/miniconda/etc/profile.d/conda.sh'
conda activate default-${{ matrix.env }}
cd docsrc
make github
65 changes: 60 additions & 5 deletions bin/run_all_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export LC_CTYPE=en_GB.utf8

FILES_TO_TEST=$(find $CATNIP_LIB_DIR -type f -name '*.py')


function check_flake8 {
echo -e "\033[1;32mRunning flake8 tests ...\033[0m"
flake8
Expand All @@ -22,21 +21,77 @@ function check_flake8 {
function check_black {
echo -e "\033[1;32mRunning black tests ...\033[0m"
module unload scitools
module load scitools/experimental-current
black $FILES_TO_TEST
#module load scitools/experimental-current
module load scitools/default-next
black $FILES_TO_TEST

}

function check_documentation {
echo -e "\033[1;32mChecking documentation ...\033[0m"
echo "TODO"
# Build documentation as test.
cd $CATNIP_ROOT_DIR/docsrc
make github
}

function check_license {
echo -e "\033[1;32mChecking for license ...\033[0m"
echo "TODO"
# Iterate through files to check whether they contain the expected
# licence information. If any files do not contain the expected licence
# information, then this test will fail.
read -d '' expected <<'__TEXT__' || true
# -*- coding: utf-8 -*-
# -----------------------------------------------------------------------------
# (C) British Crown Copyright 2017-2020 Met Office.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
__TEXT__


echo $FILES_TO_TEST
count=0
for FILE in $FILES_TO_TEST; do
# Check whether file has a size greater than zero.
echo 'Checking: ' $FILE
if [[ -s $FILE ]]; then
file_contents=$(<$FILE)
if [[ "$file_contents" != *"$expected"* ]]; then
echo 'Licence information is not found in ' $FILE
count=$((count+1))
fi
fi
done
if (( $count > 0 )); then
return 1
fi
}


function check_pytest {
echo -e "\033[1;32mRunning pytest ...\033[0m"
cd $CATNIP_LIB_DIR
Expand Down
8 changes: 4 additions & 4 deletions docs/_sources/tools.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ analysis module
.. toctree::
:maxdepth: 2

.. automodule:: catnip.analysis
.. automodule:: analysis
:members:

preparation module
Expand All @@ -13,7 +13,7 @@ preparation module
.. toctree::
:maxdepth: 2

.. automodule:: catnip.preparation
.. automodule:: preparation
:members:


Expand All @@ -23,7 +23,7 @@ visualisation module
.. toctree::
:maxdepth: 2

.. automodule:: catnip.visualisation
.. automodule:: visualisation
:members:

.. image:: images/regress_ci.png
Expand All @@ -38,5 +38,5 @@ utils module
.. toctree::
:maxdepth: 2

.. automodule:: catnip.utils
.. automodule:: utils
:members:
Loading

0 comments on commit 721b47a

Please sign in to comment.