Skip to content

Commit

Permalink
Testing schemachange using schemachange
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-tmathew committed May 6, 2024
1 parent 4e9ae5b commit 4105da9
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 80 deletions.
61 changes: 12 additions & 49 deletions .github/workflows/dev-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,6 @@ jobs:
- name: Test with pytest
run: |
pytest
- name: Setup SnowSQL
env:
SNOWSQL_MAJOR_VERSION: "1.2"
SNOWSQL_PATCH_VERSION: "28"
SNOWSQL_DOWNLOAD_DIR: "/home/runner/downloads"
# SNOWSQL_DEST: "/home/runner/.snowsql/bin"
# SNOWSQL_LOGIN_SHELL: "/home/runner/.profile"
MY_SNOWSQL_CONFIG_FILE: "/home/runner/.snowsql/config"
run: |
apt-get update -y && apt-get upgrade -y && apt-get install -y curl unzip bash
curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/${SNOWSQL_MAJOR_VERSION}/linux_x86_64/snowsql-${SNOWSQL_MAJOR_VERSION}.${SNOWSQL_PATCH_VERSION}-linux_x86_64.bash
bash snowsql-${SNOWSQL_MAJOR_VERSION}.${SNOWSQL_PATCH_VERSION}-linux_x86_64.bash
cat >$MY_SNOWSQL_CONFIG_FILE <<EOL
[connections]
[options]
variable_substitution = True
log_file = /home/runner/.snowsql/log
EOL
- name: Test Snowsql
env:
SNOWSQL_PWD: ${{ env.SNOWFLAKE_PASSWORD }}
SNOWSQL_ACCOUNT: ${{ env.SNOWFLAKE_ACCOUNT }}
SNOWSQL_USER: ${{ env.SNOWFLAKE_USER }}
SNOWSQL_DATABASE: ${{ env.SNOWFLAKE_DATABASE }}
SNOWSQL_WAREHOUSE: ${{ env.SNOWFLAKE_WAREHOUSE }}
SNOWSQL_ROLE: ${{ env.SNOWFLAKE_ROLE }}
MY_TARGET_SCHEMA: BASICS_DEMO_${{ env.SCHEMACHANGE_BUILD_ID }}
run: snowsql -v
# - name: Test Basics Demo
# env:
# SNOWSQL_PWD: ${{ env.SNOWFLAKE_PASSWORD }}
# SNOWSQL_ACCOUNT: ${{ env.SNOWFLAKE_ACCOUNT }}
# SNOWSQL_USER: ${{ env.SNOWFLAKE_USER }}
# SNOWSQL_DATABASE: ${{ env.SNOWFLAKE_DATABASE }}
# SNOWSQL_WAREHOUSE: ${{ env.SNOWFLAKE_WAREHOUSE }}
# SNOWSQL_ROLE: ${{ env.SNOWFLAKE_ROLE }}
# MY_TARGET_SCHEMA: BASICS_DEMO_${{ env.SCHEMACHANGE_BUILD_ID }}
# run: |
# snowsql -D v_target_schema_name=$MY_TARGET_SCHEMA -f ./demo/setup/basics_demo.sql
# snowsql -D v_target_schema_name=$MY_TARGET_SCHEMA -f ./demo/teardown/basics_demo.sql
#- name: Setup SnowCLI connection file
# run: |
# echo "[connections]" > config.toml
Expand All @@ -101,15 +61,18 @@ jobs:
# echo "Tested SnowCLI connection successfully!"
# echo "Set default connection"
# snow --config-file config.toml connection set-default "myconnection"
#- name: Test Basic Schemachange
# run: |
# schemachange --config-folder ./demo/setup/basics_demo
# schemachange --config-folder ./demo/basics
# schemachange --config-folder ./demo/teardown/basics_demo
#run: |
# snow --config-file config.toml sql -f ./demo/setup/setup_basics_demo.sql
# schemachange --config-folder ./demo/basics
# snow --config-file config.toml sql -f ./demo/teardown/teardown_basics_demo.sql
- name: Test Basic Schemachange
env:
MY_TARGET_SCHEMA: BASICS_DEMO_${{ env.SCHEMACHANGE_BUILD_ID }}
run: |
echo "Setting up ${MY_TARGET_SCHEMA}"
schemachange --config-folder ./demo/setup/basics_demo
echo "Testing Rendering to ${MY_TARGET_SCHEMA}"
echo "Work in Progress"
echo "Testing Deployment using ${MY_TARGET_SCHEMA}"
schemachange --config-folder ./demo/basics
echo "Tearing down up ${MY_TARGET_SCHEMA}"
schemachange --config-folder ./demo/teardown/basics_demo
#- name: Test Citibike Demo
# run: |
# snow --config-file config.toml sql -f ./demo/setup/setup_citibike_demo.sql
Expand Down
9 changes: 2 additions & 7 deletions demo/basics/schemachange-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ config-version: 1

root-folder: ./demo/basics

snowflake-user: {{ env_var('SNOWFLAKE_USER')}}
snowflake-account: {{ env_var('SNOWFLAKE_ACCOUNT')}}
snowflake-role: {{ env_var('SNOWFLAKE_ROLE')}}
snowflake-warehouse: {{ env_var('SNOWFLAKE_WAREHOUSE')}}
snowflake-database: {{ env_var('SNOWFLAKE_DATABASE')}}
snowflake-schema: {{ env_var('MY_TARGET_SCHEMA')}}
change-history-table: "{{ env_var('SNOWFLAKE_DATABASE')}}.{{ env_var('MY_TARGET_SCHEMA')}}.CHANGE_HISTORY"
create-change-history-table: true

vars:
database_name: {{env_var('SNOWFLAKE_DATABASE', 'SCHEMACHANGE_DEMO')}}
schema_name: {{env_var('SNOWFLAKE_SCHEMA', 'BASICS_DEMO')}}
database_name: {{env_var('SNOWFLAKE_DATABASE')}}
schema_name: {{env_var('MY_TARGET_SCHEMA')}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SET TARGET_SCHEMA_NAME = '&{v_target_schema_name}';
SET TARGET_DB_NAME = 'SCHEMACHANGE_DEMO'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
SET TARGET_SCHEMA_NAME = '{{ schema_name }}';
SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
-- Dependent Variables; Change the naming pattern if you want but not necessary
SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas.
SET DEPLOY_ROLE = $TARGET_DB_NAME || '_DEPLOY'; -- This role will be granted privileges to create objects in any schema in the database
Expand Down
13 changes: 3 additions & 10 deletions demo/setup/basics_demo/schemachange-config.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
config-version: 1

root-folder: ./demo/setup/basics_demo

snowflake-user: {{ env_var('SNOWFLAKE_USER')}}
snowflake-account: {{ env_var('SNOWFLAKE_ACCOUNT')}}
snowflake-role: SCHEMACHANGE_DEMO_DEPLOY
snowflake-warehouse: SCHEMACHANGE_DEMO_WH
snowflake-database: SCHEMACHANGE_DEMO
snowflake-schema: BASICS_DEMO_{{ env_var('SCHEMACHANGE_BUILD_ID') }}
change-history-table: "SCHEMACHANGE_DEMO.SCHEMACHANGE.BASICS_DEMO_CHANGE_HISTORY"
change-history-table: "{{ env_var('SNOWFLAKE_DATABASE')}}.SCHEMACHANGE.BASICS_DEMO_CHANGE_HISTORY"
create-change-history-table: true

vars:
database_name: {{env_var('SNOWFLAKE_DATABASE', 'SCHEMACHANGE_DEMO')}}
schema_name: {{env_var('SNOWFLAKE_SCHEMA', 'BASICS_DEMO')}}
database_name: {{env_var('SNOWFLAKE_DATABASE')}}
schema_name: {{env_var('MY_TARGET_SCHEMA')}}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SET TARGET_SCHEMA_NAME = '&{v_target_schema_name}';
SET TARGET_DB_NAME = 'SCHEMACHANGE_DEMO'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
SET TARGET_SCHEMA_NAME = '{{ schema_name }}';
SET TARGET_DB_NAME = '{{ database_name }}'; -- Name of database that will have the SCHEMACHANGE Schema for change tracking.
-- Dependent Variables; Change the naming pattern if you want but not necessary
SET ADMIN_ROLE = $TARGET_DB_NAME || '_ADMIN'; -- This role will own the database and schemas.
SET DEPLOY_ROLE = $TARGET_DB_NAME || '_DEPLOY'; -- This role will be granted privileges to create objects in any schema in the database
Expand Down
13 changes: 3 additions & 10 deletions demo/teardown/basics_demo/schemachange-config.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
config-version: 1

root-folder: ./demo/teardown/basics_demo

snowflake-user: {{ env_var('SNOWFLAKE_USER')}}
snowflake-account: {{ env_var('SNOWFLAKE_ACCOUNT')}}
snowflake-role: SCHEMACHANGE_DEMO_DEPLOY
snowflake-warehouse: SCHEMACHANGE_DEMO_WH
snowflake-database: SCHEMACHANGE_DEMO
snowflake-schema: BASICS_DEMO_{{ env_var('SCHEMACHANGE_BUILD_ID') }}
change-history-table: "SCHEMACHANGE_DEMO.SCHEMACHANGE.BASICS_DEMO_CHANGE_HISTORY"
change-history-table: "{{ env_var('SNOWFLAKE_DATABASE')}}.SCHEMACHANGE.BASICS_DEMO_CHANGE_HISTORY"
create-change-history-table: true

vars:
database_name: {{env_var('SNOWFLAKE_DATABASE', 'SCHEMACHANGE_DEMO')}}
schema_name: {{env_var('SNOWFLAKE_SCHEMA', 'BASICS_DEMO')}}
database_name: {{env_var('SNOWFLAKE_DATABASE')}}
schema_name: {{env_var('MY_TARGET_SCHEMA')}}

0 comments on commit 4105da9

Please sign in to comment.