From cf1e1a79d9dfb64ddaaede7903378bedde237dda Mon Sep 17 00:00:00 2001 From: burnettk Date: Fri, 19 May 2023 07:05:58 -0400 Subject: [PATCH] avoid doing stuff outside of nox --- .github/workflows/backend_tests.yml | 31 ++++++++++++++++------------- spiffworkflow-backend/noxfile.py | 12 +++++++++++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index 9d36ebc3..80692cd1 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -119,20 +119,23 @@ 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: Poetry Install - if: matrix.database == 'sqlite' - run: poetry install - - 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 + # when we get an imcompatible sqlite migration again and need to combine all migrations into one for the benefit of sqlite + # see if we can get the sqlite-specific block in the noxfile.py to work instead of this block in the github workflow, + # which annoyingly runs python setup outside of the nox environment (which seems to be flakier on poetry install). + # - name: Checkout Samples + # if: matrix.database == 'sqlite' + # uses: actions/checkout@v3 + # 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' + # env: + # SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR: "${GITHUB_WORKSPACE}/sample-process-models" + # run: ./bin/recreate_db clean rmall - name: Setup Mysql uses: mirromutth/mysql-action@v1.1 diff --git a/spiffworkflow-backend/noxfile.py b/spiffworkflow-backend/noxfile.py index f266e411..2e67fbee 100644 --- a/spiffworkflow-backend/noxfile.py +++ b/spiffworkflow-backend/noxfile.py @@ -41,6 +41,18 @@ def setup_database(session: Session) -> None: session.env[flask_env_key] = "e7711a3ba96c46c68e084a86952de16f" session.env["FLASK_APP"] = "src/spiffworkflow_backend" session.env["SPIFFWORKFLOW_BACKEND_ENV"] = "unit_testing" + + if os.environ.get("SPIFFWORKFLOW_BACKEND_DATABASE_TYPE") == "sqlite": + # maybe replace this sqlite-specific block with ./bin/recreate_db clean rmall + # (if we can make it work, since it uses poetry), + # which would also remove the migrations folder and re-create things as a single migration + if os.path.exists("migrations"): + import shutil + + shutil.rmtree("migrations") + for task in ["init", "migrate"]: + session.run("flask", "db", task) + session.run("flask", "db", "upgrade")