Skip to content

Commit 779bed1

Browse files
authored
Merge pull request #52 from MDAnalysis/travis2ghactions
replace Travis CI with GitHub actions
2 parents 4cb391f + 4572c0c commit 779bed1

9 files changed

Lines changed: 178 additions & 54 deletions

File tree

.github/workflows/docs.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: docs deployment
2+
on:
3+
push:
4+
branches:
5+
- master
6+
7+
concurrency:
8+
group: "${{ github.ref }}-${{ github.head_ref }}"
9+
cancel-in-progress: true
10+
11+
jobs:
12+
docs:
13+
if: github.repository == 'MDAnalysis/MDAnalysisData'
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
19+
- name: Setup python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: 3.9
23+
24+
- name: Display Python version
25+
run: python -c "import sys; print(sys.version)"
26+
27+
- name: Install sphinx, pytest, pytest plugins
28+
run: |
29+
python -m pip install wheel
30+
python -m pip install pytest pytest-cov pytest-pep8 pytest-mock codecov
31+
python -m pip install sphinx sphinx-sitemap sphinx-rtd-theme
32+
33+
- name: Install main dependencies
34+
run: |
35+
python -m pip install six setuptools tqdm
36+
37+
- name: install package
38+
run: |
39+
pip install -v .
40+
41+
- name: build docs
42+
run: |
43+
python setup.py build_sphinx
44+
45+
- name: deploy docs
46+
uses: peaceiris/actions-gh-pages@v3
47+
with:
48+
github_token: ${{ secrets.GITHUB_TOKEN }}
49+
publish_dir: ./build/sphinx/html
50+
user_name: 'github-actions'
51+
user_email: 'github-action@users.noreply.github.com'

.github/workflows/gh-ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: GH Actions CI
2+
3+
on:
4+
# run every Sunday at 3:53 UTC
5+
schedule:
6+
- cron: "53 3 * * 0"
7+
push:
8+
branches:
9+
- "master"
10+
pull_request:
11+
branches:
12+
- "master"
13+
14+
concurrency:
15+
group: "${{ github.ref }}-${{ github.head_ref }}"
16+
cancel-in-progress: true
17+
18+
jobs:
19+
unittests:
20+
name: Test ${{ matrix.os }} with Python ${{ matrix.python-version }}
21+
if: github.repository == 'MDAnalysis/MDAnalysisData'
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
os: [ubuntu-latest]
27+
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
28+
include:
29+
- os: macOS-latest
30+
python-version: 2.7
31+
- os: macOS-latest
32+
python-version: 3.9
33+
- os: windows-latest
34+
python-version: 2.7
35+
- os: windows-latest
36+
python-version: 3.9
37+
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- name: Setup python
42+
uses: actions/setup-python@v2
43+
with:
44+
python-version: ${{ matrix.python-version }}
45+
46+
- name: Display Python version
47+
run: python -c "import sys; print(sys.version)"
48+
49+
- name: Install testing dependencies (pytest, pytest plugins)
50+
run: |
51+
python -m pip install wheel
52+
python -m pip install pytest pytest-cov pytest-pep8 pytest-mock codecov
53+
54+
- name: Install package dependencies
55+
run: |
56+
python -m pip install six setuptools tqdm
57+
58+
- name: Install compatibility dependencies for Python 2.7 only
59+
if: startsWith(matrix.python-version, '2.7')
60+
run: python -m pip install pathlib2
61+
62+
- name: Install package
63+
run: |
64+
python -m pip install -e .
65+
66+
- name: Run tests
67+
run: |
68+
pytest -v --cov=MDAnalysisData --cov-report=xml --color=yes MDAnalysisData/tests
69+
70+
- name: Codecov
71+
uses: codecov/codecov-action@v2
72+
with:
73+
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
74+
file: ./coverage.xml
75+
fail_ci_if_error: True
76+
verbose: True

.travis.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
### Changes
1414
- update online docs theme (#43)
15+
- tested for Python 2.7, 3.6 - 3.9 on Linux, macOS, Windows (#48)
1516

1617
## [0.8.0] - 2019-08-13
1718

MDAnalysisData/tests/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# tests/__init__.py so that pytest-cov collects data
2+
# otherwise "CoverageWarning: No data was collected. (no-data-collected)"
3+
# see https://stackoverflow.com/a/60579142

MDAnalysisData/tests/test_base.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
from six.moves.urllib.request import urlretrieve
66

7+
try:
8+
import pathlib
9+
except ImportError:
10+
# Python 2.7
11+
import pathlib2 as pathlib
12+
713
import os
814
import os.path
915

@@ -48,23 +54,32 @@ def test_dir(self, bunch):
4854

4955
def test_read_description():
5056
descr = base._read_description("adk_equilibrium.rst")
51-
assert len(descr) == 1252
52-
assert descr.startswith(".. -*- coding: utf-8 -*-\n\n.. _`adk-equilibrium-dataset`:")
57+
assert (descr.startswith( # UNIX
58+
".. -*- coding: utf-8 -*-\n\n.. _`adk-equilibrium-dataset`:") or
59+
descr.startswith( # Windows
60+
".. -*- coding: utf-8 -*-\r\n\r\n.. _`adk-equilibrium-dataset`:"))
61+
# descr is read with automatic line ending conversion so by splitting into
62+
# words we don't need to care about that (len(descr) differs between UNIX
63+
# and Windows)
64+
n_words = len(descr.split())
65+
assert n_words == 153
5366

5467
def test_sha256(tmpdir, some_text):
5568
filename = "address.txt"
5669
with tmpdir.as_cwd():
57-
with open(filename, "w") as txt:
58-
txt.write(some_text)
70+
with open(filename, "wb") as txt:
71+
txt.write(some_text.encode("utf-8"))
5972
checksum = base._sha256(filename)
6073
assert checksum == "4446bfb2ec5dedfbd981d059d6005f5144b067b392a00e3bcf98f8302ec8f765"
6174

6275
@pytest.mark.parametrize('data_home,location', [
63-
(None, os.path.expanduser("~/MDAnalysis_data")),
64-
("/tmp/MDAnalysisData", "/tmp/MDAnalysisData"),
76+
(None,
77+
pathlib.Path("~/MDAnalysis_data").expanduser()),
78+
(str(pathlib.Path("/tmp/MDAnalysisData")),
79+
pathlib.Path("/tmp/MDAnalysisData")),
6580
])
6681
def test_get_data_home(data_home, location):
67-
assert base.get_data_home(data_home=data_home) == location
82+
assert base.get_data_home(data_home=data_home) == str(location)
6883

6984
def test_clear_data_home(tmpdir, some_text):
7085
data_home_path = tmpdir.join("MDAnalysis_data_test")

MDAnalysisData/tests/test_package_metadata.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# -*- coding: utf-8 -*-
22

33
import sys
4+
import six
45
from six.moves import reload_module
56
import pytest
67

@@ -28,4 +29,4 @@ def test_default_authors(monkeypatch):
2829
def test_version():
2930
# very generic because versioneer will provide different strings depending
3031
# on the repository status
31-
assert isinstance(MDAnalysisData.__version__, str)
32+
assert isinstance(MDAnalysisData.__version__, six.string_types)

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MDAnalysisData
22

3-
[![Build Status](https://travis-ci.com/MDAnalysis/MDAnalysisData.svg?branch=master)](https://travis-ci.com/MDAnalysis/MDAnalysisData)
3+
[![Build Status](https://github.com/MDAnalysis/MDAnalysisData/actions/workflows/gh-ci.yaml/badge.svg)](https://github.com/MDAnalysis/GridDataFormats/actions/workflows/ci.yaml)
44
[![codecov](https://codecov.io/gh/MDAnalysis/MDAnalysisData/branch/master/graph/badge.svg)](https://codecov.io/gh/MDAnalysis/MDAnalysisData)
55
[![docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://www.mdanalysis.org/MDAnalysisData/)
66
[![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
@@ -72,6 +72,20 @@ The data directory can we wiped with the function
7272
MDAnalysisData.base.clear_data_home()
7373
```
7474

75+
## Contributing new datasets
76+
77+
Please add new datasets to MDAnalysisData. See [Contributing new
78+
datasets](https://www.mdanalysis.org/MDAnalysisData/contributing.html)
79+
for details, but in short:
80+
81+
1. raise an issue in the [issue
82+
tracker](https://github.com/MDAnalysis/MDAnalysisData/issues) describing
83+
what you want to add; this issue will become the focal point for discussions
84+
where the developers can easily give advice
85+
2. deposit data in an archive under an [Open
86+
Data](https://opendatacommons.org/) compatible license (CC0 or
87+
CC-BY preferred)
88+
3. write accessor code in MDAnalysisData
7589

7690

7791
## Credits

setup.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import versioneer
2121

2222
import os
23+
import sys
2324
import warnings
2425
import codecs
2526

@@ -119,17 +120,21 @@ def dynamic_author_list():
119120
'Programming Language :: Python :: 2',
120121
'Programming Language :: Python :: 2.7',
121122
'Programming Language :: Python :: 3',
122-
'Programming Language :: Python :: 3.4',
123-
'Programming Language :: Python :: 3.5',
124123
'Programming Language :: Python :: 3.6',
125124
'Programming Language :: Python :: 3.7',
126125
'Programming Language :: Python :: 3.8',
126+
'Programming Language :: Python :: 3.9',
127127
'Topic :: Scientific/Engineering',
128128
'Topic :: Scientific/Engineering :: Bio-Informatics',
129129
'Topic :: Scientific/Engineering :: Chemistry',
130130
'Topic :: Software Development :: Libraries :: Python Modules',
131131
]
132132

133+
# Python 2.7 compatibility
134+
test_requirements = ['pytest', 'pytest-mock']
135+
if sys.version_info.major < 3:
136+
test_requirements.append("pathlib2")
137+
133138
setup(name='MDAnalysisData',
134139
version=versioneer.get_version(),
135140
cmdclass=versioneer.get_cmdclass(),
@@ -156,6 +161,6 @@ def dynamic_author_list():
156161
'setuptools',
157162
'tqdm',
158163
],
159-
tests_require=['pytest', 'pytest-mock'],
164+
tests_require=test_requirements,
160165
zip_safe=True,
161166
)

0 commit comments

Comments
 (0)