Skip to content

Add support for csi index #120

Add support for csi index

Add support for csi index #120

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", "3.12"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- 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
# Only install non-python dependencies (like bedtools & ucsc tools);
# let pip take care of the rest.
grep -Ev "genomepy|matplotlib" optional-requirements.txt > optional-requirements-conda.txt
grep -E "genomepy|matplotlib" optional-requirements.txt > optional-requirements-python.txt
mamba create -y -p ./test-env \
--channel conda-forge \
--channel bioconda \
bedtools \
python=${{ matrix.python-version }} \
--file optional-requirements-conda.txt
conda activate ./test-env
pip install -r test-requirements.txt -r optional-requirements-python.txt
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
if: ${{ (matrix.python-version == 3.10) }}
# Build docs and commit to gh-pages branch. Note that no push happens
# unless we're on the master branch
run: |
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
- name: docs artifact
# Upload built docs as an artifact for inspection, even on PRs
uses: actions/upload-artifact@v4
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.10) }}
run: |
cd /tmp/docs
git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY" gh-pages
cd $WORKDIR