From c428158de6dfc34902e175cf75a7ec4722365f1c Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 27 Feb 2023 17:00:34 -0500 Subject: [PATCH 1/6] attempt to run migrations from scratch for sqlite in ci since it does not support the migrations w/ burnettk --- .github/workflows/backend_tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index 12e503345..cb87dc86d 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -119,6 +119,10 @@ jobs: pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry nox --version + - name: Setup sqlite + if: matrix.database == 'sqlite' + run: ./bin/recreate_db clean rmall + - name: Setup Mysql uses: mirromutth/mysql-action@v1.1 with: From edfbc77c307364bbb62e78de80cf55ac3ee189ee Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 27 Feb 2023 17:10:14 -0500 Subject: [PATCH 2/6] attempt to set the sample process model dir w/ burnettk --- .github/workflows/backend_tests.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index cb87dc86d..8257745f4 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -119,8 +119,16 @@ jobs: pipx inject --pip-args=--constraint=.github/workflows/constraints.txt nox nox-poetry nox --version + - name: Checkout Samples + if: matrix.database == 'sqlite' + uses: actions/checkout@v3 + with: + repository: sartography/sample-process-models + path: sample-process-models - name: Setup sqlite if: matrix.database == 'sqlite' + env: + SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="${GITHUB_WORKSPACE}/sample-process-models" run: ./bin/recreate_db clean rmall - name: Setup Mysql From dca78150456a56d1c29925c5e2b0ffa70a3dd0d4 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 27 Feb 2023 17:10:52 -0500 Subject: [PATCH 3/6] syntax error w/ burnettk --- .github/workflows/backend_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index 8257745f4..a56d4d910 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -128,7 +128,7 @@ jobs: - name: Setup sqlite if: matrix.database == 'sqlite' env: - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="${GITHUB_WORKSPACE}/sample-process-models" + SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR: "${GITHUB_WORKSPACE}/sample-process-models" run: ./bin/recreate_db clean rmall - name: Setup Mysql From 338bc6a8ad1fd88086ab3784ae9ea930c5b412cd Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 27 Feb 2023 17:15:21 -0500 Subject: [PATCH 4/6] do not override env vars w/ burnettk --- .github/workflows/backend_tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index a56d4d910..5bc78bb08 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -127,9 +127,9 @@ jobs: path: sample-process-models - name: Setup sqlite if: matrix.database == 'sqlite' - env: - SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR: "${GITHUB_WORKSPACE}/sample-process-models" - run: ./bin/recreate_db clean rmall + run: | + export SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR="${GITHUB_WORKSPACE}/sample-process-models" + ./bin/recreate_db clean rmall - name: Setup Mysql uses: mirromutth/mysql-action@v1.1 From 5a873a9e2de6158c3a5f532417a32496b1421684 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 27 Feb 2023 17:19:03 -0500 Subject: [PATCH 5/6] do not run mysql commands if not doing mysql w/ burnettk --- spiffworkflow-backend/bin/recreate_db | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/spiffworkflow-backend/bin/recreate_db b/spiffworkflow-backend/bin/recreate_db index dd0bf2856..2a10401ef 100755 --- a/spiffworkflow-backend/bin/recreate_db +++ b/spiffworkflow-backend/bin/recreate_db @@ -34,9 +34,12 @@ if [[ "${1:-}" == "clean" ]]; then exit 1 fi - rm -f ./src/instance/*.sqlite3 - mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_local_development" - mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_unit_testing" + if [[ "${SPIFFWORKFLOW_BACKEND_DATABASE_TYPE:-mysql}" != "mysql" ]]; then + rm -f ./src/instance/*.sqlite3 + else + mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_local_development" + mysql -uroot -e "DROP DATABASE IF EXISTS spiffworkflow_backend_unit_testing" + fi # TODO: check to see if the db already exists and we can connect to it. also actually clean it up. # start postgres in background with one db @@ -55,8 +58,10 @@ elif [[ "${1:-}" == "migrate" ]]; then fi tasks="$tasks upgrade" -mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_local_development" -mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_unit_testing" +if [[ "${SPIFFWORKFLOW_BACKEND_DATABASE_TYPE:-mysql}" == "mysql" ]]; then + mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_local_development" + mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_unit_testing" +fi for task in $tasks; do SPIFFWORKFLOW_BACKEND_ENV=local_development FLASK_APP=src/spiffworkflow_backend poetry run flask db "$task" @@ -64,6 +69,8 @@ done SPIFFWORKFLOW_BACKEND_ENV=unit_testing FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade if [[ -n "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]] && ! grep -Eq '^(local_development|unit_testing)$' <<< "$SPIFFWORKFLOW_BACKEND_ENV"; then - mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_$SPIFFWORKFLOW_BACKEND_ENV" + if [[ "${SPIFFWORKFLOW_BACKEND_DATABASE_TYPE:-mysql}" == "mysql" ]]; then + mysql -uroot -e "CREATE DATABASE IF NOT EXISTS spiffworkflow_backend_$SPIFFWORKFLOW_BACKEND_ENV" + fi FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade fi From b2782f8975328e80e6777ba37a4cfc0c27b2f47e Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 27 Feb 2023 17:21:34 -0500 Subject: [PATCH 6/6] run poetry install for sqlite w/ burnettk --- .github/workflows/backend_tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index 5bc78bb08..150f13eb5 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -125,6 +125,9 @@ jobs: with: repository: sartography/sample-process-models path: sample-process-models + - name: Poetry Install + if: matrix.database == 'sqlite' + run: poetry install - name: Setup sqlite if: matrix.database == 'sqlite' run: |