Skip to content

Commit 3b6bb49

Browse files
authored
Merge pull request #76 from turbach/py3X_ci_matrix
update TravisCI to build and upload conda packages for py 3.6, 3.7, 3.8
2 parents a25a110 + 46b7d53 commit 3b6bb49

File tree

3 files changed

+53
-26
lines changed

3 files changed

+53
-26
lines changed

.travis.yml

+34-12
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
11
# requires a valid GIT_TOKEN, ANACONDA_TOKEN, PYPI_TOKEN in TravisCI settings
22
env:
3-
- PACKAGE_NAME: pymer4 # for the conda_upload.sh deploy script
3+
global:
4+
- PACKAGE_NAME: pymer4 # for the conda_upload.sh deploy script
45

56
language: minimal
67

8+
jobs:
9+
include:
10+
- name: "3.6 build"
11+
env: PYV=3.6
12+
- name: "3.7 build"
13+
env: PYV=3.7
14+
- name: "3.8 build"
15+
env: PYV=3.8
16+
- name: "default python build"
17+
env: PYV=""
18+
719
before_install:
820
# b.c conda build GIT_BUILD_STR works (or not) in mysterious ways ...
921
# pfx g means ordinary commit, r means github tagged vM.N.P release
@@ -19,38 +31,48 @@ before_install:
1931

2032
install:
2133
- conda install -q conda-build conda-verify
22-
- conda build conda -c defaults -c conda-forge
23-
- conda create --name pymer4_env pymer4 -c local -c defaults -c conda-forge
24-
- conda activate pymer4_env # run pytests in conda env
34+
- conda build --python=${PYV} -c defaults -c conda-forge conda
35+
36+
script:
37+
# install and test py 3.x variants
38+
- conda create -n pyenv_${PYV} python=${PYV} pymer4 -c local -c defaults -c conda-forge
39+
- conda activate pyenv_${PYV}
2540
- conda install black pytest-cov
2641
- conda list
2742
- lscpu
2843
- python -c 'import numpy; numpy.show_config()'
29-
30-
script:
3144
- black --check --verbose .
3245
- pytest --cov=pymer4
3346

3447
after_success:
35-
- conda install codecov && codecov
3648

3749
before_deploy:
3850
# install necessary packages and refresh the docs before deployment
3951
- conda install sphinx sphinx_bootstrap_theme sphinx-gallery -c conda-forge
4052
- cd docs && make clean && make html && cd .. && pwd
4153

54+
# Gotcha: deploy on conditions are bash if [[ ... ]]; then deploy ; fi
55+
# and **NOT** TravisCI condition syntax used for conditional execution
4256
deploy:
4357

58+
# moved codecov from after_success
59+
- provider: script
60+
skip_cleanup: true
61+
script: conda install codecov && codecov
62+
on:
63+
branch: master
64+
condition: $PYV == "3.8"
65+
4466
# allow any commit to master or dev to refresh the docs on gh-pages
4567
- provider: pages
4668
skip_cleanup: true
4769
keep-history: false
4870
github_token: $GITHUB_TOKEN # from github, set in TravisCI settings
4971
local_dir: ./docs/_build/html
5072
on:
51-
branch: master
5273
# all_branches: true # testing only
53-
# condition: $TRAVIS_BRANCH =~ ^(master)$|^(dev)$
74+
branch: master
75+
condition: $PYV == "3.8"
5476

5577
# this script manages conda package uploads. It routes routine
5678
# master commits to the pre-release label and manual github releases
@@ -59,7 +81,8 @@ deploy:
5981
skip_cleanup: true
6082
script: bash ./ci/conda_upload.sh
6183
on:
62-
all_branches: true # always dry-run the script
84+
condition: $PYV =~ ^3\.[678]$ # python 3.6, 3.7, 3.8 jobs
85+
all_branches: true # dry-run the script on any branch
6386

6487
# only upload manual github releases tagged vM.N.P to PyPI
6588
# so M.N.P on Anaconda Cloud channel/label/main == PyPI
@@ -70,5 +93,4 @@ deploy:
7093
on:
7194
branch: master
7295
tags: true
73-
condition: $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$
74-
96+
condition: $TRAVIS_TAG =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ && $PYV == "3.8"

ci/conda_upload.sh

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Anaconda Cloud package uploader.
22
#
3-
# * This assumes TravisCI ran conda build and the linux-64 package tar.bz
4-
# is in the default location /home/travis/miniconda3/conda-bld/linux-64
3+
# * This assumes TravisCI ran conda build python=$PYV conda
4+
# and the one linux-64 tarball is in the default location
5+
# /home/travis/miniconda3/conda-bld/linux-64
56
#
67
# * The upload only fires if the package version from meta.yaml is
78
# (exactly) Major.Minor.Patch and $TRAVIS_BRANCH is master or
@@ -21,6 +22,9 @@ if [[ -z ${CONDA_DEFAULT_ENV} ]]; then
2122
fi
2223

2324
# intended for TravisCI deploy but can be tricked into running locally
25+
echo PACKAGE_NAME=$PACKAGE_NAME
26+
echo TRAVIS=$TRAVIS
27+
echo TRAVIS_BRANCH=$TRAVIS_BRANCH
2428
if [[ "$TRAVIS" != "true" || -z "$TRAVIS_BRANCH" || -z "${PACKAGE_NAME}" ]]; then
2529
echo "conda_upload.sh is meant to run on TravisCI"
2630
exit -2
@@ -30,8 +34,8 @@ fi
3034
# bld_prefix=${HOME}/miniconda3
3135
bld_prefix="/home/travis/miniconda" # from the .travis.yml
3236

33-
# on travis there should be a single linux-64 package tarball. insist
34-
tarball=`/bin/ls -1 ${bld_prefix}/conda-bld/linux-64/${PACKAGE_NAME}-*-*.tar.bz2`
37+
# for travis parallel jobs there should be 1 py3X linux-64 tarball, insist
38+
tarball=`/bin/ls -1ta ${bld_prefix}/conda-bld/linux-64/${PACKAGE_NAME}-*-*.tar.bz2`
3539
n_tarballs=`echo "${tarball}" | wc -w`
3640
if (( $n_tarballs != 1 )); then
3741
echo "found $n_tarballs package tarballs there must be exactly 1"
@@ -55,7 +59,7 @@ mmp=$(echo $version | sed -n "s/\(\([0-9]\+\.\)\{1,2\}[0-9]\+\).*/\1/p")
5559
# assume this is a dry run, unless version is M.N.P or M.N.P.devXXX and
5660
# TRAVIS_BRANCH is master or a tagged vM.N.P release, in which case,
5761
# set the destination label appropriately.
58-
label="dry-run"
62+
label="dry-run"
5963
if [[ "${version}" =~ ^${mmp}(.dev[0-9]+){0,1}$ ]]; then
6064

6165
# commit to master uploads to pre-release
@@ -74,11 +78,11 @@ fi
7478
mkdir -p ${bld_prefix}/conda-convert/linux-64
7579
cp ${tarball} ${bld_prefix}/conda-convert/linux-64
7680
cd ${bld_prefix}/conda-convert
77-
conda convert -p linux-64 -p osx-64 -p win-64 linux-64/${PACKAGE_NAME}*tar.bz2
81+
conda convert -p linux-64 -p osx-64 -p win-64 linux-64/${PACKAGE_NAME}-*-*.tar.bz2
7882

7983
# POSIX trick sets $ANACONDA_TOKEN if unset or empty string
8084
ANACONDA_TOKEN=${ANACONDA_TOKEN:-[not_set]}
81-
conda_cmd="anaconda --token $ANACONDA_TOKEN upload ./**/${PACKAGE_NAME}*.tar.bz2 --label ${label} --skip-existing"
85+
conda_cmd="anaconda --token $ANACONDA_TOKEN upload ./**/${PACKAGE_NAME}*-*.tar.bz2 --label ${label} --skip-existing"
8286

8387
# echo values to the TravisCI log for general info/debugging
8488
echo "package name: $PACKAGE_NAME"
@@ -91,7 +95,7 @@ echo "tarball: $tarball"
9195
echo "conda label: ${label}"
9296
echo "conda upload command: ${conda_cmd}"
9397
echo "platforms:"
94-
echo "$(ls ./**/${PACKAGE_NAME}*.tar.bz2)"
98+
echo "$(ls ./**/${PACKAGE_NAME}-*-*.tar.bz2)"
9599

96100
# trigger the upload and destination or
97101
if [[ $ANACONDA_TOKEN != "[not_set]" && ( $label = "main" || $label = "pre-release" ) ]]; then

conda/meta.yaml

+7-6
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,26 @@ build:
1313
# script: python setup.py install --single-version-externally-managed --record=record.txt
1414
script: pip install . -vv --no-deps
1515
# abandoned conda build GIT_BUILD_STRING env variable
16-
string: {{ environ.get("GIT_ABBREV_COMMIT", "no_git_abbrev_commit") }}_{{ environ.get("PKG_BUILDNUM", "no_pkg_buildnum") }}
16+
string: py{{environ.get("CONDA_PY", "XX")}}{{environ.get("GIT_ABBREV_COMMIT", "no_git_abbrev_commit") }}_{{ environ.get("PKG_BUILDNUM", "no_pkg_buildnum") }}
1717

1818
requirements:
1919

2020
host:
21-
- python # else test section fails during TravisCI conda build
21+
# else test section fails during TravisCI conda build
22+
- python {{ python }}
2223
- pip
2324

2425
run:
25-
- python >=3.6
26+
- python {{ python }}
2627
- deepdish >=0.3.6
2728
- joblib >=0.14
2829
- matplotlib >=3.0
2930
- numpy >=1.16
3031
- pandas >=1.0
31-
- patsy =>0.5.1
32+
- patsy >=0.5.1
3233
- rpy2 >=3.3.2
33-
- scipy>=1.4.0
34-
- seaborn>=0.10.0
34+
- scipy >=1.4.0
35+
- seaborn >=0.10.0
3536
- r-base
3637
- r-lme4
3738
- r-lmerTest

0 commit comments

Comments
 (0)