11#! /usr/bin/env bash
22set -ex
33
4- GATEWAY_NAME=" duckdb_persistent"
5- TMP_DIR=$( mktemp -d)
6- SUSHI_DIR=" $TMP_DIR /sushi"
7-
8-
94if [[ -z $( git tag --points-at HEAD) ]]; then
105 # If the current commit is not tagged, we need to find the last tag
116 LAST_TAG=$( git describe --tags --abbrev=0)
149 LAST_TAG=$( git tag --sort=-creatordate | head -n 2 | tail -n 1)
1510fi
1611
12+ if [ " $1 " == " " ]; then
13+ echo " Usage: $0 <example name> <sqlmesh opts>"
14+ echo " eg $0 sushi '--gateway duckdb_persistent'"
15+ exit 1
16+ fi
17+
18+
19+ TMP_DIR=$( mktemp -d)
20+ EXAMPLE_NAME=" $1 "
21+ SQLMESH_OPTS=" $2 "
22+ EXAMPLE_DIR=" ./examples/$EXAMPLE_NAME "
23+ TEST_DIR=" $TMP_DIR /$EXAMPLE_NAME "
24+
25+ echo " Running migration test for '$EXAMPLE_NAME ' in '$TEST_DIR ' for example project '$EXAMPLE_DIR ' using options '$SQLMESH_OPTS '"
26+
1727git checkout $LAST_TAG
1828
1929# Install dependencies from the previous release.
2030make install-dev
2131
22- cp -r ./examples/sushi $TMP_DIR
32+ cp -r $EXAMPLE_DIR $TEST_DIR
33+
34+ # this is only needed temporarily until the released tag for $LAST_TAG includes this config
35+ if [ " $EXAMPLE_NAME " == " sushi_dbt" ]; then
36+ echo ' migration_test_config = sqlmesh_config(Path(__file__).parent, dbt_target_name="duckdb")' >> $TEST_DIR /config.py
37+ fi
2338
2439# Run initial plan
25- pushd $SUSHI_DIR
40+ pushd $TEST_DIR
2641rm -rf ./data/*
27- sqlmesh --gateway $GATEWAY_NAME plan --no-prompts --auto-apply
42+ sqlmesh $SQLMESH_OPTS plan --no-prompts --auto-apply
2843rm -rf .cache
2944popd
3045
31- # Switch back to the starting state of the repository
46+ # Switch back to the starting state of the repository
3247git checkout -
3348
3449# Install updated dependencies.
3550make install-dev
3651
3752# Migrate and make sure the diff is empty
38- pushd $SUSHI_DIR
39- sqlmesh --gateway $GATEWAY_NAME migrate
40- sqlmesh --gateway $GATEWAY_NAME diff prod
41- popd
53+ pushd $TEST_DIR
54+ sqlmesh $SQLMESH_OPTS migrate
55+ sqlmesh $SQLMESH_OPTS diff prod
56+ popd
0 commit comments