Skip to content

Commit

Permalink
Add GitHub actions for testing (#108)
Browse files Browse the repository at this point in the history
Replaces TravisCI and restores working CI.
  • Loading branch information
joaomcteixeira authored Jun 18, 2022
1 parent 0312bc4 commit a781b46
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 65 deletions.
24 changes: 0 additions & 24 deletions .appveyor.yml

This file was deleted.

3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ exclude_lines =
if __name__ == .__main__.:
ignore_errors = True
omit =
tests/*
tests/*
docs/*
156 changes: 156 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: build

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
lint:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest]
python-version: [3.9]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
shell: bash

- name: Linter
run: |
python -m pip install flake8
flake8 .
build_and_test_linux:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel bump2version twine
shell: bash

- name: Linter
run: |
python -m pip install flake8
flake8 .
- name: Build
run: |
python --version
python setup.py sdist bdist_wheel
twine check dist/*.whl
twine check dist/*.tar.gz
bump2version --dry-run --verbose --allow-dirty patch
bump2version --dry-run --verbose --allow-dirty minor
bump2version --dry-run --verbose --allow-dirty major
- name: Test
run: |
python -m pip install .
script -q -e -c "python setup.py test"
test_macos:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
brew install expect
shell: bash

- name: Test Linux/MacOS
run: |
python -m pip install .
unbuffer python setup.py test
# test_windows:
# runs-on: ${{ matrix.platform }}
# strategy:
# matrix:
# platform: [windows-latest]
# python-version: [3.6, 3.7, 3.8, 3.9]

# steps:
# - uses: actions/checkout@v2

# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v2
# with:
# python-version: ${{ matrix.python-version }}

# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip setuptools wheel

# - name: Test Windows
# run: |
# python -m pip install .
# Invoke-Expression 'python setup.py test'

coverage:
runs-on: ${{ matrix.platform }}
strategy:
matrix:
platform: [ubuntu-latest]
python-version: [3.9]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install coverage
- name: Get Coverage
run: |
python -m pip install .
script -q -e -c "coverage run setup.py test"
# from https://about.codecov.io/blog/
# python-code-coverage-using-github-actions-and-codecov/
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
verbose: true
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# pdb-tools

[![PyPI version](https://badge.fury.io/py/pdb-tools.svg)](https://badge.fury.io/py/pdb-tools)
[![Travis (.org) branch](https://img.shields.io/travis/haddocking/pdb-tools/master.svg?style=flat&label=TravisCI)](https://travis-ci.org/haddocking/pdb-tools)
[![AppVeyor branch](https://img.shields.io/appveyor/ci/JoaoRodrigues/pdb-tools-2coq6.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/JoaoRodrigues/pdb-tools-2coq6)
[![tests](https://github.com/haddocking/pdb-tools/workflows/tests/badge.svg?branch=master)](https://github.com/haddocking/pdb-tools/actions?workflow=tests)
[![codecov](https://codecov.io/gh/haddocking/pdb-tools/branch/master/graph/badge.svg)](https://codecov.io/gh/haddocking/pdb-tools)
[![DOI](https://zenodo.org/badge/27217350.svg)](https://doi.org/10.12688/f1000research.17456.1)

Expand Down
2 changes: 1 addition & 1 deletion pdbtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@
'pdb_uniqname',
'pdb_validate',
'pdb_wc',
]
]
15 changes: 7 additions & 8 deletions pdbtools/pdb_selaltloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
data to another. They are based on old FORTRAN77 code that was taking too much
effort to maintain and compile. RIP.
"""
import operator
import os
import sys

Expand Down Expand Up @@ -250,8 +249,8 @@ def is_another_altloc_group(
resname,
prev_resname,
altloc_lines,
rploc,
):
rploc
):
"""Detect if current line belongs to a new altloc group."""
a0 = prev_altloc
a1 = altloc
Expand All @@ -264,7 +263,7 @@ def is_another_altloc_group(

is_another = (
all((a0, ra0, ru0)) and (
(a0 != a1 and a1 == ' ' and ru1 > ru0)
(a0 != a1 and a1 == ' ' and ru1 > ru0)
or (a0 == ' ' and a1 != ' ' and ru1 > ru0)
or (a0 == ' ' and a1 == ' ' and (ru1 != ru0 or ra1 != ra0))
or (
Expand All @@ -274,9 +273,9 @@ def is_another_altloc_group(
and ru1 > ru0
and len(rl) > 1
and all(len(v) == len(rv[0]) for v in rv[1:])
)
)
)
)

return is_another

Expand Down Expand Up @@ -348,8 +347,8 @@ def flush_resloc_occ_same_residue(altloc_lines, **kw):
for atom, linest in sorted_atoms:
lines = linest[1]

atom_lines = [l for l in lines if l.startswith(("ATOM", "HETATM"))]
anisou_lines = [l for l in lines if l.startswith(("ANISOU"))]
atom_lines = [ln for ln in lines if ln.startswith(("ATOM", "HETATM"))]
anisou_lines = [ln for ln in lines if ln.startswith(("ANISOU"))]

if anisou_lines:
new = []
Expand All @@ -359,7 +358,7 @@ def flush_resloc_occ_same_residue(altloc_lines, **kw):
"There is an error with this PDB. "
"We expect one ANISOU line per ATOM/HETATM lines. "
"But the number of ATOM/HETATM and ANISOU lines differ."
)
)
raise ValueError(emsg)

for _a, _b in zip(atom_lines, anisou_lines):
Expand Down
1 change: 0 additions & 1 deletion pdbtools/pdb_tidy.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ def make_TER(prev_line):
in_model = True
serial_offset = 0


if serial > 99999:
emsg = 'ERROR!! Structure contains more than 99.999 atoms.\n'
sys.stderr.write(emsg)
Expand Down
11 changes: 5 additions & 6 deletions tox.ini → setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ exclude =
tests/,
setup.py

# Ignore long lines and lambda warnings
ignore = E501,E731
# Ignore:
# E501: long lines
# E731: lambda warnings
# W503/W504: line breaks before/after operators
ignore = E501,E731,W503,W504

# Enable statistics at the end
statistics = True

[testenv]
passenv = TOXENV CI TRAVIS TRAVIS_*
deps = codecov>=1.4.0
commands = codecov -e TOXENV

0 comments on commit a781b46

Please sign in to comment.