Skip to content

Commit

Permalink
move ci to github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
ejolly committed Aug 19, 2021
1 parent f1ecba8 commit 6c39ee8
Show file tree
Hide file tree
Showing 8 changed files with 205 additions and 236 deletions.
194 changes: 194 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
name: tests & build
on:
push:
branches:
- master
- main
tags-ignore:
- v[0-9].[0-9].[0-9] # prevent double runs for vM.N.P releases
pull_request:
branches:
- master
- main
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run workflow with ssh debugging'
required: false
default: false

schedule:
- cron: '0 0 * * 0'

env:
PACKAGE_NAME: pymer4
DEPLOY_PY_VER: 3.8 # only this job deploys docs, anaconda.org, pypi
DEPLOY_OS: ubuntu-latest
CONDA_BLD_PATH: /tmp/ci_conda_bld

defaults:
run:
# login shell to source the conda hook in .bash_profile
shell:
bash -l {0}

jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
py_ver: [3.7, 3.8, 3.9]
os: [ubuntu-latest, macos-10.15] # Intel macs

outputs:
# tarballs are py3X job-specific
conda-tarball: ${{ steps.conda-bld.outputs.conda-tarball }}

steps:

# ------------------------------------------------------------
# 0. Print some basic github action info
- name: diagnostic info
run: |
echo "OS: ${{ matrix.os }}"
echo "Python: ${{ matrix.py_ver }}"
echo "Conda build path: $CONDA_BLD_PATH"
echo "Deploy OS: $DEPLOY_OS"
echo "Deploy Python: $DEPLOY_PY_VER"
echo "GA event name: ${{ github.event_name }}"
echo "GA ref: ${{ github.ref }}"
# ------------------------------------------------------------
# 1. Grab git repo, setup miniconda environment and packages required to build
- uses: actions/checkout@v2
- name: Setup Miniconda + Checkout code
run: |
echo "GIT_ABBREV_COMMIT=_g${GITHUB_SHA:0:8}" >> $GITHUB_ENV
if [[ ${{ runner.os }} == Linux ]]; then \
miniconda_url='https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh'; \
fi
if [[ ${{ runner.os }} == macOS ]]; then \
miniconda_url='https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh'; \
fi
wget $miniconda_url -O $HOME/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda
hash -r
$HOME/miniconda/bin/conda shell.bash hook >> ~/.bash_profile
source ~/.bash_profile
hash -r
conda config --set always_yes yes --set changeps1 no
conda config --set bld_path $CONDA_BLD_PATH
conda install -n base -q conda-build conda-verify anaconda-client
echo "# ------------------------------------------------------------"
conda info -a
# ------------------------------------------------------------
# 2. Build the conda package and tarballs for each OS
# env defined here are just for convenience when writing bash commands
- name: Build package
id: conda-bld
env:
OS: ${{ runner.os }}
PY_VER: ${{ matrix.py_ver }}
run: |
conda build --python=$PY_VER -c defaults -c conda-forge conda
tarball=$(conda build --python=$PY_VER conda --output | tail -1)
if [[ $OS == "Linux" ]]; then \
conda convert -p win-64 -o $CONDA_BLD_PATH $tarball; \
fi
echo "conda build tarball" $tarball
echo "::set-output name=conda-tarball::$tarball"
# ------------------------------------------------------------
# 3. Create new conda env and install package locally
# Test installation worked
# Get black and pytest from pip because black version on conda lags behind
- name: Create and test fresh installation
env:
PY_VER: ${{ matrix.py_ver }}
run: |
conda create -n env_$PY_VER python=$PY_VER $PACKAGE_NAME -c $CONDA_BLD_PATH -c defaults -c conda-forge
conda activate env_$PY_VER
pip install black pytest-cov
conda list
lscpu
python -c 'import numpy; numpy.show_config()'
python -c "from pymer4.test_install import test_install; test_install()"
# # 4. Run code tests, formatting, and coverage
- name: Run tests + coverage
env:
PY_VER: ${{ matrix.py_ver }}
run: |
conda activate env_$PY_VER
black --check --verbose .
pytest --cov=$PACKAGE_NAME
# 5a. Build docs (only for 3.8 which handles deployment)
# Will also run on PRs which serves as another layer of testing
- name: Build docs
env:
PY_VER: ${{ matrix.py_ver }}
if: ${{ matrix.py_ver == env.DEPLOY_PY_VER && matrix.os == env.DEPLOY_OS }}
run: |
conda activate env_$PY_VER
conda install sphinx sphinx_bootstrap_theme sphinx-gallery -c conda-forge
cd docs && make clean && make html
touch _build/html/.nojekyll
# 5b. Deploy docs (only for 3.8 which handles deployment)
# Only runs when a PR is merged into master or there's a direct push to master
- name: Deploy docs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ (matrix.py_ver == env.DEPLOY_PY_VER && matrix.os == env.DEPLOY_OS) && ((github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event.pull_request.merged && github.base_ref == 'master' && github.head_ref == 'dev')) }}
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-pages
build_dir: docs/_build/html

# 6. Build package for PyPi (only for 3.8 which handles deployment)
- name: Build for Pypi
if: ${{ matrix.py_ver == env.DEPLOY_PY_VER && matrix.os == env.DEPLOY_OS }}
run: |
conda activate env_$PY_VER
pip install build
python -m build --sdist --wheel --outdir dist/
# 7. Deploy package to Pypi (only for 3.8 which handles deployment)
# Only runs when a manual github release is created
- name: PyPi deploy
if: ${{ matrix.py_ver == env.DEPLOY_PY_VER && matrix.os == env.DEPLOY_OS && github.event_name == 'release'}}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}

# 8a. Deploy package to main conda channel (only for 3.8 which handles deployment)
# Only runs when a manual github release is created
- name: Conda main deploy
if: ${{ matrix.py_ver == env.DEPLOY_PY_VER && matrix.os == env.DEPLOY_OS && github.event_name == 'release' }}
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
echo 'Conda release on main channel'
anaconda -t "$ANACONDA_TOKEN" upload $CONDA_BLD_PATH/**/${PACKAGE_NAME}*.tar.bz2 -l "main"
# OR -----

# 8b. Deploy package to pre-release conda channel (only for 3.8 which handles deployment)
# Only runs when a PR is merged into master or there's a direct push to master
- name: Conda pre-release deploy
if: ${{ (matrix.py_ver == env.DEPLOY_PY_VER && matrix.os == env.DEPLOY_OS) && ((github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event.pull_request.merged && github.base_ref == 'master' && github.head_ref == 'dev')) }}
env:
ANACONDA_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
echo 'Conda release on pre-release channel'
anaconda -t "$ANACONDA_TOKEN" upload $CONDA_BLD_PATH/**/${PACKAGE_NAME}*.tar.bz2 -l "pre-release"
# N. Optionall debug via ssh if workflow is run manually with debug_enabled = true
- name: Setup SSH session
if: ${{ github.event_name == 'workflow_dispatch' && github.events.inputs.debug_enabled }}
uses: mxschmitt/action-tmate@v3
96 changes: 0 additions & 96 deletions .travis.yml

This file was deleted.

14 changes: 0 additions & 14 deletions .vscode/launch.json

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build Status](https://travis-ci.org/ejolly/pymer4.svg?branch=master)](https://travis-ci.org/ejolly/pymer4)
[![tests & build](https://github.com/ejolly/pymer4/actions/workflows/CI.yml/badge.svg)](https://github.com/ejolly/pymer4/actions/workflows/CI.yml)
[![PyPI version](https://badge.fury.io/py/pymer4.svg)](https://badge.fury.io/py/pymer4)
[![Anaconda Version](https://anaconda.org/ejolly/pymer4/badges/version.svg)](https://anaconda.org/ejolly/pymer4)
[![Anaconda Platforms](https://anaconda.org/ejolly/pymer4/badges/platforms.svg)](https://anaconda.org/ejolly/pymer4)
[![PyPI version](https://badge.fury.io/py/pymer4.svg)](https://badge.fury.io/py/pymer4)
[![Downloads](https://pepy.tech/badge/pymer4)](https://pepy.tech/project/pymer4)
[![DOI](http://joss.theoj.org/papers/10.21105/joss.00862/status.svg)](https://doi.org/10.21105/joss.00862)
[![DOI](https://zenodo.org/badge/90598701.svg)](https://zenodo.org/record/1523205)
Expand Down Expand Up @@ -56,7 +56,7 @@ Installing via [Anaconda](https://www.anacnda.com/products/individual) is the pr
## Contributing

Contributions are *always welcome*!
If you are interested in contributing feel free to check out the [open issues](https://github.com/ejolly/pymer4/issues), [development roadmap on Trello](https://trello.com/b/gGKmeAJ4), or submit pull requests for additional features or bug fixes. If you do make a pull request, please do so by forking the [development branch](https://github.com/ejolly/pymer4/tree/dev) and taking note of the [contribution guidelines](http://eshinjolly.com/pymer4/contributing.html).
If you are interested in contributing feel free to check out the [open issues](https://github.com/ejolly/pymer4/issues), [development roadmap on Trello](https://trello.com/b/gGKmeAJ4), or submit pull requests for additional features or bug fixes. If you do make a pull request, please do so by forking the [development branch](https://github.com/ejolly/pymer4/tree/dev) and taking note of the [contribution guidelines](https://eshinjolly.com/pymer4/contributing.html).

## Contributors

Expand Down
Loading

0 comments on commit 6c39ee8

Please sign in to comment.