Skip to content

Commit

Permalink
Migrate CI to GitHub Actions (#332)
Browse files Browse the repository at this point in the history
* replace requirements.txt with setuptools extras

* ci: replace travis-ci with github actions

* README: update badges for CI
  • Loading branch information
duncanmmacleod authored Jan 24, 2022
1 parent 5368f1d commit bf7f1ea
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 104 deletions.
127 changes: 127 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# -----------------------
#
# Run a full build-and-test from the git repo
# using a combination of conda and pip to install
# all optional dependencies.
#
# This is the 'full' test suite.
#
# -----------------------

name: Build and test

on:
push:
branches:
- main
- master
- release/**
pull_request:
branches:
- main
- master
- release/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
conda:
name: Python ${{ matrix.python-version }} (${{ matrix.os }})

strategy:
fail-fast: false
matrix:
os:
- macOS
- Ubuntu
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
runs-on: ${{ matrix.os }}-latest

# this is needed for conda environments to activate automatically
defaults:
run:
shell: bash -el {0}

steps:
- name: Get source code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Cache conda packages
uses: actions/cache@v2
env:
# increment to reset cache
CACHE_NUMBER: 0
with:
path: ~/conda_pkgs_dir
key: ${{ runner.os }}-conda-${{ matrix.python-version }}-${{ env.CACHE_NUMBER }}
restore-keys: ${{ runner.os }}-conda-${{ matrix.python-version }}-

- name: Configure conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: test
miniforge-variant: Mambaforge
python-version: ${{ matrix.python-version }}
use-mamba: true
# this is needed for caching to work properly:
use-only-tar-bz2: true

- name: Conda info
run: conda info --all

- name: Install dependencies
run: |
python3 -c "
import configparser;
conf = configparser.ConfigParser();
conf.read('setup.cfg');
for opt in ('setup_requires', 'install_requires', 'tests_require'):
print(conf['options'].get(opt, '').strip().lower())
for opt in ('options.extras_require'):
print(conf['options'].get(opt, '').strip().lower())
" | sort -u > _requirements.txt
mamba install --quiet --yes --name test --file _requirements.txt
- name: Install GWSumm
run: python -m pip install . --no-build-isolation -vv

- name: Package list
run: conda list --name test

- name: Run test suite
run: python -m pytest -ra --color yes --cov gwsumm --pyargs gwsumm --cov-report=xml --junitxml=pytest.xml

- name: Test command-line interfaces
run: |
python -m coverage run --append --source gwsumm -m gwsumm --help
python -m coverage run --append --source gwsumm -m gwsumm day --help
python -m coverage run --append --source gwsumm -m gwsumm week --help
python -m coverage run --append --source gwsumm -m gwsumm month --help
python -m coverage run --append --source gwsumm -m gwsumm gps --help
python -m coverage run --append --source gwsumm -m gwsumm.batch --help
python -m coverage run --append --source gwsumm -m gwsumm.plot.triggers --help
python -m coverage run --append --source gwsumm -m gwsumm.plot.guardian --help
- name: Coverage report
run: python -m coverage report --show-missing

- name: Publish coverage to Codecov
uses: codecov/codecov-action@v1.2.1
with:
files: coverage.xml
flags: ${{ runner.os }},python${{ matrix.python-version }}

- name: Upload test results
if: always()
uses: actions/upload-artifact@v2
with:
name: pytest-conda-${{ matrix.os }}-${{ matrix.python-version }}
path: pytest.xml
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ---------------------------
#
# Check the source files for quality issues
#
# ---------------------------

name: Lint

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
flake8:
name: Flake8
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install "flake8>=3.7.0"
- name: Lint with flake8
run: python -m flake8 .
72 changes: 0 additions & 72 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ proposing additions/changes.
:target: https://choosealicense.com/licenses/gpl-3.0/
.. |Supported Python versions| image:: https://img.shields.io/pypi/pyversions/gwsumm.svg
:target: https://pypi.org/project/gwsumm/
.. |Build Status| image:: https://travis-ci.org/gwpy/gwsumm.svg?branch=master
:target: https://travis-ci.org/gwpy/gwsumm
.. |Build Status| image:: https://github.com/gwpy/gwsumm/actions/workflows/build.yml/badge.svg?branch=master
:target: https://github.com/gwpy/gwsumm/actions/workflows/build.yml
.. |Coverage Status| image:: https://codecov.io/gh/gwpy/gwsumm/branch/master/graph/badge.svg
:target: https://codecov.io/gh/gwpy/gwsumm
.. |Code Climate| image:: https://codeclimate.com/github/gwpy/gwsumm/badges/gpa.svg
Expand Down
30 changes: 0 additions & 30 deletions requirements.txt

This file was deleted.

4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ console_scripts =
gwsumm-plot-triggers = gwsumm.plot.triggers.__main__:main

[options.extras_require]
dev =
h5py
ligo-gracedb >= 2.0.0
pykerberos
doc =
sphinx
numpydoc
Expand Down

0 comments on commit bf7f1ea

Please sign in to comment.