Deckhand Makefile for CICD

Add Makefile to Deckhand for building charts and running lint checks
against the code base (including charts).

Modeled after Shipyard's Makefile.

Change-Id: I23a9b746369f5765cf4d75e9cb0854b9f5f65972
This commit is contained in:
Felipe Monteiro 2017-10-26 23:18:06 +01:00
parent 2ba761a36c
commit 6ff443de2d
3 changed files with 111 additions and 0 deletions

4
.gitignore vendored
View File

@ -24,6 +24,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
*.tgz
# PyInstaller
# Usually these files are written by a python script from a template
@ -102,3 +103,6 @@ ENV/
# mypy
.mypy_cache/
# makefile build/lint artifacts
/charts/deckhand/*

55
Makefile Normal file
View File

@ -0,0 +1,55 @@
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
DECKHAND_IMAGE_NAME ?= deckhand
IMAGE_PREFIX ?= attcomdev
IMAGE_TAG ?= latest
HELM ?= helm
# Build Deckhand Docker image for this project
.PHONY: images
images: build_deckhand
# Create tgz of the chart
.PHONY: charts
charts: clean
$(HELM) package charts/deckhand
# Perform linting
.PHONY: lint
lint: pep8 helm_lint
# Dry run templating of chart
.PHONY: dry-run
dry-run: clean
tools/helm_tk.sh $(HELM)
# Make targets intended for use by the primary targets above.
.PHONY: build_deckhand
build_deckhand:
docker build -t $(IMAGE_PREFIX)/$(DECKHAND_IMAGE_NAME):$(IMAGE_TAG) images/deckhand/
.PHONY: clean
clean:
rm -rf build
helm delete helm-template
.PHONY: pep8
pep8:
tox -e pep8
.PHONY: helm_lint
helm_lint: clean
tools/helm_tk.sh $(HELM)
$(HELM) lint charts/deckhand

52
tools/helm_tk.sh Executable file
View File

@ -0,0 +1,52 @@
#!/bin/bash
# Copyright 2017 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Script to setup helm-toolkit and helm dep up the deckhand chart
#
HELM=$1
set -x
function helm_serve {
if [[ -d "$HOME/.helm" ]]; then
echo ".helm directory found"
else
${HELM} init --client-only
fi
if [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; then
${HELM} serve & > /dev/null
while [[ -z $(curl -s 127.0.0.1:8879 | grep 'Helm Repository') ]]; do
sleep 1
echo "Waiting for Helm Repository"
done
else
echo "Helm serve already running"
fi
if ${HELM} repo list | grep -q "^stable" ; then
${HELM} repo remove stable
fi
${HELM} repo add local http://localhost:8879/charts
}
mkdir -p build
cd build
git clone --depth 1 https://git.openstack.org/openstack/openstack-helm.git || true
cd openstack-helm
git pull
helm_serve
make helm-toolkit
${HELM} dep up ../../charts/deckhand