Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add testing setup #1

Merged
merged 5 commits into from Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 74 additions & 0 deletions .github/workflows/ci.yaml
@@ -0,0 +1,74 @@
name: ci
on:
push:
branches: master
pull_request:
branches: master
jobs:
lint:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- run: pip install tox
- name: Run linter
run: make lint
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: '3.7.x'
- run: pip install tox
- name: Build charm
run: make build
- name: Upload charm artifact
uses: actions/upload-artifact@v1
with:
name: charm
path: /tmp/charm-builds/ubuntu-lite
test:
runs-on: ubuntu-18.04
needs: build
strategy:
fail-fast: false
matrix:
juju_channel:
- 2.5/stable
- 2.6/stable
- 2.7/stable
test_bundles:
- xenial-bundle
- bionic-bundle
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
with:
python-version: '3.7.x'
- run: pip install tox
- name: Download charm artifact
uses: actions/download-artifact@v1
with:
name: charm
path: /tmp/charm-builds/ubuntu-lite
# Workarounds for https://github.com/actions/upload-artifact/issues/38
- run: chmod +x -R /tmp/charm-builds/ubuntu-lite/hooks
- name: Set up LXD
run: |
sudo usermod --append --groups lxd $(whoami)
sudo su $(whoami) -c 'lxd init --auto'
sudo su $(whoami) -c 'lxc network set lxdbr0 ipv6.address none'
- name: Set up juju
run: |
sudo snap install juju --classic --channel=${{ matrix.juju_channel }}
sudo su $(whoami) -c 'juju bootstrap localhost --no-gui'
- name: Run deploy
run: make deploy-${{ matrix.test_bundles }}
- name: Run jujuna tests
run: make test-${{ matrix.test_bundles }}
- name: Display juju debug log on failure
run: juju debug-log --lines 100
if: failure()
141 changes: 141 additions & 0 deletions .gitignore
@@ -0,0 +1,141 @@
# Vim
*.swp

# Tox working folder
/.tox

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
.DS_Store

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Dev env
.vagrant
#vagrant.yaml
#Vagrantfile
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,31 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: 'v1.4.4'
hooks:
- id: autopep8
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
- repo: https://gitlab.com/pycqa/flake8
rev: '3.7.9'
hooks:
- id: flake8
args: ['--max-line-length=120']
- repo: https://github.com/ansible/ansible-lint.git
rev: v4.1.1a5
hooks:
- id: ansible-lint
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.16.0
hooks:
- id: yamllint
# pre-commit only reads .yamllint
args: [--config-file=.yamllint.yaml]
15 changes: 15 additions & 0 deletions .yamllint.yaml
@@ -0,0 +1,15 @@
extends: default

rules:
document-start:
present: false
indentation:
# Due to relations from `juju export-bundle`
indent-sequences: whatever
line-length:
max: 120
allow-non-breakable-words: true
allow-non-breakable-inline-mappings: true
truthy:
# Allowing 'on' due to: https://github.com/adrienverge/yamllint/issues/158
allowed-values: ['true', 'false', 'yes', 'no', 'on']
17 changes: 17 additions & 0 deletions DEVELOPMENT.md
@@ -0,0 +1,17 @@
# Development

Here are some handy commands to get you started:

```
$ make help
lint Run linter
build Build charm
deploy Deploy charm
upgrade Upgrade charm
force-upgrade Force upgrade charm
test-xenial Test xenial deployment
test-bionic Test bionic bundle
push Push charm to stable channel
clean Clean .tox and build
help Show this help
```
91 changes: 91 additions & 0 deletions Makefile
@@ -0,0 +1,91 @@
# Use one shell for all commands in a target recipe
.ONESHELL:
# Set default goal
.DEFAULT_GOAL := help
# Use bash shell in Make instead of sh
SHELL := /bin/bash
# Charm variables
CHARM_NAME := ubuntu-lite
CHARM_STORE_URL := cs:~huntdatacenter/ubuntu-lite
CHARM_HOMEPAGE := https://github.com/huntdatacenter/ubuntu-lite/
CHARM_BUGS_URL := https://github.com/huntdatacenter/ubuntu-lite/issues
CHARM_BUILD_DIR ?= /tmp/charm-builds
CHARM_PATH ?= $(CHARM_BUILD_DIR)/$(CHARM_NAME)
# Jujuna variables - can be overrided by env
TIMEOUT ?= 600
ERROR_TIMEOUT ?= 60


lint: ## Run linter
tox -e lint


build: ## Build charm
tox -e build


deploy: ## Deploy charm
juju deploy $(CHARM_BUILD_DIR)/$(CHARM_NAME)


upgrade: ## Upgrade charm
juju upgrade-charm $(CHARM_NAME) --path $(CHARM_BUILD_DIR)/$(CHARM_NAME)


force-upgrade: ## Force upgrade charm
juju upgrade-charm $(CHARM_NAME) --path $(CHARM_BUILD_DIR)/$(CHARM_NAME) --force-units


deploy-xenial-bundle: ## Deploy Xenial test bundle
tox -e deploy-xenial


deploy-bionic-bundle: ## Deploy Bionic test bundle
tox -e deploy-bionic


test-xenial-bundle: ## Test Xenial test bundle
tox -e test-xenial


test-bionic-bundle: ## Test Bionic test bundle
tox -e test-bionic


push: clean build generate-repo-info ## Push charm to stable channel
@echo "Publishing $(CHARM_STORE_URL)"
@export rev=$$(charm push $(CHARM_PATH) $(CHARM_STORE_URL) 2>&1 \
| tee /dev/tty | grep url: | cut -f 2 -d ' ') \
&& charm release --channel stable $$rev \
&& charm grant $$rev --acl read everyone \
&& charm set $$rev extra-info=$$(git rev-parse --short HEAD) \
bugs-url=$(CHARM_BUGS_URL) homepage=$(CHARM_HOMEPAGE)


clean: ## Clean .tox and build
@echo "Cleaning files"
@if [ -d $(CHARM_PATH) ] ; then rm -r $(CHARM_PATH) ; fi
@if [ -d .tox ] ; then rm -r .tox ; fi


# Internal targets
clean-repo:
@if [ -n "$$(git status --porcelain)" ]; then \
echo '!!! Hard resetting repo and removing untracked files !!!'; \
git reset --hard; \
git clean -fdx; \
fi


generate-repo-info:
@if [ -f $(CHARM_PATH)/repo-info ] ; then rm -r $(CHARM_PATH)/repo-info ; fi
@echo "commit: $$(git rev-parse HEAD)" >> $(CHARM_PATH)/repo-info
@echo "commit-short: $$(git rev-parse --short HEAD)" >> $(CHARM_PATH)/repo-info
@echo "branch: $$(git rev-parse --abbrev-ref HEAD)" >> $(CHARM_PATH)/repo-info
@echo "remote: $$(git config --get remote.origin.url)" >> $(CHARM_PATH)/repo-info
@echo "generated: $$(date -u)" >> $(CHARM_PATH)/repo-info


# Display target comments in 'make help'
help: ## Show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
File renamed without changes.
1 change: 1 addition & 0 deletions copyright
3 changes: 3 additions & 0 deletions hooks/hook.template
@@ -0,0 +1,3 @@
#!/bin/bash

exit 0
6 changes: 6 additions & 0 deletions tests/bundles/bionic.yaml
@@ -0,0 +1,6 @@
series: bionic

applications:
ubuntu:
charm: /tmp/charm-builds/ubuntu-lite
num_units: 1
9 changes: 9 additions & 0 deletions tests/bundles/test-bionic.yaml
@@ -0,0 +1,9 @@
# Jujuna test bundle
---
ubuntu:
service:
ssh:
status: 'running'
network:
port:
'22': True