Merge pull request #231 from daler/v0.13rc #128
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: main | |
on: [push] | |
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@v3 | |
- name: git setup | |
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: conda env | |
run: | | |
wget -O Mambaforge.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh" | |
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh" | |
bash Mambaforge.sh -b -p "${HOME}/conda" | |
source "${HOME}/conda/etc/profile.d/conda.sh" | |
source "${HOME}/conda/etc/profile.d/mamba.sh" | |
which conda | |
conda config --system --add channels defaults | |
conda config --system --add channels bioconda | |
conda config --system --add channels conda-forge | |
conda config --system --set channel_priority strict | |
mamba create -y -n gffutils-env \ | |
python=${{ matrix.python-version }} \ | |
bedtools | |
conda activate gffutils-env | |
python setup.py clean sdist | |
(cd dist && pip install gffutils-*.tar.gz) | |
cd $TMPDIR | |
python -c "import gffutils; print(gffutils.__file__)" | |
conda deactivate | |
- name: run unit tests | |
run: | | |
source "${HOME}/conda/etc/profile.d/conda.sh" | |
source "${HOME}/conda/etc/profile.d/mamba.sh" | |
conda activate gffutils-env | |
pip install pytest hypothesis biopython pybedtools | |
pytest -v --doctest-modules gffutils | |
conda deactivate | |
- name: doctests | |
# Specifically in 3.8 (but not 3.6, 3.7, 3.9) we get: | |
# | |
# Handler <function process_generate_options at 0x7f6eb70ba790> | |
# for event 'builder-inited' threw an exception (exception: no | |
# module named gffutils.pybedtools_integration) | |
# | |
# ...and this is difficult or impossible to replicate locally. | |
# The workaround is to just not build the html docs on 3.8. | |
if: ${{ (matrix.python-version != 3.8) }} | |
run: | | |
source "${HOME}/conda/etc/profile.d/conda.sh" | |
source "${HOME}/conda/etc/profile.d/mamba.sh" | |
mamba install -y -n gffutils-env --file docs-requirements.txt | |
conda activate gffutils-env | |
(cd doc && make clean doctest) | |
conda deactivate | |
- name: build docs | |
# See above for note about 3.8 | |
if: ${{ (matrix.python-version != 3.8) }} | |
run: | | |
source "${HOME}/conda/etc/profile.d/conda.sh" | |
source "${HOME}/conda/etc/profile.d/mamba.sh" | |
conda activate gffutils-env | |
(cd doc && make html) | |
conda deactivate | |
# Clone the gh-pages branch to a temporary location | |
git clone \ | |
--single-branch \ | |
--branch gh-pages "https://x-acess-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY" \ | |
/tmp/docs | |
# clean it out and add newly-built docs | |
rm -rf /tmp/docs/* | |
cp -r doc/build/html/* /tmp/docs | |
# so that sphinx-built docs show up correctly on github.io | |
touch /tmp/docs/.nojekyll | |
cd /tmp/docs | |
git add . | |
if git diff --cached --quiet; then | |
echo "no changes to docs, nothing to commit" | |
else | |
git commit -m "update docs" | |
fi | |
cd $WORKDIR | |
- name: push artifact | |
if: ${{ (matrix.python-version == 3.9) }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: doc | |
path: /tmp/docs | |
- name: push docs to gh-pages branch | |
# Push docs to gh-pages if this test is running on master branch, and | |
# restrict to a single Python version. | |
if: ${{ (github.ref == 'refs/heads/master') && (matrix.python-version == 3.9) }} | |
run: | | |
cd /tmp/docs | |
git push "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY" gh-pages | |
cd $WORKDIR |