|
Packit Service |
a04d08 |
language: python
|
|
Packit Service |
a04d08 |
dist: bionic
|
|
Packit Service |
a04d08 |
|
|
Packit Service |
a04d08 |
# We use two different caching strategies. The default is to cache pip
|
|
Packit Service |
a04d08 |
# packages (as most of our jobs use pip packages), which is configured here.
|
|
Packit Service |
a04d08 |
# For the integration tests, we instead want to cache the lxd images and
|
|
Packit Service |
a04d08 |
# package build schroot.
|
|
Packit Service |
a04d08 |
#
|
|
Packit Service |
a04d08 |
# We cache the lxd images because this saves a few seconds in the general
|
|
Packit Service |
a04d08 |
# case, but provides substantial speed-ups when cloud-images.ubuntu.com, the
|
|
Packit Service |
a04d08 |
# source of the images, is under heavy load. The directory in which the lxd
|
|
Packit Service |
a04d08 |
# images are stored (/var/snap/lxd/common/lxd/images/) is not
|
|
Packit Service |
a04d08 |
# readable/writeable by the default user (which is a requirement for caching),
|
|
Packit Service |
a04d08 |
# so we instead cache the `lxd_images/` directory. We move lxd images out of
|
|
Packit Service |
a04d08 |
# there before we run tests and back in once tests are complete. We _move_ the
|
|
Packit Service |
a04d08 |
# images out and only copy the most recent lxd image back into the cache, to
|
|
Packit Service |
a04d08 |
# avoid our cache growing without bound. (We only need the most recent lxd
|
|
Packit Service |
a04d08 |
# image because the integration tests only use a single image.)
|
|
Packit Service |
a04d08 |
#
|
|
Packit Service |
a04d08 |
# We cache the package build schroot because it saves 2-3 minutes per build.
|
|
Packit Service |
a04d08 |
# Without caching, we have to perform a debootstrap for every build. We update
|
|
Packit Service |
a04d08 |
# the schroot before storing it back in the cache, to ensure that we aren't
|
|
Packit Service |
a04d08 |
# just using an increasingly-old schroot as time passes. The cached schroot is
|
|
Packit Service |
a04d08 |
# stored as a tarball, to preserve permissions/ownership.
|
|
Packit Service |
a04d08 |
cache: pip
|
|
Packit Service |
a04d08 |
|
|
Packit Service |
a04d08 |
install:
|
|
Packit Service |
a04d08 |
# Required so `git describe` will definitely find a tag; see
|
|
Packit Service |
a04d08 |
# https://github.com/travis-ci/travis-ci/issues/7422
|
|
Packit Service |
a04d08 |
- git fetch --unshallow
|
|
Packit Service |
a04d08 |
- pip install tox
|
|
Packit Service |
a04d08 |
|
|
Packit Service |
a04d08 |
script:
|
|
Packit Service |
a04d08 |
- tox
|
|
Packit Service |
a04d08 |
|
|
Packit Service |
a04d08 |
matrix:
|
|
Packit Service |
a04d08 |
fast_finish: true
|
|
Packit Service |
a04d08 |
include:
|
|
Packit Service |
a04d08 |
- python: 3.6
|
|
Packit Service |
a04d08 |
env:
|
|
Packit Service |
a04d08 |
TOXENV=py3
|
|
Packit Service |
a04d08 |
PYTEST_ADDOPTS=-v # List all tests run by pytest
|
|
Packit Service |
a04d08 |
- if: NOT branch =~ /^ubuntu\//
|
|
Packit Service |
a04d08 |
cache:
|
|
Packit Service |
a04d08 |
- directories:
|
|
Packit Service |
a04d08 |
- lxd_images
|
|
Packit Service |
a04d08 |
- chroots
|
|
Packit Service |
a04d08 |
before_cache:
|
|
Packit Service |
a04d08 |
- |
|
|
Packit Service |
a04d08 |
# Find the most recent image file
|
|
Packit Service |
a04d08 |
latest_file="$(sudo ls -Art /var/snap/lxd/common/lxd/images/ | tail -n 1)"
|
|
Packit Service |
a04d08 |
# This might be <hash>.rootfs or <hash>, normalise
|
|
Packit Service |
a04d08 |
latest_file="$(basename $latest_file .rootfs)"
|
|
Packit Service |
a04d08 |
# Find all files with that prefix and copy them to our cache dir
|
|
Packit Service |
a04d08 |
sudo find /var/snap/lxd/common/lxd/images/ -name $latest_file* -print -exec cp {} "$TRAVIS_BUILD_DIR/lxd_images/" \;
|
|
Packit Service |
a04d08 |
install:
|
|
Packit Service |
a04d08 |
- git fetch --unshallow
|
|
Packit Service |
a04d08 |
- sudo apt-get install -y --install-recommends sbuild ubuntu-dev-tools fakeroot tox debhelper
|
|
Packit Service |
a04d08 |
- pip install .
|
|
Packit Service |
a04d08 |
- pip install tox
|
|
Packit Service |
a04d08 |
# bionic has lxd from deb installed, remove it first to ensure
|
|
Packit Service |
a04d08 |
# pylxd talks only to the lxd from snap
|
|
Packit Service |
a04d08 |
- sudo apt remove --purge lxd lxd-client
|
|
Packit Service |
a04d08 |
- sudo rm -Rf /var/lib/lxd
|
|
Packit Service |
a04d08 |
- sudo snap install lxd
|
|
Packit Service |
a04d08 |
- sudo lxd init --auto
|
|
Packit Service |
a04d08 |
- sudo mkdir --mode=1777 -p /var/snap/lxd/common/consoles
|
|
Packit Service |
a04d08 |
# Move any cached lxd images into lxd's image dir
|
|
Packit Service |
a04d08 |
- sudo find "$TRAVIS_BUILD_DIR/lxd_images/" -type f -print -exec mv {} /var/snap/lxd/common/lxd/images/ \;
|
|
Packit Service |
a04d08 |
- sudo usermod -a -G lxd $USER
|
|
Packit Service |
a04d08 |
- sudo sbuild-adduser $USER
|
|
Packit Service |
a04d08 |
- cp /usr/share/doc/sbuild/examples/example.sbuildrc /home/$USER/.sbuildrc
|
|
Packit Service |
a04d08 |
script:
|
|
Packit Service |
a04d08 |
# Ubuntu LTS: Build
|
|
Packit Service |
a04d08 |
- ./packages/bddeb -S -d --release xenial
|
|
Packit Service |
a04d08 |
- |
|
|
Packit Service |
a04d08 |
needs_caching=false
|
|
Packit Service |
a04d08 |
if [ -e "$TRAVIS_BUILD_DIR/chroots/xenial-amd64.tar" ]; then
|
|
Packit Service |
a04d08 |
# If we have a cached chroot, move it into place
|
|
Packit Service |
a04d08 |
sudo mkdir -p /var/lib/schroot/chroots/xenial-amd64
|
|
Packit Service |
a04d08 |
sudo tar --sparse --xattrs --preserve-permissions --numeric-owner -xf "$TRAVIS_BUILD_DIR/chroots/xenial-amd64.tar" -C /var/lib/schroot/chroots/xenial-amd64
|
|
Packit Service |
a04d08 |
# Write its configuration
|
|
Packit Service |
a04d08 |
cat > sbuild-xenial-amd64 << EOM
|
|
Packit Service |
a04d08 |
[xenial-amd64]
|
|
Packit Service |
a04d08 |
description=xenial-amd64
|
|
Packit Service |
a04d08 |
groups=sbuild,root,admin
|
|
Packit Service |
a04d08 |
root-groups=sbuild,root,admin
|
|
Packit Service |
a04d08 |
# Uncomment these lines to allow members of these groups to access
|
|
Packit Service |
a04d08 |
# the -source chroots directly (useful for automated updates, etc).
|
|
Packit Service |
a04d08 |
#source-root-users=sbuild,root,admin
|
|
Packit Service |
a04d08 |
#source-root-groups=sbuild,root,admin
|
|
Packit Service |
a04d08 |
type=directory
|
|
Packit Service |
a04d08 |
profile=sbuild
|
|
Packit Service |
a04d08 |
union-type=overlay
|
|
Packit Service |
a04d08 |
directory=/var/lib/schroot/chroots/xenial-amd64
|
|
Packit Service |
a04d08 |
EOM
|
|
Packit Service |
a04d08 |
sudo mv sbuild-xenial-amd64 /etc/schroot/chroot.d/
|
|
Packit Service |
a04d08 |
sudo chown root /etc/schroot/chroot.d/sbuild-xenial-amd64
|
|
Packit Service |
a04d08 |
# And ensure it's up-to-date.
|
|
Packit Service |
a04d08 |
before_pkgs="$(sudo schroot -c source:xenial-amd64 -d / dpkg -l | sha256sum)"
|
|
Packit Service |
a04d08 |
sudo schroot -c source:xenial-amd64 -d / -- sh -c "apt-get update && apt-get -qqy upgrade"
|
|
Packit Service |
a04d08 |
after_pkgs=$(sudo schroot -c source:xenial-amd64 -d / dpkg -l | sha256sum)
|
|
Packit Service |
a04d08 |
if [ "$before_pkgs" != "$after_pkgs" ]; then
|
|
Packit Service |
a04d08 |
needs_caching=true
|
|
Packit Service |
a04d08 |
fi
|
|
Packit Service |
a04d08 |
else
|
|
Packit Service |
a04d08 |
# Otherwise, create the chroot
|
|
Packit Service |
a04d08 |
sudo -E su $USER -c 'mk-sbuild xenial'
|
|
Packit Service |
a04d08 |
needs_caching=true
|
|
Packit Service |
a04d08 |
fi
|
|
Packit Service |
a04d08 |
# If there are changes to the schroot (or it's entirely new),
|
|
Packit Service |
a04d08 |
# tar up the schroot (to preserve ownership/permissions) and
|
|
Packit Service |
a04d08 |
# move it into the cached dir; no need to compress it because
|
|
Packit Service |
a04d08 |
# Travis will do that anyway
|
|
Packit Service |
a04d08 |
if [ "$needs_caching" = "true" ]; then
|
|
Packit Service |
a04d08 |
sudo tar --sparse --xattrs --xattrs-include=* -cf "$TRAVIS_BUILD_DIR/chroots/xenial-amd64.tar" -C /var/lib/schroot/chroots/xenial-amd64 .
|
|
Packit Service |
a04d08 |
fi
|
|
Packit Service |
a04d08 |
# Use sudo to get a new shell where we're in the sbuild group
|
|
Packit Service |
a04d08 |
- sudo -E su $USER -c 'sbuild --nolog --no-run-lintian --verbose --dist=xenial cloud-init_*.dsc'
|
|
Packit Service |
a04d08 |
# Ubuntu LTS: Integration
|
|
Packit Service |
a04d08 |
- sg lxd -c 'tox -e citest -- run --verbose --preserve-data --data-dir results --os-name xenial --test modules/apt_configure_sources_list.yaml --test modules/ntp_servers --test modules/set_password_list --test modules/user_groups --deb cloud-init_*_all.deb'
|
|
Packit Service |
a04d08 |
- python: 3.5
|
|
Packit Service |
a04d08 |
env:
|
|
Packit Service |
a04d08 |
TOXENV=xenial
|
|
Packit Service |
a04d08 |
PYTEST_ADDOPTS=-v # List all tests run by pytest
|
|
Packit Service |
a04d08 |
dist: xenial
|
|
Packit Service |
a04d08 |
- python: 3.6
|
|
Packit Service |
a04d08 |
env: TOXENV=flake8
|
|
Packit Service |
a04d08 |
- python: 3.6
|
|
Packit Service |
a04d08 |
env: TOXENV=pylint
|
|
Packit Service |
a04d08 |
- python: 3.6
|
|
Packit Service |
a04d08 |
env: TOXENV=doc
|