|
1 | 1 | ROOT_DIR ?= $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) |
| 2 | +ifndef FORCE_CHECK_ALL_FILES |
2 | 3 | CHANGED_FILES := $(shell $(CI_DIR)/utils/git-changes files) |
3 | | -CHANGED_DIRECTORIES := $(shell $(CI_DIR)/utils/git-changes directories) |
4 | 4 | CHANGED_PY := $(shell ${CI_DIR}/utils/git-changes py) |
5 | 5 | CHANGED_YAML := $(shell $(CI_DIR)/utils/git-changes yaml) |
6 | 6 | CHANGED_JSON := $(shell $(CI_DIR)/utils/git-changes json) |
| 7 | +endif |
| 8 | +CHANGED_DIRECTORIES := $(shell $(CI_DIR)/utils/git-changes directories) |
7 | 9 | VIRTUALENV_DIR ?= virtualenv |
8 | 10 | ST2_REPO_PATH ?= /tmp/st2 |
9 | 11 | ST2_REPO_BRANCH ?= master |
@@ -65,54 +67,137 @@ compile: |
65 | 67 | @echo |
66 | 68 | @echo "==================== flake8 ====================" |
67 | 69 | @echo |
68 | | - . $(VIRTUALENV_DIR)/bin/activate; if [ ! "${CHANGED_PY}" ]; then echo "No files have changed, skipping run..."; fi; for file in ${CHANGED_PY}; do if [ -n "$$file" ]; then flake8 --config=$(CI_DIR)/lint-configs/python/.flake8 $$file || exit 1; fi; done |
| 70 | + . $(VIRTUALENV_DIR)/bin/activate; \ |
| 71 | + if [ "$${FORCE_CHECK_ALL_FILES}" ]; then \ |
| 72 | + find ./* -name "*.py" | while read py_file; do \ |
| 73 | + flake8 --config=$(CI_DIR)/lint-configs/python/.flake8 $$py_file || exit 1; \ |
| 74 | + done; \ |
| 75 | + elif [ -n "${CHANGED_PY}" ]; then \ |
| 76 | + for file in ${CHANGED_PY}; do \ |
| 77 | + if [ -n "$$file" ]; then \ |
| 78 | + flake8 --config=$(CI_DIR)/lint-configs/python/.flake8 $$file || exit 1; \ |
| 79 | + fi; \ |
| 80 | + done; \ |
| 81 | + else \ |
| 82 | + echo "No files have changed, skipping run..."; \ |
| 83 | + fi; |
69 | 84 |
|
70 | 85 | .PHONY: .pylint |
71 | 86 | .pylint: |
72 | 87 | @echo |
73 | 88 | @echo "==================== pylint ====================" |
74 | 89 | @echo |
75 | | - . $(VIRTUALENV_DIR)/bin/activate; if [ ! "${CHANGED_PY}" ]; then echo "No files have changed, skipping run..."; else (REQUIREMENTS_DIR=$(CI_DIR)/.circle/ CONFIG_DIR=$(CI_DIR)/lint-configs/ st2-check-pylint-pack $(ROOT_DIR) || exit 1); fi; |
| 90 | + . $(VIRTUALENV_DIR)/bin/activate; \ |
| 91 | + if [ "$${FORCE_CHECK_ALL_FILES}" ] || [ -n "${CHANGED_PY}" ]; then \ |
| 92 | + REQUIREMENTS_DIR=$(CI_DIR)/.circle/ \ |
| 93 | + CONFIG_DIR=$(CI_DIR)/lint-configs/ \ |
| 94 | + st2-check-pylint-pack $(ROOT_DIR) || exit 1; \ |
| 95 | + else \ |
| 96 | + echo "No files have changed, skipping run..."; \ |
| 97 | + fi; |
76 | 98 |
|
77 | 99 | .PHONY: .configs-check |
78 | 100 | .configs-check: |
79 | 101 | @echo |
80 | 102 | @echo "==================== configs-check ====================" |
81 | 103 | @echo |
82 | | - . $(VIRTUALENV_DIR)/bin/activate; if [ ! "${CHANGED_YAML}" ]; then echo "No files have changed, skipping run..."; fi; for file in $(CHANGED_YAML); do if [ -n "$$file" ]; then st2-check-validate-yaml-file $$file || exit 1 ; fi; done |
83 | | - . $(VIRTUALENV_DIR)/bin/activate; if [ ! "${CHANGED_JSON}" ]; then echo "No files have changed, skipping run..."; fi; for file in $(CHANGED_JSON); do if [ -n "$$file" ]; then st2-check-validate-json-file $$file || exit 1 ; fi; done |
| 104 | + @# The number of changed files in the AWS pack exceeds the limits of Bash, |
| 105 | + @# leading to CI failures like this: |
| 106 | + @# https://circleci.com/gh/StackStorm-Exchange/stackstorm-aws/320 |
| 107 | + @# Instead of passing the entire list into a Bash for loop, we convert the |
| 108 | + @# make variable to a Bash string, convert that to a Bash array, and then |
| 109 | + @# iterate through each element of the array |
| 110 | + . $(VIRTUALENV_DIR)/bin/activate; \ |
| 111 | + if [ "$${FORCE_CHECK_ALL_FILES}" = "true" ]; then \ |
| 112 | + find $(CI_DIR)/* -name "*.yaml" -o -name "*.yml" | while read yaml_file; do \ |
| 113 | + st2-check-validate-yaml-file "$$yaml_file" || exit 1 ; \ |
| 114 | + done; \ |
| 115 | + elif [ -n "${CHANGED_YAML}" ]; then \ |
| 116 | + for file in $(CHANGED_YAML); do \ |
| 117 | + if [ -n "$$file" ]; then \ |
| 118 | + st2-check-validate-yaml-file $$file || exit 1 ; \ |
| 119 | + fi; \ |
| 120 | + done; \ |
| 121 | + else \ |
| 122 | + echo "No files have changed, skipping run..."; \ |
| 123 | + fi |
| 124 | + @# |
| 125 | + . $(VIRTUALENV_DIR)/bin/activate; \ |
| 126 | + if [ "$${FORCE_CHECK_ALL_FILES}" = "true" ]; then \ |
| 127 | + find $(CI_DIR)/* -name "*.json" | while read json_file; do \ |
| 128 | + st2-check-validate-json-file "$$json_file" || exit 1 ; \ |
| 129 | + done; \ |
| 130 | + elif [ -n "${CHANGED_JSON}" ]; then \ |
| 131 | + for file in $(CHANGED_JSON); do \ |
| 132 | + if [ -n "$$file" ]; then \ |
| 133 | + echo "file: $$file"; \ |
| 134 | + st2-check-validate-json-file $$file || exit 1 ; \ |
| 135 | + fi; \ |
| 136 | + done; \ |
| 137 | + else \ |
| 138 | + echo "No files have changed, skipping run..."; \ |
| 139 | + fi |
| 140 | + @# |
84 | 141 | @echo |
85 | 142 | @echo "==================== example config check ====================" |
86 | 143 | @echo |
87 | | - . $(VIRTUALENV_DIR)/bin/activate; if [ ! "${CHANGED_FILES}" ]; then echo "No files have changed, skipping run..."; else st2-check-validate-pack-example-config /tmp/packs/$(PACK_NAME) || exit 1; fi; |
| 144 | + . $(VIRTUALENV_DIR)/bin/activate; \ |
| 145 | + if [ "$${FORCE_CHECK_ALL_FILES}" = "true" ]; then \ |
| 146 | + find ./* | while read file; do \ |
| 147 | + st2-check-validate-pack-example-config $$file || exit 1; \ |
| 148 | + done; \ |
| 149 | + elif [ -n "${CHANGED_FILES}" ]; then \ |
| 150 | + st2-check-validate-pack-example-config /tmp/packs/$(PACK_NAME) || exit 1; \ |
| 151 | + else \ |
| 152 | + echo "No files have changed, skipping run..."; \ |
| 153 | + fi; |
88 | 154 |
|
89 | 155 | .PHONY: .metadata-check |
90 | 156 | .metadata-check: |
91 | 157 | @echo |
92 | 158 | @echo "==================== metadata-check ====================" |
93 | 159 | @echo |
94 | | - . $(VIRTUALENV_DIR)/bin/activate; if [ ! "${CHANGED_YAML}" ]; then echo "No files have changed, skipping run..."; else (st2-check-validate-pack-metadata-exists $(ROOT_DIR) || exit 1); fi; |
| 160 | + . $(VIRTUALENV_DIR)/bin/activate; \ |
| 161 | + if [ "$${FORCE_CHECK_ALL_FILES}" = "true" ] || [ -n "${CHANGED_YAML}" ]; then \ |
| 162 | + st2-check-validate-pack-metadata-exists $(ROOT_DIR) || exit 1; \ |
| 163 | + else \ |
| 164 | + echo "No files have changed, skipping run..."; \ |
| 165 | + fi; |
95 | 166 |
|
96 | 167 | .PHONY: .packs-resource-register |
97 | 168 | .packs-resource-register: |
98 | 169 | @echo |
99 | 170 | @echo "==================== packs-resource-register ====================" |
100 | 171 | @echo |
101 | | - . $(VIRTUALENV_DIR)/bin/activate; if [ ! "${CHANGED_FILES}" ]; then echo "No files have changed, skipping run..."; else st2-check-register-pack-resources /tmp/packs/$(PACK_NAME) || exit 1; fi; |
| 172 | + . $(VIRTUALENV_DIR)/bin/activate; \ |
| 173 | + if [ ! "${CHANGED_FILES}" ]; then \ |
| 174 | + echo "No files have changed, skipping run..."; \ |
| 175 | + else \ |
| 176 | + st2-check-register-pack-resources /tmp/packs/$(PACK_NAME) || exit 1; \ |
| 177 | + fi; |
102 | 178 |
|
103 | 179 | .PHONY: .packs-tests |
104 | 180 | .packs-tests: |
105 | 181 | @echo |
106 | 182 | @echo "==================== packs-tests ====================" |
107 | 183 | @echo |
108 | | - . $(VIRTUALENV_DIR)/bin/activate; if [ ! "${CHANGED_FILES}" ]; then echo "No files have changed, skipping run..."; else ($(ST2_REPO_PATH)/st2common/bin/st2-run-pack-tests -c -t -x -j -p $(ROOT_DIR) || exit 1); fi; |
| 184 | + . $(VIRTUALENV_DIR)/bin/activate; \ |
| 185 | + if [ ! "${CHANGED_FILES}" ]; then \ |
| 186 | + echo "No files have changed, skipping run..."; \ |
| 187 | + else \ |
| 188 | + $(ST2_REPO_PATH)/st2common/bin/st2-run-pack-tests -c -t -x -j -p $(ROOT_DIR) || exit 1; \ |
| 189 | + fi; |
109 | 190 |
|
110 | 191 | .PHONY: .packs-missing-tests |
111 | 192 | .packs-missing-tests: |
112 | 193 | @echo |
113 | 194 | @echo "==================== pack-missing-tests ====================" |
114 | 195 | @echo |
115 | | - if [ ! "${CHANGED_FILES}" ]; then echo "No files have changed, skipping run..."; else (st2-check-print-pack-tests-coverage $(ROOT_DIR) || exit 1); fi; |
| 196 | + if [ ! "${CHANGED_FILES}" ]; then \ |
| 197 | + echo "No files have changed, skipping run..."; \ |
| 198 | + else \ |
| 199 | + st2-check-print-pack-tests-coverage $(ROOT_DIR) || exit 1; \ |
| 200 | + fi; |
116 | 201 |
|
117 | 202 | .PHONY: .clone_st2_repo |
118 | 203 | .clone_st2_repo: /tmp/st2 |
|
0 commit comments