Skip to content

Commit

Permalink
Validate CI config (2600hz#5402)
Browse files Browse the repository at this point in the history
* move ci to own include mk file

* use order-only prereqs

* remove old phony targets

* fix some specs and arg order
  • Loading branch information
jamesaimonetti authored and lazedo committed Jan 8, 2019
1 parent c60c173 commit 0646ac3
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 64 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ compile_commands.json
/make/core.mk
/make/cover.mk
/make/.deps.mk.*
/make/circleci
/core/*/cover/*.html
/applications/*/cover/*.html

Expand Down
66 changes: 8 additions & 58 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ FMT = $(ROOT)/make/erlang-formatter/fmt.sh
TAGS = $(ROOT)/TAGS
ERLANG_MK_COMMIT = d30dda39b08e6ed9e12b44533889eaf90aba86de

## list files changed for more focused checks
CHANGED := $(shell git --no-pager diff --name-only HEAD origin/master -- applications core scripts)
CHANGED_SWAGGER := $(shell git --no-pager diff --name-only HEAD origin/master -- applications/crossbar/priv/api/swagger.json)

# You can override this when calling make, e.g. make JOBS=1
# to prevent parallel builds, or make JOBS="8".
JOBS ?= 1
Expand All @@ -14,7 +18,7 @@ KAZOODIRS = core/Makefile applications/Makefile
.PHONY: $(KAZOODIRS) kazoo deps core apps \
build-release build-ci-release tar-release release read-release-cookie \
bump-copyright apis validate-swagger sdks coverage-report fs-headers docs validate-schemas \
circle circle-pre circle-fmt circle-codechecks circle-build circle-docs circle-schemas circle-dialyze circle-release circle-unstaged \
circle \
clean clean-test clean-release \
dialyze dialyze-it dialyze-apps dialyze-core dialyze-kazoo dialyze-hard dialyze-changed \
elvis install ci diff \
Expand Down Expand Up @@ -293,61 +297,7 @@ sdks:
validate-schemas:
@$(ROOT)/scripts/validate-schemas.sh $(ROOT)/applications/crossbar/priv/couchdb/schemas

CHANGED := $(shell git --no-pager diff --name-only HEAD origin/master -- applications core scripts)
CHANGED_SWAGGER := $(shell git --no-pager diff --name-only HEAD origin/master -- applications/crossbar/priv/api/swagger.json)
PIP2 := $(shell { command -v pip || command -v pip2; } 2>/dev/null)

circle-pre:
ifneq ($(PIP2),)
## needs root access
@echo $(CHANGED)
@$(PIP2) install --user --upgrade pip
@$(PIP2) install --user PyYAML mkdocs pyembed-markdown jsonschema
else
$(error "pip/pip2 is not available, please install python2-pip package")
endif

circle-docs:
@./scripts/state-of-docs.sh || true
@$(ROOT)/scripts/state-of-edoc.escript
@$(MAKE) apis
@$(MAKE) docs

circle-codechecks:
@./scripts/code_checks.bash $(CHANGED)
@$(MAKE) code_checks
@$(MAKE) app_applications
@./scripts/validate-js.sh $(find {core,applications}/*/priv/**/* -name *.json)

circle-fmt:
@$(MAKE) fmt
@$(MAKE) elvis

circle-build:
@$(MAKE) clean clean-deps deps kazoo xref sup_completion

circle-schemas:
@$(MAKE) validate-schemas
@$(if $(CHANGED_SWAGGER), $(MAKE) circle-swagger)

circle-swagger:
@-$(MAKE) validate-swagger

circle-unstaged:
echo Unstaged changes!
git status --porcelain
git --no-pager diff
echo 'Maybe try `make apis` and see if that fixes anything ;)'
exit 1

circle-dialyze: build-plt
circle-dialyze:
@TO_DIALYZE="$(CHANGED)" $(MAKE) dialyze-it

circle-release:
@$(MAKE) build-ci-release

circle: circle-pre circle-fmt circle-build circle-codechecks circle-docs circle-schemas circle-dialyze circle-release
@$(if $(git status --porcelain | wc -l), $(MAKE) circle-unstaged)

include make/splchk.mk
include make/ci.mk

circle: ci
3 changes: 1 addition & 2 deletions core/kazoo_documents/src/kzd_accounts.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1082,13 +1082,12 @@ bill_early_task_timestamp(Doc) ->

-spec set_bill_early_task_timestamp(doc(), non_neg_integer()) -> doc().
set_bill_early_task_timestamp(Doc, Timestamp) ->
kz_json:set_value(path_bill_early_task_timestamp(), Doc, Timestamp).
kz_json:set_value(path_bill_early_task_timestamp(), Timestamp, Doc).

-spec path_bill_early_task_timestamp() -> kz_json:path().
path_bill_early_task_timestamp() ->
[<<"notifications">>, <<"low_balance">>, <<"bill_early_task_timestamp">>].


%%------------------------------------------------------------------------------
%% @doc
%% @end
Expand Down
8 changes: 4 additions & 4 deletions core/kazoo_media/src/kz_media_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -372,11 +372,11 @@ max_recording_time_limit() ->
%% Port = kz_couch_connections:get_port(),
%% base_url(Host, Port).

-spec base_url(kz_term:text(), kz_term:text()) -> kz_term:ne_binary().
-spec base_url(kz_term:text(), inet:port_number() | kz_term:text()) -> kz_term:ne_binary().
base_url(Host, Port) ->
base_url(Host, Port, 'proxy_playback').

-spec base_url(kz_term:text(), kz_term:text(), atom()) -> kz_term:ne_binary().
-spec base_url(kz_term:text(), inet:port_number() | kz_term:text(), atom()) -> kz_term:ne_binary().
base_url(Host, Port, 'proxy_playback') ->
case ?AUTH_PLAYBACK of
'false' -> build_url(Host, Port, <<>>);
Expand All @@ -388,11 +388,11 @@ base_url(Host, Port, 'proxy_store') ->
'true' -> build_url(Host, Port, list_to_binary([?AUTH_USERNAME, ":", ?AUTH_PASSWORD, "@"]))
end.

-spec build_url(kz_term:ne_binary(), pos_integer(), binary()) -> kz_term:ne_binary().
-spec build_url(kz_term:ne_binary(), inet:port_number(), binary()) -> kz_term:ne_binary().
build_url(H, P, Creds) ->
build_url(proxy_scheme(), H, P, Creds).

-spec build_url(proxy_scheme(), kz_term:ne_binary(), pos_integer(), binary()) -> kz_term:ne_binary().
-spec build_url(proxy_scheme(), kz_term:ne_binary(), inet:port_number(), binary()) -> kz_term:ne_binary().
build_url('https', H, 443, Creds) ->
list_to_binary(["https://", Creds, kz_term:to_binary(H)]);
build_url('https', H, P, Creds) ->
Expand Down
74 changes: 74 additions & 0 deletions make/ci.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
.PHONY: ci ci-config ci-steps ci-pre ci-fmt ci-build ci-codechecks ci-docs ci-schemas ci-dialyze ci-release

PIP2 := $(shell { command -v pip || command -v pip2; } 2>/dev/null)
CI_DIR := $(CURDIR)/make
CI_VALIDATOR := $(CI_DIR)/circleci
CI_CONFIG := $(CURDIR)/.circleci/config.yml

ci: ci-config ci-steps


ci-config: $(CI_VALIDATOR)
@$(CI_VALIDATOR) config validate -c $(CI_CONFIG) || (echo "$(CI_CONFIG):1:"; exit 1)

# | $(CI_DIR): see https://www.gnu.org/software/make/manual/make.html#Prerequisite-Types
# order-only-prereq
# otherwise cURL will be run everytime
$(CI_VALIDATOR): | $(CI_DIR)
@curl -fLSs https://circle.ci/cli | DESTDIR="$(CI_DIR)" bash

$(CI_DIR):
@mkdir $(CI_DIR)

ci-steps: ci-pre ci-fmt ci-build ci-codechecks ci-docs ci-schemas ci-dialyze ci-release
@$(if $(git status --porcelain | wc -l), $(MAKE) ci-unstaged)

ci-pre:
ifneq ($(PIP2),)
## needs root access
@echo $(CHANGED)
@$(PIP2) install --user --upgrade pip
@$(PIP2) install --user PyYAML mkdocs pyembed-markdown jsonschema
else
$(error "pip/pip2 is not available, please install python2-pip package")
endif

ci-docs:
@./scripts/state-of-docs.sh || true
@$(ROOT)/scripts/state-of-edoc.escript
@$(MAKE) apis
@$(MAKE) docs

ci-codechecks:
@./scripts/code_checks.bash $(CHANGED)
@$(MAKE) code_checks
@$(MAKE) app_applications
@./scripts/validate-js.sh $(find {core,applications}/*/priv/**/* -name *.json)

ci-fmt:
@$(MAKE) fmt
@$(MAKE) elvis

ci-build:
@$(MAKE) clean clean-deps deps kazoo xref sup_completion

ci-schemas:
@$(MAKE) validate-schemas
@$(if $(CHANGED_SWAGGER), $(MAKE) ci-swagger)

ci-swagger:
@-$(MAKE) validate-swagger

ci-unstaged:
echo Unstaged changes!
git status --porcelain
git --no-pager diff
echo 'Maybe try `make apis` and see if that fixes anything ;)'
exit 1

ci-dialyze: build-plt
ci-dialyze:
@TO_DIALYZE="$(CHANGED)" $(MAKE) dialyze-it

ci-release:
@$(MAKE) build-ci-release

0 comments on commit 0646ac3

Please sign in to comment.