-
Notifications
You must be signed in to change notification settings - Fork 103
150 lines (127 loc) · 5.05 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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@v3
- 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 "[email protected]"
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: |
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@v3
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