Skip to content

[SNOW-90] Introduce CI job to test schemachange updates against a clone #32

[SNOW-90] Introduce CI job to test schemachange updates against a clone

[SNOW-90] Introduce CI job to test schemachange updates against a clone #32

---
name: Test Changes with Cloned DB
on:
pull_request:
types: [ labeled ]
permissions:
contents: read
jobs:
create_clone_and_run_schemachange:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'create_clone_and_run_schemachange')
environment: dev
env:
SNOWSQL_PWD: ${{ secrets.SNOWSQL_PWD }}
SNOWSQL_ACCOUNT: ${{ secrets.SNOWSQL_ACCOUNT }}
SNOWSQL_USER: ${{ secrets.SNOWSQL_USER }}
SNOWSQL_WAREHOUSE: ${{ secrets.SNOWSQL_WAREHOUSE }}
SNOWSQL_CLONE_ROLE: DATA_ENGINEER
#SNOWSQL_SCHEMACHANGE_ROLE: SYSADMIN
SNOWFLAKE_SYNAPSE_DATA_WAREHOUSE_DATABASE: "${{ vars.SNOWFLAKE_SYNAPSE_DATA_WAREHOUSE_DATABASE }}_${{ github.head_ref }}"
SNOWFLAKE_SYNAPSE_DATA_WAREHOUSE_DATABASE_ORIG: ${{ vars.SNOWFLAKE_SYNAPSE_DATA_WAREHOUSE_DATABASE }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install python libraries
shell: bash
run: |
pip install schemachange==3.6.1
pip install numpy==1.26.4
pip install pandas==1.5.3
- name: Install SnowSQL
run: |
curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.9-linux_x86_64.bash
SNOWSQL_DEST=~/bin SNOWSQL_LOGIN_SHELL=~/.profile bash snowsql-1.2.9-linux_x86_64.bash
- name: Verify SnowSQL installation
run: ~/bin/snowsql -v
- name: Zero-copy clone the database
shell: bash
run: |
~/bin/snowsql -r $SNOWSQL_CLONE_ROLE -q "CREATE OR REPLACE DATABASE $SNOWFLAKE_SYNAPSE_DATA_WAREHOUSE_DATABASE CLONE $SNOWFLAKE_SYNAPSE_DATA_WAREHOUSE_DATABASE_ORIG;"
# TODO: Do we need SYSADMIN to run schemachange?
- name: Run schemachange on the clone
shell: bash
run: |
schemachange \
-f synapse_data_warehouse \
-a $SNOWSQL_ACCOUNT \
-u $SNOWSQL_USER \
-r $SNOWSQL_CLONE_ROLE \
-w $SNOWSQL_WAREHOUSE \
--config-folder synapse_data_warehouse
# delete_clone:
# runs-on: ubuntu-latest
# if: contains(github.event.pull_request.labels.*.name, 'create_clone_and_run_schemachange')
# environment: dev