diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3f653c71bef..5489bf5bdad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: with: python-version: '3.9' - name: Test migrations across versions - run: bash scripts/test-migrations.sh mysql + run: bash scripts/test-migrations-mysql.sh mysql sqlite-db-migration-testing: runs-on: ubuntu-dind-runners steps: @@ -49,13 +49,25 @@ jobs: with: python-version: '3.9' - name: Test migrations across versions - run: bash scripts/test-migrations.sh sqlite + run: bash scripts/test-migrations-mysql.sh sqlite + mariadb-db-migration-testing: + runs-on: ubuntu-dind-runners + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + - name: Set up Python 3.9 + uses: actions/setup-python@v4.8.0 + with: + python-version: '3.9' + - name: Test migrations across versions + run: bash scripts/test-migrations-mariadb.sh publish-python-package: needs: - setup-and-test - mlstacks-compatibility-check - sqlite-db-migration-testing - mysql-db-migration-testing + - mariadb-db-migration-testing uses: ./.github/workflows/publish_to_pypi.yml secrets: inherit wait-for-package-release: diff --git a/scripts/test-migrations-mariadb.sh b/scripts/test-migrations-mariadb.sh new file mode 100755 index 00000000000..eb5234d7aa1 --- /dev/null +++ b/scripts/test-migrations-mariadb.sh @@ -0,0 +1,86 @@ +#!/bin/bash + +DB="mariadb" +DB_STARTUP_DELAY=30 # Time in seconds to wait for the database container to start + +function run_tests_for_version() { + set -e # Exit immediately if a command exits with a non-zero status + local VERSION=$1 + + echo "===== Testing version $VERSION =====" + + mkdir test_starter + zenml init --template starter --path test_starter --template-with-defaults --test + cd test_starter + + export ZENML_ANALYTICS_OPT_IN=false + export ZENML_DEBUG=true + + echo "===== Installing sklearn integration =====" + zenml integration install sklearn -y + + echo "===== Running starter template pipeline =====" + python3 run.py + # Add additional CLI tests here + zenml version + + # Confirm DB works and is accessible + zenml pipeline runs list + + cd .. + rm -rf test_starter + echo "===== Finished testing version $VERSION =====" +} + +echo "===== Testing MariaDB =====" +# run a mariadb instance in docker +docker run --name mariadb -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password mariadb:10.6 +# mariadb takes a while to start up +sleep $DB_STARTUP_DELAY + +# List of versions to test +VERSIONS=("0.54.0") + +# Start completely fresh +rm -rf ~/.config/zenml + +for VERSION in "${VERSIONS[@]}" +do + set -e # Exit immediately if a command exits with a non-zero status + # Create a new virtual environment + python3 -m venv ".venv-$VERSION" + source ".venv-$VERSION/bin/activate" + + # Install the specific version + pip3 install -U pip setuptools wheel + pip3 install "zenml[templates,server]==$VERSION" + + zenml connect --url mysql://127.0.0.1/zenml --username root --password password + + # Run the tests for this version + run_tests_for_version $VERSION + + zenml disconnect + sleep 5 + + deactivate +done + +# Test the most recent migration with MariaDB +echo "===== TESTING CURRENT BRANCH =====" +set -e +python3 -m venv ".venv-current-branch" +source ".venv-current-branch/bin/activate" + +pip3 install -U pip setuptools wheel +pip3 install -e ".[templates,server]" +pip3 install importlib_metadata + +zenml connect --url mysql://127.0.0.1/zenml --username root --password password + +run_tests_for_version current_branch_mariadb + +zenml disconnect +docker rm -f mariadb + +deactivate diff --git a/scripts/test-migrations.sh b/scripts/test-migrations-mysql.sh similarity index 77% rename from scripts/test-migrations.sh rename to scripts/test-migrations-mysql.sh index 7c152eda94b..7c57261dc28 100755 --- a/scripts/test-migrations.sh +++ b/scripts/test-migrations-mysql.sh @@ -1,6 +1,8 @@ #!/bin/bash DB="sqlite" +DB_STARTUP_DELAY=30 # Time in seconds to wait for the database container to start + if [ -z "$1" ]; then echo "No argument passed, using default: $DB" else @@ -10,12 +12,20 @@ fi function run_tests_for_version() { set -e # Exit immediately if a command exits with a non-zero status local VERSION=$1 + # versions pre-templates and pre-init test flag + # (zenml init --test allows for a non-interactive init) + local PRE_TEMPLATE_VERSIONS=("0.40.0" "0.40.3" "0.41.0" "0.43.0" "0.44.1" "0.44.3" "0.45.2" "0.45.3" "0.45.4" "0.45.5" "0.45.6" "0.46.0" "0.47.0") echo "===== Testing version $VERSION =====" - # Initialize zenml with the appropriate template - # hardcoded to 0.43.0 since this is the latest template-starter repo - # release tag - copier copy -l --trust -r release/0.43.0 https://github.com/zenml-io/template-starter.git test_starter + + # Check if VERSION is in PRE_TEMPLATE_VERSIONS + if printf '%s\n' "${PRE_TEMPLATE_VERSIONS[@]}" | grep -q "^$VERSION$"; then + copier copy -l --trust -r release/0.43.0 https://github.com/zenml-io/template-starter.git test_starter + else + mkdir test_starter + zenml init --template starter --path test_starter --template-with-defaults --test + fi + cd test_starter export ZENML_ANALYTICS_OPT_IN=false @@ -37,17 +47,18 @@ function run_tests_for_version() { echo "===== Finished testing version $VERSION =====" } + + if [ "$1" == "mysql" ]; then echo "===== Testing MySQL =====" # run a mysql instance in docker docker run --name mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password mysql:latest - # mysql takes a while to start up - sleep 30 + sleep $DB_STARTUP_DELAY fi # List of versions to test -VERSIONS=("0.40.0" "0.40.3" "0.41.0" "0.43.0" "0.44.1" "0.44.3" "0.45.2" "0.45.3" "0.45.4" "0.45.5" "0.45.6" "0.46.0" "0.47.0" "0.50.0" "0.51.0" "0.52.0") +VERSIONS=("0.40.0" "0.40.3" "0.41.0" "0.43.0" "0.44.1" "0.44.3" "0.45.2" "0.45.3" "0.45.4" "0.45.5" "0.45.6" "0.46.0" "0.47.0" "0.50.0" "0.51.0" "0.52.0" "0.53.0" "0.53.1" "0.54.0") # Start completely fresh rm -rf ~/.config/zenml @@ -95,6 +106,7 @@ done # Test the most recent migration with MySQL +echo "===== TESTING CURRENT BRANCH =====" set -e python3 -m venv ".venv-current-branch" source ".venv-current-branch/bin/activate"