Skip to content

Commit

Permalink
Replace TravisCI tests with GitHub Actions (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored Nov 18, 2020
1 parent 9d6ade5 commit bae64f7
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 152 deletions.
25 changes: 0 additions & 25 deletions .appveyor.yml

This file was deleted.

109 changes: 109 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: tests
on:
push:
branches:
- master
pull_request:
branches:
- '*'

jobs:
test_suite:
name: Pytest on ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
python-version: [2.7, 3.6, 3.7]
exclude:
- os: windows-latest
python-version: 2.7
timeout-minutes: 30
defaults:
run:
shell: bash -l {0}
env:
DESC: "Python ${{ matrix.python-version }} tests"
HV_REQUIREMENTS: "unit_tests"
PYTHON_VERSION: ${{ matrix.python-version }}
CHANS_DEV: "-c pyviz/label/dev"
CHANS: "-c pyviz"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: "100"
- uses: actions/setup-python@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
- name: Fetch unshallow
run: git fetch --prune --tags --unshallow
- name: conda setup
run: |
conda config --set always_yes True
conda install -c pyviz "pyctdev>=0.5"
doit ecosystem_setup
conda install nodejs
doit env_create ${{ env.CHANS_DEV}} --python=${{ matrix.python-version }}
- name: doit develop_install py2
if: startsWith(matrix.python-version, 2.)
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
conda list
doit develop_install -c pyviz/label/dev -o tests
- name: doit develop_install py3
if: startsWith(matrix.python-version, 3.)
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
conda list
doit develop_install ${{ env.CHANS_DEV}} -o examples -o tests
- name: pygraphviz
if: contains(matrix.os, 'ubuntu')
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
conda install -c conda-forge pygraphviz
- name: doit env_capture
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
doit env_capture
- name: doit test_flakes
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
doit test_flakes
- name: doit test_unit
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
doit test_unit
- name: test examples ubuntu
if: contains(matrix.os, 'ubuntu') && startsWith(matrix.python-version, 3.)
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
bokeh sampledata
doit test_examples_extra
- name: test examples windows
if: contains(matrix.os, 'windows')
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
bokeh sampledata
doit test_examples
- name: codecov
env:
github-token: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(matrix.python-version, 3.)
run: |
eval "$(conda shell.bash hook)"
conda activate test-environment
coveralls
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ env:
- PYTHON_VERSION=3.6

stages:
- test
- name: test
if: tag =~ ^v(\d+|\.)+([a-z]|rc)?\d?$
- name: docs
if: tag =~ ^v(\d+|\.)*[^a-z]\d*$ OR tag = website
- name: docs_dev
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include hvplot/.version
include README.rst
include LICENSE
include hvplot/.version
graft examples
global-exclude *.py[co]
global-exclude *~
Expand Down
4 changes: 2 additions & 2 deletions examples/user_guide/NetworkX.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@
"G.add_edge('c', 'f', weight=0.9)\n",
"G.add_edge('a', 'd', weight=0.3)\n",
"\n",
"elarge = [(u, v) for (u, v, d) in G.edges(data=True) if d['weight'] > 0.5]\n",
"esmall = [(u, v) for (u, v, d) in G.edges(data=True) if d['weight'] <= 0.5]\n",
"elarge = [(u, v) for (u, v, attr) in G.edges(data=True) if attr['weight'] > 0.5]\n",
"esmall = [(u, v) for (u, v, attr) in G.edges(data=True) if attr['weight'] <= 0.5]\n",
"\n",
"pos = nx.spring_layout(G) # positions for all nodes\n",
"\n",
Expand Down
5 changes: 4 additions & 1 deletion hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,10 @@ def method_wrapper(ds, x, y):
name = data.name or self.label or self.value_label
dataset = Dataset(data, self.indexes, name)
else:
dataset = Dataset(data, self.indexes)
try:
dataset = Dataset(data, self.indexes)
except Exception:
dataset = Dataset(data)
dataset = dataset.redim(**self._redim)
obj = method(x, y)
obj._dataset = dataset
Expand Down
2 changes: 2 additions & 0 deletions hvplot/intake.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import absolute_import

from distutils.version import LooseVersion

from . import hvPlot, post_patch
Expand Down
13 changes: 7 additions & 6 deletions hvplot/tests/testcharts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


class TestChart2D(ComparisonTestCase):

def setUp(self):
try:
import numpy as np
Expand Down Expand Up @@ -76,7 +77,7 @@ def test_heatmap_2d_derived_x_and_y(self):
class TestChart2DDask(TestChart2D):

def setUp(self):
super().setUp()
super(TestChart2DDask, self).setUp()
try:
import dask.dataframe as dd
except:
Expand Down Expand Up @@ -250,27 +251,27 @@ def test_time_df_sorts_on_plot(self):
scrambled = self.time_df.sample(frac=1)
plot = scrambled.hvplot(x='time')
assert (plot.data == self.time_df).all().all()
assert (plot.data.time.diff()[1:].astype('int') > 0).all()
assert len(plot.data.time.unique()) == len(plot.data.time)

def test_time_df_does_not_sort_on_plot_if_sort_date_off(self):
scrambled = self.time_df.sample(frac=1)
plot = scrambled.hvplot(x='time', sort_date=False)
assert (plot.data == scrambled).all().all()
assert not (plot.data.time.diff()[1:].astype('int') > 0).all()
assert len(plot.data.time.unique()) == len(plot.data.time)

def test_time_df_sorts_on_plot_using_index_as_x(self):
df = self.time_df.set_index('time')
scrambled = df.sample(frac=1)
plot = scrambled.hvplot()
assert (plot.data['time'] == df.index).all()
assert (plot.data.time.diff()[1:].astype('int') > 0).all()
assert len(plot.data.time.unique()) == len(plot.data.time)

def test_time_df_does_not_sort_on_plot_if_sort_date_off_using_index_as_x(self):
df = self.time_df.set_index('time')
scrambled = df.sample(frac=1)
plot = scrambled.hvplot(sort_date=False)
assert (plot.data.time == scrambled.index).all().all()
assert not (plot.data.time.diff()[1:].astype('int') > 0).all()
assert len(plot.data.time.unique()) == len(plot.data.time)

def test_time_df_with_groupby_as_derived_datetime(self):
plot = self.time_df.hvplot(groupby='time.dayofweek', dynamic=False)
Expand Down Expand Up @@ -306,7 +307,7 @@ def test_default_y_not_in_by(self):
class TestChart1DDask(TestChart1D):

def setUp(self):
super().setUp()
super(TestChart1DDask, self).setUp()
try:
import dask.dataframe as dd
except:
Expand Down
25 changes: 20 additions & 5 deletions hvplot/tests/testgeo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sys

from unittest import TestCase, SkipTest, expectedFailure

import numpy as np
Expand All @@ -8,6 +10,8 @@
class TestGeo(TestCase):

def setUp(self):
if sys.platform == "win32":
raise SkipTest("Skip geo tests on windows for now")
try:
import xarray as xr
import rasterio # noqa
Expand All @@ -29,10 +33,14 @@ def assert_projection(self, plot, proj):
opts = hv.Store.lookup_options('bokeh', plot, 'plot')
assert opts.kwargs['projection'].proj4_params['proj'] == proj

def test_plot_with_crs_as_object(self):
plot = self.da.hvplot.image('x', 'y', crs=self.crs)
self.assertCRS(plot)

class TestCRSInference(TestGeo):

def setUp(self):
if sys.platform == "win32":
raise SkipTest("Skip CRS inference on Windows")
super(TestCRSInference, self).setUp()

def test_plot_with_crs_as_proj_string(self):
plot = self.da.hvplot.image('x', 'y', crs=self.da.crs)
self.assertCRS(plot)
Expand All @@ -41,6 +49,13 @@ def test_plot_with_geo_as_true_crs_undefined(self):
plot = self.da.hvplot.image('x', 'y', geo=True)
self.assertCRS(plot)


class TestProjections(TestGeo):

def test_plot_with_crs_as_object(self):
plot = self.da.hvplot.image('x', 'y', crs=self.crs)
self.assertCRS(plot)

def test_plot_with_crs_as_attr_str(self):
da = self.da.copy()
da.attrs = {'bar': self.crs}
Expand All @@ -59,12 +74,12 @@ def test_plot_with_geo_as_true_crs_no_crs_on_data_returns_default(self):

def test_plot_with_projection_as_string(self):
da = self.da.copy()
plot = da.hvplot.image('x', 'y', projection='Robinson')
plot = da.hvplot.image('x', 'y', crs=self.crs, projection='Robinson')
self.assert_projection(plot, 'robin')

def test_plot_with_projection_as_string_google_mercator(self):
da = self.da.copy()
plot = da.hvplot.image('x', 'y', projection='GOOGLE_MERCATOR')
plot = da.hvplot.image('x', 'y', crs=self.crs, projection='GOOGLE_MERCATOR')
self.assert_projection(plot, 'merc')

def test_plot_with_projection_as_invalid_string(self):
Expand Down
2 changes: 1 addition & 1 deletion hvplot/tests/testnetworkx.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class TestOptions(TestCase):
def setUp(self):
# Create nodes (1-10) in unsorted order
nodes = np.array([1, 4, 5, 10, 8, 9, 3, 7, 2, 6])
edges = [*zip(nodes[:-1], nodes[1:])]
edges = list(zip(nodes[:-1], nodes[1:]))

g = nx.Graph()
g.add_nodes_from(nodes)
Expand Down
9 changes: 3 additions & 6 deletions hvplot/tests/testtransforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def test_pandas_transform(self):
class TestXArrayTransforms(ComparisonTestCase):

def setUp(self):

try:
import xarray as xr
import xarray as xr # noqa
except:
raise SkipTest('xarray not available')
import hvplot.xarray # noqa

def test_xarray_transform(self):
import xarray as xr
data = np.arange(0, 60).reshape(6, 10)
Expand All @@ -42,6 +42,3 @@ def test_xarray_transform(self):
transforms=dict(value=hv.dim('value')*10)
)
self.assertEqual(img.data.value.data, da.data*10)



4 changes: 4 additions & 0 deletions hvplot/tests/testutil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Tests utilities to convert data and projections
"""
import sys

import numpy as np

from unittest import TestCase, SkipTest
Expand Down Expand Up @@ -195,6 +197,8 @@ def test_process_xarray_dataset_with_x_as_derived_datetime(self):
class TestGeoUtil(TestCase):

def setUp(self):
if sys.platform == "win32":
raise SkipTest("Skip geo tests on windows for now")
try:
import geoviews # noqa
import cartopy.crs as ccrs
Expand Down
Loading

0 comments on commit bae64f7

Please sign in to comment.