EXTENSION = anon EXTENSION_VERSION=$(shell grep default_version $(EXTENSION).control | sed -e "s/default_version[[:space:]]*=[[:space:]]*'\([^']*\)'/\1/") DATA = anon/* REGRESS = load random partial masking MODULEDIR=extension/anon REGRESS_OPTS = --inputdir=tests .PHONY: extension extension: mkdir -p anon cp anon.sql anon/anon--$(EXTENSION_VERSION).sql cp data/default/* anon/ PG_DUMP?=docker exec postgresqlanonymizer_PostgreSQL_1 pg_dump -U postgres --insert --no-owner SED1=sed 's/public.//' SED2=sed 's/SELECT.*search_path.*//' SED3=sed 's/^SET idle_in_transaction_session_timeout.*//' SED4=sed 's/^SET row_security.*//' sql/tables/%.sql: $(PG_DUMP) --table $* | $(SED1) | $(SED2) | $(SED3) | $(SED4) > $@ PSQL?=PGPASSWORD=CHANGEME psql -U postgres -h 0.0.0.0 -p54322 PGRGRSS=docker exec postgresqlanonymizer_PostgreSQL_1 /usr/lib/postgresql/10/lib/pgxs/src/test/regress/pg_regress --outputdir=tests/ --inputdir=./ --bindir='/usr/lib/postgresql/10/bin' --inputdir=tests --dbname=contrib_regression --user=postgres unit ## ## Docker ## docker_image: Dockerfile docker build -t registry.gitlab.com/daamien/postgresql_anonymizer . docker_push: docker push registry.gitlab.com/daamien/postgresql_anonymizer docker_bash: docker exec -it postgresqlanonymizer_PostgreSQL_1 bash COMPOSE=docker-compose docker_init: $(COMPOSE) down $(COMPOSE) up -d @echo "The Postgres server may take a few seconds to start. Please wait." .PHONY: expected expected : tests/expected/unit.out tests/expected/unit.out: $(PGRGRSS) cp tests/results/unit.out tests/expected/unit.out ## ## Load data from CSV files into SQL tables ## .PHONY: load load: $(PSQL) -f data/load.sql ## ## Demo & Tests ## .PHONY: demo_masking demo_perf demo_random demo_partial demo_masking: demo/masking.sql demo_perf: demo/perf.sql demo_random: demo/random.sql demo_partial: demo/partial.sql demo/%.sql: $(PSQL) -c 'CREATE DATABASE demo;' $(PSQL) --echo-all demo -f $@ $(PSQL) -c 'DROP DATABASE demo;' tests/sql/%.sql: $(PSQL) -f $@ ## ## CI ## .PHONY: ci_local ci_local: gitlab-ci-multi-runner exec docker make ## ## PGXN ## ZIPBALL:=$(EXTENSION)-$(EXTENSION_VERSION).zip .PHONY: pgxn $(ZIPBALL): pgxn pgxn: mkdir -p _pgxn # required by CI : https://gitlab.com/gitlab-com/support-forum/issues/1351 git clone --bare https://gitlab.com/daamien/postgresql_anonymizer.git git -C postgresql_anonymizer.git archive --format zip --prefix=$(EXTENSION)_$(EXTENSION_VERSION)/ --output ../$(ZIPBALL) master # open the package unzip $(ZIPBALL) $(EXTENSION)_$(EXTENSION_VERSION)/ # copy artefact into the package cp -pr anon ./$(EXTENSION)_$(EXTENSION_VERSION)/ # rebuild the package zip -r $(ZIPBALL) ./$(EXTENSION)_$(EXTENSION_VERSION)/ # clean up rm -fr ./$(EXTENSION)_$(EXTENSION_VERSION) ./postgresql_anonymizer.git/ ## ## Mandatory PGXS stuff ## PG_CONFIG = pg_config PGXS := $(shell $(PG_CONFIG) --pgxs) include $(PGXS)