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

Migrate to GitHub Actions #187

Merged
merged 52 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
a7b8ca3
Create main.yml
dnerini Nov 22, 2020
c4b3b53
Add missing -
dnerini Nov 22, 2020
3839645
Update main.yml
dnerini Nov 22, 2020
914a2da
Update main.yml
dnerini Nov 22, 2020
abe55af
Update main.yml
dnerini Nov 22, 2020
72c0cc2
Update main.yml
dnerini Nov 22, 2020
9649719
Update main.yml
dnerini Nov 22, 2020
8fa1a27
Update main.yml
dnerini Nov 22, 2020
0cd4119
Update main.yml
dnerini Nov 22, 2020
44e933e
Remove travis CI file
dnerini Nov 22, 2020
03be46c
Install gcc for macos
dnerini Nov 22, 2020
6a3c95e
Use env context
dnerini Nov 22, 2020
d6fc838
Fix expression
dnerini Nov 22, 2020
e826803
Add missing quotes
dnerini Nov 22, 2020
3a1977e
Use single quotes
dnerini Nov 22, 2020
56605d2
Explicitly export variable
dnerini Nov 22, 2020
6fe733d
Check imports
dnerini Nov 22, 2020
03a1d70
Rename to test
dnerini Nov 22, 2020
ef886e2
Set working dir
dnerini Nov 22, 2020
821b9b8
Export gcc vars before installing pysteps
dnerini Nov 22, 2020
2bf9091
Push @aperezhortal version
dnerini Nov 22, 2020
dc9ac20
Add default shell
dnerini Nov 22, 2020
e0349da
Fix DATA path
aperezhortal Nov 22, 2020
6e94b52
Do not install/use mamba
dnerini Nov 22, 2020
cc00cfa
Do not install pygrib on win
aperezhortal Nov 22, 2020
250016b
Fix compatibility issues in windows paths
aperezhortal Nov 22, 2020
42f2502
Fix bug introduced in test
aperezhortal Nov 22, 2020
5945e4b
Remove old travis' test runner
aperezhortal Nov 22, 2020
a309c79
Make file name self-describing
aperezhortal Nov 22, 2020
f2fceec
Test for py39 too
aperezhortal Nov 22, 2020
69a7e93
Set flexible channel priority
aperezhortal Nov 22, 2020
3a36b33
Test against py38 instead of py39
aperezhortal Nov 23, 2020
b0f2171
Add black check
aperezhortal Nov 23, 2020
8e66cef
fixup! Add black check
aperezhortal Nov 23, 2020
dd3bc2b
Run black on PR
aperezhortal Nov 23, 2020
f6847b7
Run only on pushes to master
aperezhortal Nov 23, 2020
fa90736
Upload to codecov
dnerini Nov 24, 2020
fb8487a
Use Codecov action instead
dnerini Nov 24, 2020
d936641
Specify directory
dnerini Nov 24, 2020
3522cbd
Report to terminal for debugging
dnerini Nov 24, 2020
4cb5c8c
Change working dir for testing
dnerini Nov 24, 2020
a3b0745
Update black.yml
RubenImhoff Nov 24, 2020
30393ff
Update test_datasets.py
RubenImhoff Nov 24, 2020
4382212
Update test_paramsrc.py
RubenImhoff Nov 24, 2020
cc1f631
Debug
dnerini Nov 24, 2020
b395e21
Fix syntax
dnerini Nov 24, 2020
57602fe
Try different strategy to pass path to coverage report
dnerini Nov 24, 2020
ad1cb2b
Back to full matrix
dnerini Nov 24, 2020
c31b482
Add newline at the end of file
aperezhortal Nov 24, 2020
f00352c
Do not hardcode path to coverage report
dnerini Nov 24, 2020
e3e476b
Yet another try with the coverage file ...
dnerini Nov 24, 2020
e9c9078
Upload coverage report with linux only
dnerini Nov 24, 2020
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
39 changes: 39 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will test the code base using the LATEST version of black

# IMPORTANT: Black is under development. Hence, minor fommatting changes between
# different version are expected.
# If this test fails, install the latest version of black and then run black.
# Preferably, run black only on the files that you have modified.
# This will faciliate the revision of the proposed changes.

name: Black

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black

- name: Black version
run: black --version

- name: Black check
working-directory: ${{github.workspace}}
run: black --check .
108 changes: 108 additions & 0 deletions .github/workflows/test_pysteps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Test Pysteps installation

env:
MINIMAL_DEPENDENCIES: cython numpy jsmin jsonschema matplotlib netCDF4 opencv pillow pyproj scipy dask
OPTIONAL_DEPENDENCIES: dask pyfftw cartopy h5py PyWavelets
TEST_DEPENDENCIES: pytest pytest-cov codecov

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
unit_tests:
name: Unit Tests (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
python-version: [ "3.6", "3.8" ]
max-parallel: 6

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

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2.0.0
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge
channel-priority: flexible
activate-environment: test-environment

- name: Install dependencies
env:
PACKAGES: ${{env.MINIMAL_DEPENDENCIES}} ${{env.OPTIONAL_DEPENDENCIES}} ${{env.TEST_DEPENDENCIES}}
PYSTEPS_DATA_PATH: ${{github.workspace}}/pysteps_data
run: |
conda install --quiet ${{env.PACKAGES}}

- name: Install pysteps for MacOS
if: matrix.os == 'macos-latest'
working-directory: ${{github.workspace}}
env:
CC: gcc-9
CXX: g++-9
CXX1X: g++-9
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew update-reset
brew update
brew install gcc@9
gcc-9 --version
pip install .

- name: Install pygrib (not win)
if: matrix.os != 'windows-latest'
run: conda install --quiet pygrib

- name: Install pysteps
if: matrix.os != 'macos-latest'
working-directory: ${{github.workspace}}
run: pip install .

- name: Download pysteps data
env:
PYSTEPS_DATA_PATH: ${{github.workspace}}/pysteps_data
working-directory: ${{github.workspace}}/ci
run: python fetch_pysteps_data.py

- name: Check imports
working-directory: ${{github.workspace}}/pysteps_data
run: |
python -c "import pysteps; print(pysteps.__file__)"
python -c "from pysteps import motion"
python -c "from pysteps.motion import vet"
python -c "from pysteps.motion import proesmans"

- name: Run tests and coverage report
working-directory: ${{github.workspace}}/pysteps_data
env:
PYSTEPSRC: ${{github.workspace}}/pysteps_data/pystepsrc
run: pytest --pyargs pysteps --cov=pysteps --cov-report=xml --cov-report=term -ra

- name: Upload coverage to Codecov (Linux only)
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v1
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
with:
file: ${{github.workspace}}/pysteps_data/coverage.xml
flags: unit_tests
env_vars: OS,PYTHON
fail_ci_if_error: true
verbose: true
142 changes: 0 additions & 142 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions ci/fetch_pysteps_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
Script used to install the pysteps data in a test environment and set a pystepsrc
configuration file that points to that data.

The test data is downloaded in the `PYSTEPS_DATA_DIR` environmental variable.
The test data is downloaded in the `PYSTEPS_DATA_PATH` environmental variable.

After this script is run, the `PYSTEPSRC` environmental variable should be set to
PYSTEPSRC=$PYSTEPS_DATA_DIR/pystepsrc for pysteps to use that configuration file.
PYSTEPSRC=$PYSTEPS_DATA_PATH/pystepsrc for pysteps to use that configuration file.
"""

import os

from pysteps.datasets import create_default_pystepsrc, download_pysteps_data

tox_test_data_dir = os.environ["PYSTEPS_DATA_DIR"]
tox_test_data_dir = os.environ["PYSTEPS_DATA_PATH"]

download_pysteps_data(tox_test_data_dir, force=True)

Expand Down
19 changes: 0 additions & 19 deletions ci/run_tests.sh

This file was deleted.

7 changes: 4 additions & 3 deletions pysteps/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ def download_pysteps_data(dir_path, force=True):
pbar = ShowProgress()
print("Downloading pysteps-data from github.")
tmp_file_name, _ = request.urlretrieve(
"https://github.com/pySTEPS/pysteps-data/archive/master.zip", reporthook=pbar,
"https://github.com/pySTEPS/pysteps-data/archive/master.zip",
reporthook=pbar,
)
pbar.end(message="Download complete\n")

Expand Down Expand Up @@ -354,7 +355,7 @@ def create_default_pystepsrc(
pystepsrc, pystepsrc.1, pystepsrc.2, etc. exist, they are renamed to respectively
pystepsrc.1, pystepsrc.2, pystepsrc.2, etc. Finally, after the existing files are
backed up, the new configuration file is written.

Parameters
----------

Expand Down Expand Up @@ -414,7 +415,7 @@ def create_default_pystepsrc(
with open(dest_path, "w") as f:
json.dump(rcparams_json, f, indent=4)

return dest_path
return os.path.normpath(dest_path)


def load_dataset(case="fmi", frames=14):
Expand Down
7 changes: 6 additions & 1 deletion pysteps/tests/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ def _default_path():

@pytest.mark.parametrize("config_dir, file_name, expected_path", test_params_paths)
def test_params_file_creation_path(config_dir, file_name, expected_path):
"""Test that the default pysteps parameters file is create in the right place."""
"""Test that the default pysteps parameters file is created in the right place."""

# For windows compatibility
if config_dir is not None:
config_dir = os.path.normpath(config_dir)
expected_path = os.path.normpath(expected_path)

pysteps_data_dir = "dummy/path/to/data"
params_file_path = create_default_pystepsrc(
Expand Down
Loading