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
17- git checkout $LAST_TAG
12+ function run_migration_test {
13+ TMP_DIR=$( mktemp -d)
14+ EXAMPLE_NAME=" $1 "
15+ SQLMESH_OPTS=" $2 "
16+ EXAMPLE_DIR=" ./examples/$EXAMPLE_NAME "
17+ TEST_DIR=" $TMP_DIR /$EXAMPLE_NAME "
18+
19+ echo " Running migration test for '$EXAMPLE_NAME ' in '$TEST_DIR ' for example project '$EXAMPLE_DIR ' using options '$SQLMESH_OPTS '"
20+
21+ git checkout $LAST_TAG
22+
23+ # Install dependencies from the previous release.
24+ make install-dev
25+
26+ cp -r $EXAMPLE_DIR $TEST_DIR
1827
19- # Install dependencies from the previous release.
20- make install-dev
28+ # this is only needed temporarily until the released tag for $LAST_TAG includes this config
29+ if [ " $EXAMPLE_NAME " == " sushi_dbt" ]; then
30+ echo ' migration_test_config = sqlmesh_config(Path(__file__).parent, dbt_target_name="duckdb")' >> $TEST_DIR /config.py
31+ fi
2132
22- cp -r ./examples/sushi $TMP_DIR
33+ # Run initial plan
34+ pushd $TEST_DIR
35+ rm -rf ./data/*
36+ sqlmesh $SQLMESH_OPTS plan --no-prompts --auto-apply
37+ rm -rf .cache
38+ popd
2339
24- # Run initial plan
25- pushd $SUSHI_DIR
26- rm -rf ./data/*
27- sqlmesh --gateway $GATEWAY_NAME plan --no-prompts --auto-apply
28- rm -rf .cache
29- popd
40+ # Switch back to the starting state of the repository
41+ git checkout -
3042
31- # Switch back to the starting state of the repository
32- git checkout -
43+ # Install updated dependencies.
44+ make install-dev
3345
34- # Install updated dependencies.
35- make install-dev
46+ # Migrate and make sure the diff is empty
47+ pushd $TEST_DIR
48+ sqlmesh $SQLMESH_OPTS migrate
49+ sqlmesh $SQLMESH_OPTS diff prod
50+ popd
51+ }
3652
37- # 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+ run_migration_test " sushi" " --gateway duckdb_persistent"
54+ run_migration_test " sushi_dbt" " --config migration_test_config"
0 commit comments