all: | all: | ||||
@echo "make install - Install into DESTDIR" | @echo "make install - Install into DESTDIR" | ||||
@echo "make lint - Run lint tests" | |||||
@echo "make test - Run tests" | @echo "make test - Run tests" | ||||
@echo "make kitchen - Run Kitchen CI tests (create, converge, verify)" | @echo "make kitchen - Run Kitchen CI tests (create, converge, verify)" | ||||
@echo "make clean - Cleanup after tests run" | @echo "make clean - Cleanup after tests run" | ||||
@echo "make release-major - Generate new major release" | @echo "make release-major - Generate new major release" | ||||
@echo "make release-minor - Generate new minor release" | @echo "make release-minor - Generate new minor release" | ||||
@echo "make changelog - Show changes since last release" | @echo "make changelog - Show changes since last release" | ||||
@echo "make test-model-validate - Run salt jsonschema validation" | |||||
install: | install: | ||||
# Formula | # Formula | ||||
[ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) | [ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) | ||||
cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) | cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) | ||||
lint: | |||||
[ ! -d tests ] || (cd tests; ./run_tests.sh lint) | |||||
test: | test: | ||||
[ ! -d tests ] || (cd tests; ./run_tests.sh) | [ ! -d tests ] || (cd tests; ./run_tests.sh) | ||||
test-model-validate: | |||||
# TODO make it actually fail | |||||
[ ! -d $(FORMULANAME)/schemas/ ] || (cd tests; ./run_tests.sh model-validate) | |||||
release-major: check-changes | release-major: check-changes | ||||
@echo "Current version is $(VERSION), new version is $(NEW_MAJOR_VERSION)" | @echo "Current version is $(VERSION), new version is $(NEW_MAJOR_VERSION)" | ||||
@[ $(VERSION_MAJOR) != $(NEW_MAJOR_VERSION) ] || (echo "Major version $(NEW_MAJOR_VERSION) already released, nothing to do. Do you want release-minor?" && exit 1) | @[ $(VERSION_MAJOR) != $(NEW_MAJOR_VERSION) ] || (echo "Major version $(NEW_MAJOR_VERSION) already released, nothing to do. Do you want release-minor?" && exit 1) | ||||
[ ! -f debian/changelog ] || dch -v $(VERSION_MAJOR).$(NEW_MINOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version" | [ ! -f debian/changelog ] || dch -v $(VERSION_MAJOR).$(NEW_MINOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version" | ||||
make genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION) | make genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION) | ||||
(git add -u; git commit -m "Version $(VERSION_MAJOR).$(NEW_MINOR_VERSION)") | (git add -u; git commit -m "Version $(VERSION_MAJOR).$(NEW_MINOR_VERSION)") | ||||
git tag -s -m $(NEW_MAJOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION) | |||||
git tag -s -m $(VERSION_MAJOR).$(NEW_MINOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION) | |||||
check-changes: | check-changes: | ||||
@git log --pretty=oneline --decorate $(VERSION)..HEAD | grep -Eqc '.*' || (echo "No new changes since version $(VERSION)"; exit 1) | @git log --pretty=oneline --decorate $(VERSION)..HEAD | grep -Eqc '.*' || (echo "No new changes since version $(VERSION)"; exit 1) |
home_assistant: | home_assistant: | ||||
server: | server: | ||||
enabled: true | enabled: true | ||||
bind: | |||||
address: 0.0.0.0 | |||||
port: 8123 |
### | ### | ||||
# Script requirments: | # Script requirments: | ||||
# apt-get install -y python-yaml virtualenv git | |||||
#apt-get install -y python-yaml virtualenv git | |||||
set -e | set -e | ||||
[ -n "$DEBUG" ] && set -x | [ -n "$DEBUG" ] && set -x | ||||
setup_virtualenv() { | setup_virtualenv() { | ||||
log_info "Setting up Python virtualenv" | log_info "Setting up Python virtualenv" | ||||
dependency_check virtualenv | |||||
virtualenv $VENV_DIR | virtualenv $VENV_DIR | ||||
source ${VENV_DIR}/bin/activate | source ${VENV_DIR}/bin/activate | ||||
pip install salt${PIP_SALT_VERSION} | pip install salt${PIP_SALT_VERSION} | ||||
pip install jsonschema | |||||
if [[ -f ${CURDIR}/pip_requirements.txt ]]; then | if [[ -f ${CURDIR}/pip_requirements.txt ]]; then | ||||
pip install -r ${CURDIR}/pip_requirements.txt | pip install -r ${CURDIR}/pip_requirements.txt | ||||
fi | fi | ||||
dep_root="${DEPSDIR}/$(basename $dep_source .git)" | dep_root="${DEPSDIR}/$(basename $dep_source .git)" | ||||
dep_metadata="${dep_root}/metadata.yml" | dep_metadata="${dep_root}/metadata.yml" | ||||
dependency_check git | |||||
[ -d $dep_root ] && { log_info "Dependency $dep_name already fetched"; return 0; } | [ -d $dep_root ] && { log_info "Dependency $dep_name already fetched"; return 0; } | ||||
log_info "Fetching dependency $dep_name" | log_info "Fetching dependency $dep_name" | ||||
} | } | ||||
run_model_validate(){ | run_model_validate(){ | ||||
[[ -d ${SCHEMARDIR} ]] || { log_err "${SCHEMARDIR} not found!"; return 1; } | |||||
# model validator require py modules | |||||
fetch_dependency "salt:https://github.com/salt-formulas/salt-formula-salt" | |||||
link_modules | |||||
# Rendered Example: | |||||
# salt-call --local -c /test1/maas/tests/build/salt --id=maas_cluster modelschema.model_validate maas cluster | |||||
for role in ${SCHEMARDIR}/*.yaml; do | |||||
state_name=$(basename "${role%*.yaml}") | |||||
minion_id="${state_name}" | |||||
# in case debug-reruns, usefull to make cleanup | |||||
[ -n "$DEBUG" ] && { salt_run saltutil.clear_cache; salt_run saltutil.refresh_pillar; salt_run saltutil.sync_all; } | |||||
salt_run -m ${DEPSDIR}/salt-formula-salt --id=${minion_id} modelschema.model_validate ${FORMULA_NAME} ${state_name} || { log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1 ; } | |||||
done | |||||
if [ -d ${SCHEMARDIR} ]; then | |||||
# model validator require py modules | |||||
fetch_dependency "salt:https://github.com/salt-formulas/salt-formula-salt" | |||||
link_modules | |||||
# Rendered Example: | |||||
# salt-call --local -c /test1/maas/tests/build/salt --id=maas_cluster modelschema.model_validate maas cluster | |||||
for role in ${SCHEMARDIR}/*.yaml; do | |||||
state_name=$(basename "${role%*.yaml}") | |||||
minion_id="${state_name}" | |||||
# in case debug-reruns, usefull to make cleanup | |||||
[ -n "$DEBUG" ] && { salt_run saltutil.clear_cache; salt_run saltutil.refresh_pillar; salt_run saltutil.sync_all; } | |||||
salt_run -m ${DEPSDIR}/salt-formula-salt --id=${minion_id} modelschema.model_validate ${FORMULA_NAME} ${state_name} || { log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1 ; } | |||||
done | |||||
else | |||||
log_err "${SCHEMARDIR} not found!"; | |||||
fi | |||||
} | |||||
dependency_check() { | |||||
local DEPENDENCY_COMMANDS=$* | |||||
for DEPENDENCY_COMMAND in $DEPENDENCY_COMMANDS; do | |||||
which $DEPENDENCY_COMMAND > /dev/null || ( log_err "Command \"$DEPENDENCY_COMMAND\" can not be found in default path."; exit 1; ) | |||||
done | |||||
} | } | ||||
_atexit() { | _atexit() { | ||||
run | run | ||||
run_model_validate | run_model_validate | ||||
;; | ;; | ||||
esac | |||||
esac |