Skip to content

Commit 72e8db3

Browse files
committed
tests packaging and installation methods on Ubuntu Trusty
1 parent 3e8bae3 commit 72e8db3

File tree

5 files changed

+195
-0
lines changed

5 files changed

+195
-0
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ matrix:
1717
include:
1818
- python: 3.6
1919
env: TOXENV=lint,docs
20+
- python: 3.6
21+
script: ./tests/integration/packaging-trusty.sh
2022
- python: 3.6
2123
install: python setup.py install
2224
script: ./contrib/zsh/check-all-helps
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
LOCAL_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
6+
COMPDB_PATH=$(cd ${LOCAL_PATH}/../../.. && pwd)
7+
IMAGE_NAME=sarcasm/compdb-ubuntu-trusty
8+
9+
if [[ $# -ne 1 ]]; then
10+
1>&2 cat <<EOF
11+
Usage: $0 SCRIPT
12+
13+
SCRIPT argument is required.
14+
EOF
15+
exit 1
16+
fi
17+
18+
USER_SCRIPT=$(realpath "$1")
19+
20+
>/dev/null docker build -q -t ${IMAGE_NAME} "${LOCAL_PATH}/ubuntu-trusty"
21+
22+
tempdir=$(mktemp -d --tmpdir -t compdb_docker_trusty.XXXXXXXXXX)
23+
>/dev/null pushd "$tempdir"
24+
25+
cp "$USER_SCRIPT" script.sh
26+
27+
cat <<'EOF' > wrapper.sh
28+
#!/bin/bash
29+
set -o errexit
30+
tar xaf /data/compdb.tar.gz
31+
cd compdb
32+
exec /data/script.sh
33+
EOF
34+
chmod +x wrapper.sh
35+
36+
# TODO: verify that removed files (in the index) are not present in the archive
37+
>/dev/null pushd "$COMPDB_PATH"
38+
gitref=$(git stash create)
39+
git archive --prefix=compdb/ -o "${tempdir}/compdb.tar.gz" ${gitref:-HEAD}
40+
>/dev/null popd
41+
42+
docker run \
43+
--interactive \
44+
--tty \
45+
--rm \
46+
--env USER=user \
47+
--env GROUP=grp \
48+
--env UID=$(id -u) \
49+
--env GID=$(id -g) \
50+
--volume $(pwd):/data \
51+
${IMAGE_NAME} \
52+
/data/wrapper.sh
53+
54+
>/dev/null popd
55+
56+
rm -rf "$tempdir"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM ubuntu:trusty
2+
3+
MAINTAINER Guillaume Papin "[email protected]"
4+
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
python-pip \
7+
python-virtualenv \
8+
python3-pip \
9+
runit \
10+
\
11+
&& apt-get clean \
12+
&& rm -rf /var/lib/apt/lists/*
13+
14+
COPY entrypoint.sh /
15+
16+
ENTRYPOINT ["/entrypoint.sh"]
17+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
set -o errexit
4+
5+
: "${USER?Please set USER}"
6+
: "${GROUP?Please set GROUP to the user group using $(id -gn)}"
7+
: "${UID?Please set UID}"
8+
: "${GID?Please set GID}"
9+
10+
groupadd --gid "$GID" "$GROUP"
11+
useradd --create-home --shell /bin/bash --gid "$GROUP" --uid "$UID" "$USER"
12+
13+
export HOME="/home/$USER"
14+
cd "$HOME"
15+
exec chpst -u "$USER" "$@"
16+
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/bash
2+
3+
# This script tests the packaging of compdb on Ubuntu Trusty.
4+
# It has been made to run on Travis CI and locally on Ubuntu 14.04,
5+
# or locally inside docker thanks to docker/ubuntu-trusty.sh.
6+
# The dependencies can be found in docker/ubuntu-trusty/Dockerfile.
7+
8+
if [[ ! -f compdb/__init__.py ]]; then
9+
1>&2 echo "error: this script expects to run in compdb root directory!"
10+
exit 1
11+
fi
12+
13+
set -o errexit
14+
set -o xtrace
15+
16+
# First generate release files to ~/dist
17+
virtualenv .venv
18+
source .venv/bin/activate
19+
pip install -U "setuptools>=18"
20+
pip install wheel
21+
python setup.py sdist bdist_wheel
22+
deactivate
23+
mv dist ~/dist
24+
rm -r .venv
25+
26+
# Install from source
27+
mkdir ~/userbase
28+
PYTHONUSERBASE=~/userbase python setup.py install --user
29+
PYTHONUSERBASE=~/userbase PATH="$HOME/userbase/bin:$PATH" compdb version
30+
rm -r ~/userbase
31+
32+
# Install from source with pip
33+
mkdir ~/userbase
34+
PYTHONUSERBASE=~/userbase pip install --user .
35+
PYTHONUSERBASE=~/userbase PATH="$HOME/userbase/bin:$PATH" compdb version
36+
rm -r ~/userbase
37+
38+
# Install from source in virtualenv
39+
# On Ubuntu 14.04, system wide setuptools version is 3.3,
40+
# but in virtualenv it is 2.2, which is unsufficient.
41+
virtualenv .venv
42+
source .venv/bin/activate
43+
pip install -U "setuptools>=3.3"
44+
python setup.py install
45+
compdb version
46+
deactivate
47+
rm -r .venv
48+
49+
# Wheel
50+
mkdir ~/userbase
51+
PYTHONUSERBASE=~/userbase pip install --user ~/dist/compdb-*.whl
52+
PYTHONUSERBASE=~/userbase PATH="$HOME/userbase/bin:$PATH" compdb version
53+
rm -r ~/userbase
54+
55+
# Wheel in virtualenv
56+
# Seems to work out of the box for ubuntu 14:04: with setuptools 2.2
57+
# and pip 1.5.x.
58+
# I assume wheels have support for 'extras_require'
59+
# for longer than source distributions.
60+
virtualenv .venv
61+
source .venv/bin/activate
62+
pip install ~/dist/compdb-*.whl
63+
compdb version
64+
deactivate
65+
rm -r .venv
66+
67+
# pip install source distribution
68+
mkdir ~/userbase
69+
PYTHONUSERBASE=~/userbase pip install --user ~/dist/compdb-*.tar.gz
70+
PYTHONUSERBASE=~/userbase PATH="$HOME/userbase/bin:$PATH" compdb version
71+
rm -r ~/userbase
72+
73+
# pip install source distribution in virtualenv
74+
#
75+
# 2 alternatives:
76+
# pip vendors setuptools, in pip 7.1.0 setuptools has been bumped to version 18.
77+
# Starting from this version 'extras_require' is supported in setup().
78+
#
79+
# 1. works but does not use extras_require
80+
virtualenv .venv
81+
source .venv/bin/activate
82+
pip install -U 'setuptools>=3.3,<18'
83+
pip install -U 'pip<7.1.0'
84+
pip install ~/dist/compdb-*.tar.gz
85+
compdb version
86+
deactivate
87+
rm -r .venv
88+
# 2. works by using extras_require
89+
virtualenv .venv
90+
source .venv/bin/activate
91+
pip install -U 'setuptools>=18'
92+
pip install -U 'pip>=7.1.0'
93+
pip install ~/dist/compdb-*.tar.gz
94+
compdb version
95+
deactivate
96+
rm -r .venv
97+
98+
# requirements.txt, depends on the pip version that vendors setuptools>=18
99+
virtualenv .venv
100+
source .venv/bin/activate
101+
pip install -U 'pip==7.1.0'
102+
pip install -r requirements.txt
103+
deactivate
104+
rm -r .venv

0 commit comments

Comments
 (0)