Skip to content

Commit b4707b2

Browse files
DirectXMan12frozencemetery
authored andcommitted
Travis build stages
This fixes our Travis auto-deployment mechnanisms, and switches over to making use of Travis build stages along the way. There are now three stages: 1. verify: this *just* runs the verification suite, which currently consists of the flake8 tests. The verification is run under both Python 2 and Python 3, using the fedora:rawhide image 2. test: this runs all of non-verification tests, under the full test matrix we were using before 3. deploy: this runs our deployements, as before The deploy phase now precompiles the sdist, and asks for that to be uploaded instead of regenerating the code before upload. This is a bit of a hack. Finally, the actual Travis scripts themselves were refactored into a series of smaller files and utility functions, which makes the code a bit more readable in some cases, and allows individual functions to be called separately (useful in testing stuff out, and in creating new build stages).
1 parent d64b9a2 commit b4707b2

File tree

8 files changed

+241
-139
lines changed

8 files changed

+241
-139
lines changed

.travis.sh

Lines changed: 0 additions & 93 deletions
This file was deleted.

.travis.yml

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -14,49 +14,63 @@ env:
1414
- DISTRO=fedora:rawhide PYTHON="3"
1515
- DISTRO=fedora:rawhide PYTHON="2"
1616

17+
# we do everything in docker
18+
install: skip
19+
before_install: skip
20+
21+
stages:
22+
- verify
23+
- test
24+
- name: deploy
25+
if: tag is PRESENT
26+
1727
script:
1828
- sudo sed -i '1i 127.0.0.1 test.box' /etc/hosts
1929
- sudo hostname test.box
20-
- >
21-
docker run
22-
-v `pwd`:/tmp/build
23-
-w /tmp/build
24-
-e KRB5_VER=$KRB5_VER
25-
-e PYTHON=$PYTHON
26-
$DISTRO
27-
/bin/bash -ex .travis.sh
28-
29-
before_deploy:
30-
- >
31-
docker run
32-
-v `pwd`:/tmp/build
33-
-w /tmp/build
34-
-e TRAVIS_TAG=$TRAVIS_TAG
35-
-e PKG_NAME_VER=$PKG_NAME_VER
36-
-e KRB5_VER=$KRB5_VER
37-
-e PYTHON=$PYTHON
38-
$DISTRO
39-
/bin/bash -ex .travis.before-deploy.sh
40-
deploy:
41-
- provider: releases
42-
api_key:
43-
secure: e8kjZEY28gWySD5FsnG9CMgeKgFS12gB/xm1Ck1jEgIhYT01VwxvBMHIU7SV/92+aeBao5clN4/qN4P035hD8TShHUMzV7rsmXmqcaCwi3J5sh2hyy4e1PfYAshuX7bxvkfqJSvSonLz0AKHW4pj17yMrTXpWiEioGg0fSLtTHo=
44-
file_glob: true
45-
file:
46-
- tag_build/*
47-
on:
48-
repo: pythongssapi/python-gssapi
49-
tags: true
50-
condition: "$DISTRO = 'fedora:rawhide' && $PYTHON = '3'"
51-
skip_cleanup: true
52-
- provider: pypi
53-
user:
54-
secure: gMwGf6Zt2BuPHN6Qy4feaJaZQBIYZ1lZIdFcpugyhnWtxytzwApx2LTXqHgdaVK7Ik6Xk97RmWS5SyciKmC2V1nyaHCX/f31QZAD3TrLqhScPtvE6j9j/srJhDBjp5yAT8NENMykeSvoIhiidw1tPzWYRW9c93roaOUv6Kqd3zc=
55-
password:
56-
secure: D0lX+DRVac2GN3bZuKxd45DluBrcvwMfV+cciannEJ39kjbHTQEdpi0Uv92rDLNicjqyjy9rAEP7UAQQ1GDOvZcN5OG1+uWU1tSV84uKPgT92YbbQQdHRs/Rh3KSHKeaiJ+3TTDSeBuXYgWRs2gCeVAb18LBYjtIHLZxCFB8ln0=
57-
on:
58-
repo: pythongssapi/python-gssapi
59-
tags: true
60-
condition: "$DISTRO = 'fedora:rawhide' && $PYTHON = '3'"
61-
skip_cleanup: true
62-
docs_dir: travis_docs_build/html
30+
- source ./.travis/lib-util.sh
31+
- util::docker-run $DISTRO ./.travis/build.sh
32+
33+
jobs:
34+
include:
35+
- stage: verify
36+
env: DISTRO=fedora:rawhide PYTHON="2"
37+
script:
38+
- source ./.travis/lib-util.sh
39+
- util::docker-run $DISTRO ./.travis/verify.sh
40+
41+
- stage: verify
42+
env: DISTRO=fedora:rawhide PYTHON="3"
43+
script:
44+
- source ./.travis/lib-util.sh
45+
- util::docker-run $DISTRO ./.travis/verify.sh
46+
47+
- stage: deploy
48+
script: skip
49+
env: DISTRO=fedora:rawhide PYTHON="3"
50+
before_deploy:
51+
- source ./.travis/lib-util.sh
52+
- util::docker-run $DISTRO ./.travis/before-deploy.sh
53+
- ls -alR `pwd`
54+
55+
deploy:
56+
- provider: releases
57+
api_key:
58+
secure: e8kjZEY28gWySD5FsnG9CMgeKgFS12gB/xm1Ck1jEgIhYT01VwxvBMHIU7SV/92+aeBao5clN4/qN4P035hD8TShHUMzV7rsmXmqcaCwi3J5sh2hyy4e1PfYAshuX7bxvkfqJSvSonLz0AKHW4pj17yMrTXpWiEioGg0fSLtTHo=
59+
file_glob: true
60+
file:
61+
- tag_build/*
62+
skip_cleanup: true
63+
on:
64+
all_branches: true
65+
66+
- provider: pypi
67+
user:
68+
secure: "jUAMucBq+9xH8x9u0I0LOwrs3Zb++KN7FwIIwz2CyAt/+TyyrJzeGJaV+dTiJ1OqcUIFqQG6jopzpnAe4biL1O68PEwz9BphKetFLpLHiFNm/n67LYno6NFonWmxndIy99pOP6NZu29nzSNeYq/KgEHo/5OkqEGOxk//lh7X/OY="
69+
password:
70+
secure: "ZqywwnR+G5VeM2sStwfLeutOvqbULHtnStjrdYc8WcC/FBVwmH/W48fTlvxrnswmfKx7Eljv0nN4VcBpoFf1tvz4O2oK/tCRpf0N8SvpT0jBx8bLGUxJ1/3Po6rFgBRWgSb/mzKHPKI6fLlQNcNg8lrd9e1j/zgbVRSwNeMUOR8="
71+
skip_cleanup: true
72+
docs_dir: travis_docs_build/html
73+
on:
74+
all_branches: true
75+
# NB(directxman12): this is a hack. Check ./.travis/before-deploy.sh for an explanation.
76+
distributions: "check"

.travis.before-deploy.sh renamed to .travis/before-deploy.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/bin/bash -ex
22

3+
source ./.travis/lib-setup.sh
4+
35
# build again since I can't figure out how to get travis to recognize the old
46
# build in the new container. The other alternative (besides actually solving
57
# the issue) is to run the docs build and tarball generation every time.
6-
./.travis.sh
78

8-
source ./.venv/bin/activate
9+
./.travis/build.sh
10+
11+
setup::activate
912

1013
yum -y install tar coreutils git
1114

@@ -20,10 +23,28 @@ pip install -e .
2023
# place in a non-standard location so that they don't get cleaned up
2124
python setup.py build_sphinx --build-dir travis_docs_build
2225

26+
# NB(directxman12): this is a *terrible* hack, but basically,
27+
# dpl (the Travis deployer) uses `twine` instead of `setup.py sdist upload`.
28+
# like this:
29+
# - python setup.py $PYPI_DISTRIBUTIONS
30+
# - twine upload -r pypi dist/*
31+
# - [some other stuff]
32+
#
33+
# so if we set $PYPI_DISTRIBUTIONS to something harmless, like `check`,
34+
# and then build the dist ourselves (and save it from the cleanup),
35+
# dpl will upload that
36+
37+
# build the sdist
38+
python setup.py sdist
39+
mv dist dist_saved
40+
2341
# for the tarball upload
2442
# clean up
2543
git clean -Xdf
2644

45+
# restore the saved "dist" directory
46+
mv dist_saved dist
47+
2748
# make the dir
2849
rm -rf ./tag_build || true
2950
mkdir ./tag_build
@@ -38,5 +59,5 @@ fi
3859

3960
PKG_NAME_VER="python-gssapi-${PYTHON_GSSAPI_VERSION}"
4061

41-
tar -czvf ./tag_build/${PKG_NAME_VER}.tar.gz --exclude='tag_build' --exclude='.git' --exclude='travis_docs_build' --exclude='.git' --transform "s,^\.,${PKG_NAME_VER}," .
62+
tar -czvf ./tag_build/${PKG_NAME_VER}.tar.gz --exclude='dist' --exclude='tag_build' --exclude='.git' --exclude='travis_docs_build' --exclude='.git' --transform "s,^\.,${PKG_NAME_VER}," .
4263
sha512sum --binary ./tag_build/${PKG_NAME_VER}.tar.gz > ./tag_build/${PKG_NAME_VER}.sha512sum

.travis/build.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash -ex
2+
3+
# set up dependencies, etc
4+
source ./.travis/lib-setup.sh
5+
setup::install
6+
7+
# always build in-place so that Sphinx can find the modules
8+
python setup.py build_ext --inplace
9+
BUILD_RES=$?
10+
11+
if [ x"$KRB5_VER" = "xheimdal" ]; then
12+
# heimdal can't run the tests yet, so just exit
13+
exit $BUILD_RES
14+
fi
15+
16+
if [ $BUILD_RES -ne 0 ]; then
17+
# if the build failed, don't run the tests
18+
exit $BUILD_RES
19+
fi
20+
21+
python setup.py nosetests --verbosity=3
22+
TEST_RES=$?
23+
24+
exit $TEST_RES

.travis/lib-setup.sh

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
setup::python-suffix() {
4+
if [ x"$PYTHON" = "x3" ]; then
5+
echo "3"
6+
else
7+
echo ""
8+
fi
9+
}
10+
11+
# We test Debian's cython. el7's cython is too old, and Rawhide's virtualenv
12+
# doesn't work right (usrmerge bugs) so we can only test Debian's cython.
13+
14+
setup::debian::install() {
15+
local IS3=$(setup::python-suffix)
16+
17+
export DEBIAN_FRONTEND=noninteractive
18+
apt-get update
19+
20+
if [ x"$KRB5_VER" = "xheimdal" ]; then
21+
apt-get -y install heimdal-dev
22+
else
23+
apt-get -y install krb5-{user,kdc,admin-server,multidev} libkrb5-dev
24+
fi
25+
26+
apt-get -y install gcc virtualenv python$IS3-{virtualenv,dev} cython$IS3
27+
28+
virtualenv --system-site-packages -p $(which python${PYTHON}) .venv
29+
source ./.venv/bin/activate
30+
}
31+
32+
setup::rh::yuminst() {
33+
# yum has no update-only verb
34+
yum -y --nogpgcheck install $@
35+
}
36+
37+
setup::centos::install() {
38+
local IS3=$(setup::python-suffix)
39+
40+
# Cython on el7 is too old - downstream patches
41+
setup::rh::yuminst python$IS3-{virtualenv,devel}
42+
virtualenv -p $(which python$IS3) .venv
43+
source ./.venv/bin/activate
44+
pip install --upgrade pip # el7 pip doesn't quite work right
45+
pip install --install-option='--no-cython-compile' cython
46+
}
47+
48+
setup::fedora::install() {
49+
# path to binary here in case Rawhide changes it
50+
setup::rh::yuminst redhat-rpm-config \
51+
/usr/bin/virtualenv python${PYTHON}-{virtualenv,devel}
52+
virtualenv -p $(which python${PYTHON}) .venv
53+
source ./.venv/bin/activate
54+
pip install --install-option='--no-cython-compile' cython
55+
}
56+
57+
setup::rh::install() {
58+
setup::rh::yuminst krb5-{devel,libs,server,workstation} which gcc findutils
59+
60+
if [ -f /etc/fedora-release ]; then
61+
setup::fedora::install
62+
else
63+
setup::centos::install
64+
fi
65+
}
66+
67+
setup::install() {
68+
if [ -f /etc/debian_version ]; then
69+
setup::debian::install
70+
elif [ -f /etc/redhat-release ]; then
71+
setup::rh::install
72+
else
73+
echo "Distro not found!"
74+
false
75+
fi
76+
77+
pip install -r test-requirements.txt
78+
}
79+
80+
setup::activate() {
81+
# remove (and restore) set -x to avoid log-spam the source
82+
# script, which we don't care about
83+
wastrace=${-//[^x]/}
84+
set +x
85+
source .venv/bin/activate
86+
if [[ -n "$wastrace" ]]; then set -x; fi
87+
}

.travis/lib-util.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
util::docker-run() {
4+
local distro=$1
5+
shift
6+
7+
docker run \
8+
-v `pwd`:/tmp/build \
9+
-w /tmp/build \
10+
-e TRAVIS_TAG=$TRAVIS_TAG \
11+
-e PKG_NAME_VER=$PKG_NAME_VER \
12+
-e KRB5_VER=$KRB5_VER \
13+
-e PYTHON=$PYTHON \
14+
$distro \
15+
/bin/bash -ex $@
16+
}

0 commit comments

Comments
 (0)