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
diff --git a/Makefile b/Makefile
index ddb2a25..cb4081c 100644
--- a/Makefile
+++ b/Makefile
@@ -4,8 +4,15 @@ PROJECTPATH=$(dir $(realpath $(MAKEFILE_LIST)))
4ifndef CHARM_BUILD_DIR4ifndef CHARM_BUILD_DIR
5 CHARM_BUILD_DIR=${PROJECTPATH}.build5 CHARM_BUILD_DIR=${PROJECTPATH}.build
6endif6endif
7CHARM_LAYERS_DIR=${PROJECTPATH}/layers7ifndef CHARM_LAYERS_DIR
8CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces8 CHARM_LAYERS_DIR=${PROJECTPATH}/layers
9endif
10ifndef CHARM_INTERFACES_DIR
11 CHARM_INTERFACES_DIR=${PROJECTPATH}/interfaces
12endif
13ifdef CONTAINER
14 BUILD_ARGS="--destructive-mode"
15endif
9METADATA_FILE="src/metadata.yaml"16METADATA_FILE="src/metadata.yaml"
10CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')17CHARM_NAME=$(shell cat ${PROJECTPATH}/${METADATA_FILE} | grep -E "^name:" | awk '{print $$2}')
1118
@@ -18,7 +25,8 @@ help:
18 @echo " make submodules-update - update submodules to latest changes on remote branch"25 @echo " make submodules-update - update submodules to latest changes on remote branch"
19 @echo " make build - build the charm"26 @echo " make build - build the charm"
20 @echo " make release - run clean, submodules, and build targets"27 @echo " make release - run clean, submodules, and build targets"
21 @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"
22 @echo " make proof - run charm proof"30 @echo " make proof - run charm proof"
23 @echo " make unittests - run the tests defined in the unittest subdirectory"31 @echo " make unittests - run the tests defined in the unittest subdirectory"
24 @echo " make functional - run the tests defined in the functional subdirectory"32 @echo " make functional - run the tests defined in the functional subdirectory"
@@ -27,35 +35,37 @@ help:
2735
28clean:36clean:
29 @echo "Cleaning files"37 @echo "Cleaning files"
30 @git clean -fXd38 @git clean -ffXd -e '!.idea'
31 @echo "Cleaning existing build"39 @echo "Cleaning existing build"
32 @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}40 @rm -rf ${CHARM_BUILD_DIR}/${CHARM_NAME}
41 @charmcraft clean
42 @rm -rf ${PROJECTPATH}/${CHARM_NAME}.charm
3343
34submodules:44submodules:
35 @echo "Cloning submodules"
36 @git submodule update --init --recursive45 @git submodule update --init --recursive
3746
38submodules-update:47submodules-update:
39 @echo "Pulling latest updates for submodules"
40 @git submodule update --init --recursive --remote --merge48 @git submodule update --init --recursive --remote --merge
4149
42build:50build: clean submodules-update
43 @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"51 @echo "Building charm to directory ${CHARM_BUILD_DIR}/${CHARM_NAME}"
44 @-git rev-parse --abbrev-ref HEAD > ./src/repo-info52 @-git rev-parse --abbrev-ref HEAD > ./src/repo-info
45 @CHARM_LAYERS_DIR=${CHARM_LAYERS_DIR} CHARM_INTERFACES_DIR=${CHARM_INTERFACES_DIR} \53 @charmcraft -v pack ${BUILD_ARGS}
46 TERM=linux CHARM_BUILD_DIR=${CHARM_BUILD_DIR} charm build src/54 @bash -c ./rename.sh
55 @mkdir -p ${CHARM_BUILD_DIR}/${CHARM_NAME}
56 @unzip ${PROJECTPATH}/${CHARM_NAME}.charm -d ${CHARM_BUILD_DIR}/${CHARM_NAME}
4757
48release: clean build58release: clean build
49 @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"59 @echo "Charm is built at ${CHARM_BUILD_DIR}/${CHARM_NAME}"
5060
51black:
52 @echo "Blacken"
53 @cd src && tox -e black
54
55lint:61lint:
56 @echo "Running lint checks"62 @echo "Running lint checks"
57 @cd src && tox -e lint63 @cd src && tox -e lint
5864
65black:
66 @echo "Reformat files with black"
67 @cd src && tox -e black
68
59proof: build69proof: build
60 @echo "Running charm proof"70 @echo "Running charm proof"
61 @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}71 @charm proof ${CHARM_BUILD_DIR}/${CHARM_NAME}
@@ -66,10 +76,10 @@ unittests:
6676
67functional: build77functional: build
68 @echo "Executing functional tests in ${CHARM_BUILD_DIR}"78 @echo "Executing functional tests in ${CHARM_BUILD_DIR}"
69 @cd src && CHARM_BUILD_DIR=${CHARM_BUILD_DIR} tox -e func79 @cd src && CHARM_LOCATION=${PROJECTPATH} tox -e func
7080
71test: lint proof unittests functional81test: lint proof unittests functional
72 @echo "Tests completed for charm ${CHARM_NAME}."82 @echo "Tests completed for charm ${CHARM_NAME}."
7383
74# The targets below don't depend on a file84# The targets below don't depend on a file
75.PHONY: help submodules submodules-update clean build release lint proof unittests functional test85.PHONY: help submodules submodules-update clean build release lint black proof unittests functional test
diff --git a/charmcraft.yaml b/charmcraft.yaml
76new file mode 10064486new file mode 100644
index 0000000..7d9c002
--- /dev/null
+++ b/charmcraft.yaml
@@ -0,0 +1,20 @@
1type: charm
2parts:
3 charm:
4 source: src
5 plugin: reactive
6 build-snaps: [charm]
7bases:
8 - build-on:
9 - name: ubuntu
10 channel: "20.04"
11 architectures: ["amd64"]
12 run-on:
13 - name: ubuntu
14 channel: "20.04"
15 architectures:
16 - amd64
17 - name: ubuntu
18 channel: "18.04"
19 architectures:
20 - amd64
diff --git a/metadata.yaml b/metadata.yaml
0new file mode 12000021new file mode 120000
index 0000000..0768683
--- /dev/null
+++ b/metadata.yaml
@@ -0,0 +1 @@
1src/metadata.yaml
0\ No newline at end of file2\ No newline at end of file
diff --git a/rename.sh b/rename.sh
1new file mode 1007553new file mode 100755
index 0000000..bc8697f
--- /dev/null
+++ b/rename.sh
@@ -0,0 +1,13 @@
1#!/bin/bash
2charm=$(grep -E "^name:" src/metadata.yaml | awk '{print $2}')
3echo "renaming ${charm}_*.charm to ${charm}.charm"
4echo -n "pwd: "
5pwd
6ls -al
7echo "Removing previous charm if it exists"
8if [[ -e "${charm}.charm" ]];
9then
10 rm "${charm}.charm"
11fi
12echo "Renaming charm here."
13mv ${charm}_*.charm ${charm}.charm
diff --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
index 1d2b823..45065bc 100644
--- a/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
+++ b/src/tests/functional/tests/bundles/overlays/local-charm-overlay.yaml.j2
@@ -1,3 +1,3 @@
1applications:1applications:
2 prometheus-ceph-exporter:2 {{ charm_name }}:
3 charm: "{{ CHARM_BUILD_DIR }}/{{ charm_name }}"3 charm: "{{ CHARM_LOCATION }}/{{ charm_name }}.charm"
diff --git a/src/tox.ini b/src/tox.ini
index 40df104..af3fcb8 100644
--- a/src/tox.ini
+++ b/src/tox.ini
@@ -10,7 +10,8 @@ setenv =
10passenv =10passenv =
11 HOME11 HOME
12 PATH12 PATH
13 CHARM_BUILD_DIR13 CHARM_*
14 OS_*
14 PYTEST_KEEP_MODEL15 PYTEST_KEEP_MODEL
15 PYTEST_CLOUD_NAME16 PYTEST_CLOUD_NAME
16 PYTEST_CLOUD_REGION17 PYTEST_CLOUD_REGION
@@ -61,5 +62,5 @@ deps = -r{toxinidir}/tests/requirements.txt
6162
62[testenv:func]63[testenv:func]
63changedir = {toxinidir}/tests/functional64changedir = {toxinidir}/tests/functional
64commands = functest-run-suite {posargs}65commands = functest-run-suite --keep-faulty-model {posargs}
65deps = -r{toxinidir}/tests/requirements.txt66deps = -r{toxinidir}/tests/requirements.txt

Subscribers

People subscribed via source and target branches

to all changes: