Skip to content

target branch for v0.9.1 #99

target branch for v0.9.1

target branch for v0.9.1 #99

Workflow file for this run

name: main
on:
push:
branches:
- master
pull_request:
types:
- opened
- reopened
- synchronize
jobs:
build-and-test:
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: git setup
# Set up git and export env vars to be used in later steps.
# Note the unconventional mechanism for exporting envs by appending to
# $GITHUB_ENV.
id: git-setup
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_ENV
echo "WORKDIR=$(pwd)" >> $GITHUB_ENV
- name: cythonize and pip
# Convert .pyx files to .cpp and package into sdist tarball.
#
# This only requires Cython, no other dependencies.
run: |
eval "$(conda shell.bash hook)"
conda create -p ./cython-env -y cython python=${{ matrix.python-version }} numpy
conda activate ./cython-env
python setup.py clean cythonize sdist
(cd dist && pip install pybedtools-*.tar.gz && cd $TMPDIR && python -c 'import pybedtools; print(pybedtools.__file__)')
conda deactivate
- name: conda env and install locally
# Set up conda and install pybedtools into that env
#
# NOTE: Tests require *.so files that are created by installing the
# package, otherwise we get:
#
# ModuleNotFoundError: No module named 'pybedtools.cbedtools'
#
# We could install from the source repo dir. However this may inadvertently
# rely on files that are in the source repo but not in the actual sdist
# package. So we extract the sdist tarball to another location and install
# from there.
#
# Tests below will operate in this newly-installed directory.
run: |
eval "$(conda shell.bash hook)"
conda install mamba python=${{ matrix.python-version }} -y --channel conda-forge
if [ ${{ matrix.python-version }} != "3.11" ]; then
mamba create -y -p ./test-env \
--channel conda-forge \
--channel bioconda python=${{ matrix.python-version }} \
--file requirements.txt \
--file test-requirements.txt \
--file optional-requirements.txt
conda activate ./test-env
else
# Only install bedtools; let pip take care of the rest for 3.11 until
# bioconda catches up.
#
# We still install the test requirements though, and the optional
# requirements except for genomepy which is in bioconda.
grep -v "genomepy" optional-requirements.txt > optional-requirements-3.11.txt
mamba create -y -p ./test-env \
--channel conda-forge \
--channel bioconda \
bedtools \
python=${{ matrix.python-version }} \
--file test-requirements.txt \
--file optional-requirements-3.11.txt
conda activate ./test-env
pip install genomepy
fi
conda activate ./test-env
mkdir -p /tmp/pybedtools-uncompressed
cd /tmp/pybedtools-uncompressed
tar -xf $WORKDIR/dist/pybedtools-*.tar.gz
pip install -e /tmp/pybedtools-uncompressed/pybedtools-*
# Trying import in the same directory will complain that cbedtools
# can't be imported
(cd / && python -c 'import pybedtools; print(pybedtools.__file__)')
- name: tests
# Run pytest and sphinx doctests
run: |
cd $WORKDIR
eval "$(conda shell.bash hook)"
conda activate ./test-env
# Extract the package tarball built above, and use that for running the tests.
cd /tmp/pybedtools-uncompressed/pybedtools-*
pytest -v --doctest-modules
pytest -v pybedtools/test/genomepy_integration.py
cp -r $WORKDIR/docs .
(cd docs && make clean doctest)
- name: build-docs
# Build docs and commit to gh-pages branch. Note that no push happens
# unless we're on the master branch
run: |
if [ ${{ matrix.python-version }} != "3.11" ]; then
eval "$(conda shell.bash hook)"
conda activate ./test-env
# Move to extracted tarball dir, see above notes
cd /tmp/pybedtools-uncompressed/pybedtools-*
(cd docs && make html)
git clone \
--single-branch \
--branch gh-pages "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY" \
/tmp/docs
rm -rf /tmp/docs/*
cp -r docs/build/html/* /tmp/docs
touch /tmp/docs/.nojekyll
cd /tmp/docs
git add .
if git diff --cached --quiet; then
echo "no changes, nothing to commit"
else
git commit -m 'update docs'
fi
cd $WORKDIR
fi
- name: docs artifact
# Upload built docs as an artifact for inspection, even on PRs
uses: actions/upload-artifact@v2
with:
name: docs
path: /tmp/docs
- name: push docs to gh-pages branch
# Push docs to gh-pages if this test is running on master branch
if: ${{ (github.ref == 'refs/heads/master') && (matrix.python-version == 3.8) }}
run: |
cd /tmp/docs
git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY" gh-pages
cd $WORKDIR