Skip to content

testing snowsql variable substitution #21

testing snowsql variable substitution

testing snowsql variable substitution #21

Workflow file for this run

name: dev-pytest
on:
push:
branches:
- dev
- release/**
workflow_dispatch:
pull_request:
types: [opened, reopened]
jobs:
build:
env:
SNOWFLAKE_PASSWORD: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_PASSWORD }}
SNOWFLAKE_USER: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_USER }}
SNOWFLAKE_ACCOUNT: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_ACCOUNT }}
SNOWFLAKE_DATABASE: SCHEMACHANGE_DEMO
SNOWFLAKE_WAREHOUSE: SCHEMACHANGE_DEMO_WH
SNOWFLAKE_ROLE: SCHEMACHANGE_DEMO_DEPLOY
#SNOWFLAKE_CONNECTIONS_MYCONNECTION_PASSWORD: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_PASSWORD }}
#SNOWFLAKE_CONNECTIONS_MYCONNECTION_ACCOUNT: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_ACCOUNT }}
#SNOWFLAKE_CONNECTIONS_MYCONNECTION_USER: ${{ secrets.SCHEMACHANGE_SNOWFLAKE_USER }}
SCHEMACHANGE_BUILD_ID: ${{ github.run_id }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Update pip
run: |
python -m pip install --upgrade pip
- name: Install dependencies
run: |
python -m pip install -e .[dev]
- 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 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
# echo "[connections.myconnection]" >> config.toml
# chmod 0600 config.toml
#- name: Install snowcli
# run: |
# pip install snowflake-cli-labs
#- name: Test Default snowcli connection
# run: |
# snow --version
# echo "::group::Config Contents"
# more config.toml
# echo "::endgroup::"
# snow --config-file config.toml connection test -c myconnection
# 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 Citibike Demo
# run: |
# snow --config-file config.toml sql -f ./demo/setup/setup_citibike_demo.sql
# schemachange --config-folder ./demo/citibike
# snow --config-file config.toml sql -f ./demo/teardown/teardown_citibike_demo.sql
#- name: Test Citibike Demo Jinja Template
# run: |
# snow --config-file config.toml sql -f ./demo/setup/setup_citibike_demo_jinja.sql
# schemachange --config-folder ./demo/citibike_jinja
# snow --config-file config.toml sql -f ./demo/teardown/teardown_citibike_demo_jinja.sql