← Back to team overview

livepatch-charmers team mailing list archive

[Merge] ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:charm-test into canonical-livepatch-charm:master

 

Barry Price has proposed merging ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:charm-test into canonical-livepatch-charm:master with ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:master as a prerequisite.

Requested reviews:
  Livepatch charm developers (livepatch-charmers)

For more details, see:
https://code.launchpad.net/~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm/+merge/345071
-- 
Your team Livepatch charm developers is requested to review the proposed merge of ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:charm-test into canonical-livepatch-charm:master.
diff --git a/Makefile b/Makefile
index 07b57c9..630e665 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,38 @@
-#!/usr/bin/make
+BUILDDEST:=$(if $(JUJU_REPOSITORY),$(JUJU_REPOSITORY),"../canonical-livepatch-built")
+BUILTCHARMDIR:="$(BUILDDEST)/builds/canonical-livepatch"
 
+all: test
+
+.PHONY: clean
+clean:
+	@rm -f .unit-state.db
+	@find . -name "*.pyc" -type f -exec rm -f '{}' \;
+	@find . -name "__pycache__" -type d -prune -exec rm -rf '{}' \;
+
+.PHONY: testdeps
+testdeps:
+	@sudo apt-get update
+	@sudo apt-get install -y make flake8 python3-flake8 python3-pip python-pip snapd
+	@which juju >/dev/null || (sudo snap install juju --classic)
+	@which charm >/dev/null || (sudo snap install charm)
+	@which bundletester >/dev/null || (pip2 install bundletester juju-deployer)
+	@pip3 install amulet
+
+.PHONY: lint
 lint:
-	@flake8 --max-line-length=120
+	@flake8 --max-complexity=16 --max-line-length=120 && echo OK
+
+.PHONY: charmbuild
+charmbuild:
+	charm build --output-dir $(BUILDDEST) --report
+
+.PHONY: test
+test: check-jujumodel
+	@echo "Running functional tests (including lint and unit tests)..."
+	bundletester -t $(BUILTCHARMDIR) -Fvl DEBUG -e $(JUJU_MODEL)
+
+.PHONY: check-jujumodel
+check-jujumodel:
+ifndef JUJU_MODEL
+	$(error JUJU_MODEL is undefined)
+endif
diff --git a/tests/00-setup b/tests/00-setup
deleted file mode 100755
index 830e9a6..0000000
--- a/tests/00-setup
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-pip3 install amulet juju-deployer
diff --git a/tests/tests.yaml b/tests/tests.yaml
new file mode 100644
index 0000000..757bcc2
--- /dev/null
+++ b/tests/tests.yaml
@@ -0,0 +1,2 @@
+makefile:
+    - lint

Follow ups