forked from E3SM-Project/gdess
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (114 loc) · 4.79 KB
/
lint_and_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# This workflow will install Python dependencies using conda, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Tests
on:
# push:
# branches:
# - main
pull_request:
branches:
- test
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
test1:
name: Test1 (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
python-version: [3.8, 3.9]
env:
GDESS_REPO: ${{ github.workspace }}
GDESS_CMIP_DATA: ${{ github.workspace }}/tests/test_data/cmip/
GDESS_GLOBALVIEW_DATA: ${{ github.workspace }}/tests/test_data/globalview/
GDESS_SAVEPATH: ${{ github.workspace }}/outputs/
steps:
- name: Checkout source
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
lfs: true
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}
- name: Checkout LFS objects
run: git lfs checkout
- name: Cache conda
uses: actions/cache@v1
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-python${{ matrix.python-version }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
- name: Setup conda dependencies
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: ci/environment.yml
activate-environment: testing
auto-activate-base: false
# - name: Add conda to system path
# run: |
# # $CONDA is an environment variable pointing to the root of the miniconda directory
# echo $CONDA/bin >> $GITHUB_PATH
# - name: Install dependencies
# run: |
# conda env update --file ci/environment.yml --name base
- name: Conda info
shell: bash -l {0}
run: |
conda info
conda list
- name: Lint with flake8
shell: bash -l {0}
run: |
conda info
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install package
shell: bash -l {0}
run: |
pip install -e .
# Enable tmate debugging of manually-triggered workflows if the input option was provided
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
- name: Test and generate coverage report
shell: bash -l {0}
run: |
conda install pytest
conda install pytest-cov
pytest --cov=./ --cov-report=xml
- name: Send coverage report to codecov
uses: codecov/codecov-action@v1
with:
env_vars: OS,PYTHON
fail_ci_if_error: false
verbose: true # optional (default = false)
- name: Update demo notebooks
if: (matrix.os == 'ubuntu-latest') && (matrix.python-version == '3.9')
shell: bash -l {0}
run: |
python -m pip install jupyter nbconvert nbformat
for i in notebooks/templates/*recipe_template.ipynb; do filename=${i##*/}; python -m nbconvert --to notebook --ExecutePreprocessor.kernel_name=python3 --execute $i --output-dir notebooks/demo --output ${filename%_template.ipynb}.ipynb; done;
- name: Commit updated notebooks
if: (matrix.os == 'ubuntu-latest') && (matrix.python-version == '3.9')
uses: EndBug/add-and-commit@v9
with:
author_name: Plot update bot
message: "Update Notebooks"
add: "['notebooks/demo/meridional_recipe.ipynb', 'notebooks/demo/seasonal_cycle_recipe.ipynb', 'notebooks/demo/trends_recipe.ipynb']"