Skip to content

Commit

Permalink
Merge pull request #135 from fnordahl/enable-py37
Browse files Browse the repository at this point in the history
Enable deployment on Python 3.7 systems
  • Loading branch information
johnsca authored Aug 13, 2019
2 parents 9a80d09 + 3129f24 commit 7cb1b66
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 6 deletions.
47 changes: 47 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
sudo: required
dist: xenial
language: python
install: pip install tox-travis
matrix:
include:
- name: "Python 3.4"
python: 3.4
env: ENV=flake8,py3
- name: "Python 3.5"
python: 3.5
env: ENV=flake8,py3
- name: "Python 3.6"
python: 3.6
env: ENV=flake8,py3
- name: "Python 3.7"
python: 3.7
env: ENV=flake8,py3
- name: "Functional test"
env: ENV=func
comment: |
install dependencies in script phase saving time on simpler test environments
sudo back to ourself to activate lxd group membership executable search path
script:
- if [ $ENV = 'func' ]; then
sudo apt update;
sudo apt install -y distro-info;
sudo apt remove -y --purge lxd lxd-client;
sudo snap install lxd;
sudo snap install juju --classic;
sudo snap install charm --classic;
sudo sh -c 'echo PATH=/snap/bin:$PATH >> /etc/environment';
sudo lxd waitready;
sudo lxd init --auto;
sudo usermod -a -G lxd travis;
sudo su - travis -c 'juju bootstrap --no-gui localhost';
fi
- echo "export PATH=$PATH;cd $(pwd)" > $HOME/saved_path
- sudo su - travis -c "source $HOME/saved_path; tox -c tox.ini -e $ENV";
- if [ $ENV = 'func' ]; then
sudo su travis -c 'juju status -m $(juju models --format yaml|grep "^- name:.*zaza"|cut -f2 -d/)';
fi
after_failure:
- if [ $ENV = 'func' ]; then
sudo su travis -c 'for application in trusty xenial bionic cosmic disco; do juju ssh -m $(juju models --format yaml|grep "^- name:.*zaza"|cut -f2 -d/) minimal-${application}/0 "sudo cat /var/log/juju/unit*.log";done';
fi
3 changes: 2 additions & 1 deletion layer.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
includes: ['layer:options']
exclude: ['.travis.yml', 'tests', 'tox.ini', 'test-requirements.txt']
defines:
packages:
type: array
Expand All @@ -21,7 +22,7 @@ defines:
to help avoid conflicts with other charms or libraries on the machine.
include_system_packages:
type: boolean
default: true
default: false
description: >
If using a virtual environment, allow the venv to see Python packages
installed at the system level. This reduces isolation, but is necessary
Expand Down
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
charm-tools
git+https://github.com/openstack-charmers/zaza.git#egg=zaza
17 changes: 17 additions & 0 deletions tests/bundles/minimal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
applications:
minimal-trusty:
series: trusty
charm: /tmp/charm-builds/minimal
num_units: 1
minimal-xenial:
series: xenial
charm: /tmp/charm-builds/minimal
num_units: 1
minimal-bionic:
series: bionic
charm: /tmp/charm-builds/minimal
num_units: 1
minimal-disco:
series: disco
charm: /tmp/charm-builds/minimal
num_units: 1
1 change: 1 addition & 0 deletions tests/bundles/overlays/local-charm-overlay.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment: this bundle overlay intentionally left blank
1 change: 1 addition & 0 deletions tests/charm-minimal/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
options: {}
5 changes: 5 additions & 0 deletions tests/charm-minimal/layer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
includes: ['layer:basic']
options:
basic:
packages: ['libffi-dev', 'libssl-dev']
repo: https://github.com/juju-solutions/layer-basic.git
11 changes: 11 additions & 0 deletions tests/charm-minimal/metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: minimal
summary: minimal charm used to functionally test layer-basic
description: reactive charm with some tricky deps to test venv bootstrapping
maintainer: Juju Developers <juju@lists.ubuntu.com>
tags:
- CI
series:
- trusty
- xenial
- bionic
- disco
7 changes: 7 additions & 0 deletions tests/charm-minimal/reactive/minimal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import charmhelpers
import charms.reactive as reactive


@reactive.when_not('non-existent-flag')
def status_set():
charmhelpers.core.hookenv.status_set('active', 'Unit is ready')
1 change: 1 addition & 0 deletions tests/charm-minimal/wheelhouse.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cryptography
5 changes: 5 additions & 0 deletions tests/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
charm_name: minimal
gate_bundles:
- minimal
tests:
- zaza.charm_tests.noop.tests.NoopTest
19 changes: 16 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
skipsdist=True
envlist = py34, py35
envlist = flake8, py35, py36, py37
skip_missing_interpreters = True

[testenv]
Expand All @@ -11,5 +11,18 @@ commands = /bin/bash -c 'py.test -v || if [[ $? == 5 ]]; then true; else false;
deps =
-r{toxinidir}/requirements.txt

[flake8]
exclude=docs
[testenv:flake8]
commands = flake8

[testenv:func]
basepython = python3
deps = -r{toxinidir}/test-requirements.txt
whitelist_externals = ln mkdir readlink rm juju
setenv = CHARM_LAYERS_DIR=/tmp/charm-builds/_tmp/layers
passenv = HOME
commands =
/bin/rm -rf /tmp/charm-builds/_tmp /tmp/charm-builds/minimal
/bin/mkdir -p /tmp/charm-builds/_tmp/layers
/bin/bash -c '/bin/ln -sf $(readlink --canonicalize {toxinidir}) /tmp/charm-builds/_tmp/layers/layer-basic'
charm-build tests/charm-minimal
functest-run-suite --log DEBUG --keep-model
5 changes: 3 additions & 2 deletions wheelhouse.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pip>=7.0.0,<8.2.0
setuptools>24.3,<=39.0.1
pip>=18.1,<19.2
setuptools<42
setuptools-scm<=1.17.0
charmhelpers>=0.4.0,<1.0.0
charms.reactive>=0.1.0,<2.0.0
wheel<0.34

0 comments on commit 7cb1b66

Please sign in to comment.