Merge ~xavpaice/charm-prometheus-ceph-exporter:add_charmcraft into charm-prometheus-ceph-exporter:master

Proposed by Xav Paice
Status: Merged
Approved by: Przemyslaw Lal
Approved revision: b4cbe86e827fcc8af679fed3ea15a1b759a89be4
Merged at revision: 224588ef667e2f85b9775ecbce139bae7777b390
Proposed branch: ~xavpaice/charm-prometheus-ceph-exporter:add_charmcraft
Merge into: charm-prometheus-ceph-exporter:master
Diff against target: 177 lines (+64/-19)
6 files modified
Makefile (+25/-15)
charmcraft.yaml (+20/-0)
metadata.yaml (+1/-0)
rename.sh (+13/-0)
src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2 (+2/-2)
src/tox.ini (+3/-2)
Reviewer Review Type Date Requested Status
Przemyslaw Lal Approve
🤖 prod-jenkaas-bootstack (community) continuous-integration Approve
BootStack Reviewers Pending
BootStack Reviewers Pending
Review via email: mp+419992@code.launchpad.net

Commit message

Add charmcraft.yaml

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Approve (continuous-integration)
Revision history for this message
Przemyslaw Lal (przemeklal) wrote :

LGTM

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 224588ef667e2f85b9775ecbce139bae7777b390

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/Makefile b/Makefile
2index ddb2a25..cb4081c 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -4,8 +4,15 @@ PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
6 ifndef CHARM_BUILD_DIR
7 CHARM_BUILD_DIR=${PROJECTPATH}.build
8 endif
9-CHARM_LAYERS_DIR=${PROJECTPATH}/layers
10-CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
11+ifndef CHARM_LAYERS_DIR
12+ CHARM_LAYERS_DIR=${PROJECTPATH}/layers
13+endif
14+ifndef CHARM_INTERFACES_DIR
15+ CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
16+endif
17+ifdef CONTAINER
18+ BUILD_ARGS="--destructive-mode"
19+endif
20 METADATA_FILE="src/metadata.yaml"
21 CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')
22
23@@ -18,7 +25,8 @@ help:
24 @echo " make submodules-update - update submodules to latest changes on remote branch"
25 @echo " make build - build the charm"
26 @echo " make release - run clean, submodules, and build targets"
27- @echo " make lint - run flake8 and black"
28+ @echo " make lint - run flake8 and black --check"
29+ @echo " make black - run black and reformat files"
30 @echo " make proof - run charm proof"
31 @echo " make unittests - run the tests defined in the unittest subdirectory"
32 @echo " make functional - run the tests defined in the functional subdirectory"
33@@ -27,35 +35,37 @@ help:
34
35 clean:
36 @echo "Cleaning files"
37- @git clean -fXd
38+ @git clean -ffXd -e '!.idea'
39 @echo "Cleaning existing build"
40 @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}
41+ @charmcraft clean
42+ @rm -rf ${PROJECTPATH}/${CHARM_NAME}.charm
43
44 submodules:
45- @echo "Cloning submodules"
46 @git submodule update --init --recursive
47
48 submodules-update:
49- @echo "Pulling latest updates for submodules"
50 @git submodule update --init --recursive --remote --merge
51
52-build:
53+build: clean submodules-update
54 @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"
55 @-git rev-parse --abbrev-ref HEAD > ./src/repo-info
56- @CHARM_LAYERS_DIR=${CHARM_LAYERS_DIR} CHARM_INTERFACES_DIR=${CHARM_INTERFACES_DIR} \
57- TERM=linux CHARM_BUILD_DIR=${CHARM_BUILD_DIR} charm build src/
58+ @charmcraft -v pack ${BUILD_ARGS}
59+ @bash -c ./rename.sh
60+ @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME}
61+ @unzip ${PROJECTPATH}/${CHARM_NAME}.charm -d ${CHARM_BUILD_DIR}/${CHARM_NAME}
62
63 release: clean build
64 @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"
65
66-black:
67- @echo "Blacken"
68- @cd src && tox -e black
69-
70 lint:
71 @echo "Running lint checks"
72 @cd src && tox -e lint
73
74+black:
75+ @echo "Reformat files with black"
76+ @cd src && tox -e black
77+
78 proof: build
79 @echo "Running charm proof"
80 @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}
81@@ -66,10 +76,10 @@ unittests:
82
83 functional: build
84 @echo "Executing functional tests in ${CHARM_BUILD_DIR}"
85- @cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} tox -e func
86+ @cd src && CHARM_LOCATION=${PROJECTPATH} tox -e func
87
88 test: lint proof unittests functional
89 @echo "Tests completed for charm ${CHARM_NAME}."
90
91 # The targets below don't depend on a file
92-.PHONY: help submodules submodules-update clean build release lint proof unittests functional test
93+.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test
94diff --git a/charmcraft.yaml b/charmcraft.yaml
95new file mode 100644
96index 0000000..7d9c002
97--- /dev/null
98+++ b/charmcraft.yaml
99@@ -0,0 +1,20 @@
100+type: charm
101+parts:
102+ charm:
103+ source: src
104+ plugin: reactive
105+ build-snaps: [charm]
106+bases:
107+ - build-on:
108+ - name: ubuntu
109+ channel: "20.04"
110+ architectures: ["amd64"]
111+ run-on:
112+ - name: ubuntu
113+ channel: "20.04"
114+ architectures:
115+ - amd64
116+ - name: ubuntu
117+ channel: "18.04"
118+ architectures:
119+ - amd64
120diff --git a/metadata.yaml b/metadata.yaml
121new file mode 120000
122index 0000000..0768683
123--- /dev/null
124+++ b/metadata.yaml
125@@ -0,0 +1 @@
126+src/metadata.yaml
127\ No newline at end of file
128diff --git a/rename.sh b/rename.sh
129new file mode 100755
130index 0000000..bc8697f
131--- /dev/null
132+++ b/rename.sh
133@@ -0,0 +1,13 @@
134+#!/bin/bash
135+charm=$(grep -E "^name:" src/metadata.yaml | awk '{print $2}')
136+echo "renaming ${charm}_*.charm to ${charm}.charm"
137+echo -n "pwd: "
138+pwd
139+ls -al
140+echo "Removing previous charm if it exists"
141+if [[ -e "${charm}.charm" ]];
142+then
143+ rm "${charm}.charm"
144+fi
145+echo "Renaming charm here."
146+mv ${charm}_*.charm ${charm}.charm
147diff --git a/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2 b/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
148index 1d2b823..45065bc 100644
149--- a/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
150+++ b/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
151@@ -1,3 +1,3 @@
152 applications:
153- prometheus-ceph-exporter:
154- charm: "{{ CHARM_BUILD_DIR }}/{{ charm_name }}"
155+ {{ charm_name }}:
156+ charm: "{{ CHARM_LOCATION }}/{{ charm_name }}.charm"
157diff --git a/src/tox.ini b/src/tox.ini
158index 40df104..af3fcb8 100644
159--- a/src/tox.ini
160+++ b/src/tox.ini
161@@ -10,7 +10,8 @@ setenv =
162 passenv =
163 HOME
164 PATH
165- CHARM_BUILD_DIR
166+ CHARM_*
167+ OS_*
168 PYTEST_KEEP_MODEL
169 PYTEST_CLOUD_NAME
170 PYTEST_CLOUD_REGION
171@@ -61,5 +62,5 @@ deps = -r{toxinidir}/tests/requirements.txt
172
173 [testenv:func]
174 changedir = {toxinidir}/tests/functional
175-commands = functest-run-suite {posargs}
176+commands = functest-run-suite --keep-faulty-model {posargs}
177 deps = -r{toxinidir}/tests/requirements.txt

Subscribers

People subscribed via source and target branches

to all changes: