<commit_before>KONG_HOME = `pwd`

# Environment variables (default)
export DIR ?= $(KONG_HOME)/config.dev
export KONG_CONF ?= $(DIR)/kong.yaml
export NGINX_CONF ?= $(DIR)/nginx.conf
export DEV_LUA_LIB ?= lua_package_path \"$(KONG_HOME)/src/?.lua\;\;\"\;
# Tests variables
TESTS_DIR ?= $(KONG_HOME)/config.tests
TESTS_KONG_CONF ?= $(TESTS_DIR)/kong.yaml
TESTS_NGINX_CONF ?= $(TESTS_DIR)/nginx.conf

.PHONY: install dev clean reset seed drop test test-integration test-web test-proxy test-all

install:
	@if [[ $EUID -ne 0 ]]; then echo "Please try running this command again as root/Administrator."; exit 1; fi
	@echo "Please wait, this process could take some time.."
	@luarocks make kong-*.rockspec PCRE_LIBDIR=`find / -type f -name "libpcre.so*" -print -quit | xargs dirname` OPENSSL_LIBDIR=`find / -type f -name "libssl.so*" -print -quit | xargs dirname`

dev:
	@mkdir -p $(DIR)
	@sed -e "s@lua_package_path.*;@$(DEV_LUA_LIB)@g" $(KONG_HOME)/config.default/nginx.conf > $(NGINX_CONF)
	@cp $(KONG_HOME)/config.default/kong.yaml $(KONG_CONF)
	@mkdir -p $(TESTS_DIR)
	@sed -e "s@lua_package_path.*;@$(DEV_LUA_LIB)@g" $(KONG_HOME)/config.default/nginx.conf > $(TESTS_NGINX_CONF)
	@cp $(KONG_HOME)/config.default/kong.yaml $(TESTS_KONG_CONF)

clean:
	@rm -rf $(DIR)
	@rm -rf $(TESTS_DIR)

reset:
	@scripts/migrate reset --conf=$(KONG_CONF)

seed:
	@scripts/seed seed --conf=$(KONG_CONF)

drop:
	@scripts/seed drop --conf=$(KONG_CONF)

test:
	@busted spec/unit

run-integration-tests:
	@bin/kong -c $(TESTS_KONG_CONF) migrate
	@bin/kong -c $(TESTS_KONG_CONF) -n $(TESTS_NGINX_CONF) start
	@$(MAKE) seed KONG_CONF=$(TESTS_KONG_CONF)
	@busted $(FOLDER) || (bin/kong stop; make drop KONG_CONF=$(TESTS_KONG_CONF); exit 1)
	@bin/kong stop
	@$(MAKE) reset KONG_CONF=$(TESTS_KONG_CONF)

test-web:
	@$(MAKE) run-integration-tests FOLDER=spec/web

test-proxy:
	@$(MAKE) run-integration-tests FOLDER=spec/proxy

test-all:<commit_msg>makefile<commit_after>KONG_HOME = `pwd`

# Environment variables (default)
export DIR ?= $(KONG_HOME)/config.dev
export KONG_CONF ?= $(DIR)/kong.yaml
export NGINX_CONF ?= $(DIR)/nginx.conf
export DEV_LUA_LIB ?= lua_package_path \"$(KONG_HOME)/src/?.lua\;\;\"\;
# Tests variables
TESTS_DIR ?= $(KONG_HOME)/config.tests
TESTS_KONG_CONF ?= $(TESTS_DIR)/kong.yaml
TESTS_NGINX_CONF ?= $(TESTS_DIR)/nginx.conf

.PHONY: install dev clean reset seed drop test test-integration test-web test-proxy test-all

install:
	@if [[ $EUID -ne 0 ]]; then echo "Please try running this command again as root/Administrator."; exit 1; fi
	@echo "Please wait, this process could take some time.."
	@if [ `uname` == "Darwin" ]; then \
		luarocks make kong-*.rockspec; \
	else \
		luarocks make kong-*.rockspec \
		PCRE_LIBDIR=`find / -type f -name "libpcre.so*" -print -quit | xargs dirname` \
		OPENSSL_LIBDIR=`find / -type f -name "libssl.so*" -print -quit | xargs dirname`; \
	fi

dev:
	@mkdir -p $(DIR)
	@sed -e "s@lua_package_path.*;@$(DEV_LUA_LIB)@g" $(KONG_HOME)/config.default/nginx.conf > $(NGINX_CONF)
	@cp $(KONG_HOME)/config.default/kong.yaml $(KONG_CONF)
	@mkdir -p $(TESTS_DIR)
	@sed -e "s@lua_package_path.*;@$(DEV_LUA_LIB)@g" $(KONG_HOME)/config.default/nginx.conf > $(TESTS_NGINX_CONF)
	@cp $(KONG_HOME)/config.default/kong.yaml $(TESTS_KONG_CONF)

clean:
	@rm -rf $(DIR)
	@rm -rf $(TESTS_DIR)

reset:
	@scripts/migrate reset --conf=$(KONG_CONF)

seed:
	@scripts/seed seed --conf=$(KONG_CONF)

drop:
	@scripts/seed drop --conf=$(KONG_CONF)

test:
	@busted spec/unit

run-integration-tests:
	@bin/kong -c $(TESTS_KONG_CONF) migrate
	@bin/kong -c $(TESTS_KONG_CONF) -n $(TESTS_NGINX_CONF) start
	@while ! [ $(ps aux | grep -c nginx) -gt 1 ]; do sleep 1; done # Wait until nginx starts
	@$(MAKE) seed KONG_CONF=$(TESTS_KONG_CONF)
	@busted $(FOLDER) || (bin/kong stop; make drop KONG_CONF=$(TESTS_KONG_CONF); exit 1)
	@bin/kong stop
	@$(MAKE) reset KONG_CONF=$(TESTS_KONG_CONF)

test-web:
	@$(MAKE) run-integration-tests FOLDER=spec/web

test-proxy:
	@$(MAKE) run-integration-tests FOLDER=spec/proxy

test-all:
{'fraction_non_alphanumeric': 0.16940298507462687, 'fraction_numerical': 0.001990049751243781, 'mean_word_length': 4.7690100430416065, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4896157', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1640, 'n_words': 360}