From 59b52b6fc0076c01a2eb5b3321d8dcf4f754fa8f Mon Sep 17 00:00:00 2001 From: Valentin de la Cruz Barquero <6054336+vdelacruzb@users.noreply.github.com> Date: Wed, 6 Mar 2024 17:19:30 +0100 Subject: [PATCH] fix(bq,sf,rs,pg): drop schemas when dedicateds gets released (#485) --- .github/workflows/redshift-ded.yml | 15 ++++++++++++++- clouds/bigquery/modules/Makefile | 8 ++++++-- clouds/postgres/modules/Makefile | 8 ++++++-- clouds/redshift/modules/Makefile | 8 ++++++-- clouds/snowflake/modules/Makefile | 8 ++++++-- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/redshift-ded.yml b/.github/workflows/redshift-ded.yml index 0c5e71c2b..333159823 100644 --- a/.github/workflows/redshift-ded.yml +++ b/.github/workflows/redshift-ded.yml @@ -33,6 +33,19 @@ jobs: uses: actions/checkout@v2 - name: Check diff uses: technote-space/get-diff-action@v4 + - name: Set RS_PREFIX for releases + if: startsWith(github.event.pull_request.head.ref, 'release/') + run: | + echo "RS_PREFIX=dedicated_release_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV + - name: Set RS_PREFIX for hotfixes + if: startsWith(github.event.pull_request.head.ref, 'hotfix/') + run: | + echo "RS_PREFIX=dedicated_hotfix_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV + - name: Set RS_PREFIX for the rest + if: | + !(startsWith(github.event.pull_request.head.ref, 'hotfix/')) && + !(startsWith(github.event.pull_request.head.ref, 'release/')) + run: echo "RS_PREFIX=dedicated_${{ github.event.pull_request.number }}_" >> $GITHUB_ENV - name: Setup node uses: actions/setup-node@v1 with: @@ -63,7 +76,7 @@ jobs: if: github.event.action == 'synchronize' || github.event.action == 'labeled' run: | cd clouds/redshift - make deploy + make deploy dropfirst=1 - name: Run remove id: remove if: github.event.action == 'unlabeled' || github.event.action == 'closed' diff --git a/clouds/bigquery/modules/Makefile b/clouds/bigquery/modules/Makefile index ca2f9abfe..5314c6d02 100644 --- a/clouds/bigquery/modules/Makefile +++ b/clouds/bigquery/modules/Makefile @@ -34,10 +34,10 @@ include $(COMMON_DIR)/Makefile .SILENT: -.PHONY: help lint build build-share deploy deploy-share test remove remove-share clean +.PHONY: help lint build build-share deploy deploy-share test remove remove-functions remove-share clean help: - echo "Available targets: lint build deploy test remove clean" + echo "Available targets: lint build deploy test remove remove-functions clean" lint: venv3 $(NODE_MODULES_DEV) echo "Linting modules..." @@ -97,6 +97,10 @@ test: check $(NODE_MODULES_DEV) remove: check echo "Removing modules..." + $(BQ) rm -r -f -d $(BQ_DEPLOY_DATASET) + +remove-functions: check + echo "Removing functions..." REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \ GOOGLE_APPLICATION_CREDENTIALS=$(GOOGLE_APPLICATION_CREDENTIALS) \ $(COMMON_DIR)/run-script.js $(COMMON_DIR)/DROP_FUNCTIONS.sql diff --git a/clouds/postgres/modules/Makefile b/clouds/postgres/modules/Makefile index ba3603b36..7f9de5e72 100644 --- a/clouds/postgres/modules/Makefile +++ b/clouds/postgres/modules/Makefile @@ -21,10 +21,10 @@ include $(COMMON_DIR)/Makefile .SILENT: -.PHONY: help lint build deploy test remove clean +.PHONY: help lint build deploy test remove remove-functions clean help: - echo "Available targets: lint build deploy test remove clean" + echo "Available targets: lint build deploy test remove remove-functions clean" lint: venv3 $(NODE_MODULES_DEV) echo "Linting modules..." @@ -61,6 +61,10 @@ test: check venv3 $(NODE_MODULES_DEV) remove: venv3 echo "Removing modules..." + $(VENV3_BIN)/python $(COMMON_DIR)/run_query.py "DROP SCHEMA IF EXISTS $(PG_SCHEMA) CASCADE;" + +remove-functions: venv3 + echo "Removing functions..." REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \ $(VENV3_BIN)/python $(COMMON_DIR)/run_script.py $(COMMON_DIR)/DROP_FUNCTIONS.sql diff --git a/clouds/redshift/modules/Makefile b/clouds/redshift/modules/Makefile index d56d2c3c4..9cc9dbaf8 100644 --- a/clouds/redshift/modules/Makefile +++ b/clouds/redshift/modules/Makefile @@ -21,10 +21,10 @@ include $(COMMON_DIR)/Makefile .SILENT: -.PHONY: help lint build deploy test remove clean +.PHONY: help lint build deploy test remove remove-functions clean help: - echo "Available targets: lint build deploy test remove clean" + echo "Available targets: lint build deploy test remove remove-functions clean" lint: venv3 $(NODE_MODULES_DEV) echo "Linting modules..." @@ -61,6 +61,10 @@ test: check venv3 $(NODE_MODULES_DEV) remove: venv3 echo "Removing modules..." + $(VENV3_BIN)/python $(COMMON_DIR)/run_query.py "DROP SCHEMA IF EXISTS $(RS_SCHEMA) CASCADE;" + +remove-functions: venv3 + echo "Removing functions..." REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \ $(VENV3_BIN)/python $(COMMON_DIR)/run_script.py $(COMMON_DIR)/DROP_FUNCTIONS.sql diff --git a/clouds/snowflake/modules/Makefile b/clouds/snowflake/modules/Makefile index c2f7ac8e2..1ecaf1858 100644 --- a/clouds/snowflake/modules/Makefile +++ b/clouds/snowflake/modules/Makefile @@ -32,10 +32,10 @@ include $(COMMON_DIR)/Makefile .SILENT: -.PHONY: help lint build build-share build-native-app-setup-script deploy deploy-share test remove remove-share clean +.PHONY: help lint build build-share build-native-app-setup-script deploy deploy-share test remove remove-functions remove-share clean help: - echo "Available targets: lint build deploy test remove clean" + echo "Available targets: lint build deploy test remove remove-functions clean" lint: $(NODE_MODULES_DEV) venv3 echo "Linting modules..." @@ -107,6 +107,10 @@ test: check $(NODE_MODULES_DEV) remove: $(NODE_MODULES_DEV) echo "Removing modules..." + $(COMMON_DIR)/run-query.js "DROP SCHEMA IF EXISTS $(SF_SCHEMA) CASCADE;" + +remove-functions: $(NODE_MODULES_DEV) + echo "Removing functions..." REPLACEMENTS=$(REPLACEMENTS)" "$(REPLACEMENTS_EXTRA) \ $(COMMON_DIR)/run-script.js $(COMMON_DIR)/DROP_FUNCTIONS.sql