<commit_before>.PHONY: test spec lint_yaml lint_terraform lint_shellcheck set_aws_count set_auto_trigger disable_auto_delete check-env-vars dev ci stage prod

SHELLCHECK=shellcheck
YAMLLINT=yamllint

check-env-vars:
	$(if ${DEPLOY_ENV},,$(error Must pass DEPLOY_ENV=<name>))

test: spec lint_yaml lint_terraform lint_shellcheck

spec:
	cd manifests/bosh-manifest &&\
		bundle exec rspec
	cd manifests/cf-manifest &&\
		bundle exec rspec

lint_yaml:
	$(YAMLLINT) -c yamllint.yml .

lint_terraform:
	find terraform -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -n 1 -t terraform graph > /dev/null

lint_shellcheck:
	find . -name '*.sh' -print0 | xargs -0 $(SHELLCHECK)

dev: check-env-vars set_aws_account_dev deploy_pipelines

ci: check-env-vars set_aws_account_ci set_auto_trigger disable_auto_delete deploy_pipelines

stage: check-env-vars set_aws_account_stage disable_auto_delete set_auto_trigger deploy_pipelines

prod: check-env-vars set_aws_account_prod disable_auto_delete set_auto_trigger deploy_pipelines

set_aws_account_dev:
	$(eval export AWS_ACCOUNT=dev)

set_aws_account_ci:
	$(eval export AWS_ACCOUNT=ci)

set_aws_account_stage:
	$(eval export AWS_ACCOUNT=stage)

set_aws_account_prod:
	$(eval export AWS_ACCOUNT=prod)

set_auto_trigger:
	$(eval export ENABLE_AUTO_DEPLOY=true)

disable_auto_delete:
	$(eval export DISABLE_AUTODELETE=1)

deploy_pipelines:
	concourse/scripts/pipelines-microbosh.sh
	concourse/scripts/pipelines-cloudfoundry.sh<commit_msg>Add self documenting help for Makefile<commit_after>.PHONY: help test spec lint_yaml lint_terraform lint_shellcheck set_aws_count set_auto_trigger disable_auto_delete check-env-vars dev ci stage prod

.DEFAULT_GOAL := help

help:
	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

SHELLCHECK=shellcheck
YAMLLINT=yamllint

check-env-vars:
	$(if ${DEPLOY_ENV},,$(error Must pass DEPLOY_ENV=<name>))

test: spec lint_yaml lint_terraform lint_shellcheck ## Run linting tests

spec:
	cd manifests/bosh-manifest &&\
		bundle exec rspec
	cd manifests/cf-manifest &&\
		bundle exec rspec

lint_yaml:
	$(YAMLLINT) -c yamllint.yml .

lint_terraform:
	find terraform -mindepth 1 -maxdepth 1 -type d -print0 | xargs -0 -n 1 -t terraform graph > /dev/null

lint_shellcheck:
	find . -name '*.sh' -print0 | xargs -0 $(SHELLCHECK)

dev: check-env-vars set_aws_account_dev deploy_pipelines ## Deploy Pipelines to Dev Environment

ci: check-env-vars set_aws_account_ci set_auto_trigger disable_auto_delete deploy_pipelines  ## Deploy Pipelines to CI Environment

stage: check-env-vars set_aws_account_stage disable_auto_delete set_auto_trigger deploy_pipelines  ## Deploy Pipelines to Staging Environment

prod: check-env-vars set_aws_account_prod disable_auto_delete set_auto_trigger deploy_pipelines  ## Deploy Pipelines to Production Environment

set_aws_account_dev:
	$(eval export AWS_ACCOUNT=dev)

set_aws_account_ci:
	$(eval export AWS_ACCOUNT=ci)

set_aws_account_stage:
	$(eval export AWS_ACCOUNT=stage)

set_aws_account_prod:
	$(eval export AWS_ACCOUNT=prod)

set_auto_trigger:
	$(eval export ENABLE_AUTO_DEPLOY=true)

disable_auto_delete:
	$(eval export DISABLE_AUTODELETE=1)

deploy_pipelines:
	concourse/scripts/pipelines-microbosh.sh
	concourse/scripts/pipelines-cloudfoundry.sh
{'fraction_non_alphanumeric': 0.09409649385675757, 'fraction_numerical': 0.008690440515433023, 'mean_word_length': 5.925311203319502, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4562871', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1233, 'n_words': 278}