From 76551f5301cbf50960ca7950f8b46bbcfe5745f6 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 9 Jan 2023 10:19:31 -0500 Subject: [PATCH 1/8] some updates to test w/ burnettk --- .github/workflows/backend_tests.yml | 1 - .../bin/build_and_run_with_docker_compose | 6 ++-- .../bin/find_sample_process_models | 30 +++++++++++++++++++ spiffworkflow-backend/bin/run_server_locally | 23 +++----------- spiffworkflow-backend/bin/save_all_bpmn.py | 1 + .../services/data_setup_service.py | 6 ++-- 6 files changed, 40 insertions(+), 27 deletions(-) create mode 100755 spiffworkflow-backend/bin/find_sample_process_models diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index fce251e3a..388f3d3b8 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -220,7 +220,6 @@ jobs: timeout-minutes: 20 env: SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP: "false" - SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA: "true" - name: wait_for_backend run: ./bin/wait_for_server_to_be_up 5 diff --git a/spiffworkflow-backend/bin/build_and_run_with_docker_compose b/spiffworkflow-backend/bin/build_and_run_with_docker_compose index 2dfa896e6..c986e3941 100755 --- a/spiffworkflow-backend/bin/build_and_run_with_docker_compose +++ b/spiffworkflow-backend/bin/build_and_run_with_docker_compose @@ -7,10 +7,8 @@ function error_handler() { trap 'error_handler ${LINENO} $?' ERR set -o errtrace -o errexit -o nounset -o pipefail -if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then - script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - export BPMN_SPEC_ABSOLUTE_DIR="$script_dir/../../../sample-process-models" -fi +BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models) +export BPMN_SPEC_ABSOLUTE_DIR if [[ -z "${SPIFFWORKFLOW_BACKEND_DOCKER_COMPOSE_PROFILE:-}" ]]; then export SPIFFWORKFLOW_BACKEND_DOCKER_COMPOSE_PROFILE=run diff --git a/spiffworkflow-backend/bin/find_sample_process_models b/spiffworkflow-backend/bin/find_sample_process_models new file mode 100755 index 000000000..f5b6d1cf8 --- /dev/null +++ b/spiffworkflow-backend/bin/find_sample_process_models @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +function error_handler() { + >&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}." + exit "$2" +} +trap 'error_handler ${LINENO} $?' ERR +set -o errtrace -o errexit -o nounset -o pipefail + +if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then + script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + + BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../../sample-process-models" + if [[ ! -d "$BPMN_SPEC_ABSOLUTE_DIR" ]]; then + BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../sample-process-models" + if [[ ! -d "$BPMN_SPEC_ABSOLUTE_DIR" ]]; then + >&2 echo "ERROR: Could not find a location for the sample processes. Last tried: $BPMN_SPEC_ABSOLUTE_DIR" + exit 1 + fi + fi + export BPMN_SPEC_ABSOLUTE_DIR + pushd "$BPMN_SPEC_ABSOLUTE_DIR" + if [[ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]]; then + >&2 echo "ERROR: please do not use the main branch of sample-process-models. use dev" + exit 1 + fi + popd +fi + +echo "$BPMN_SPEC_ABSOLUTE_DIR" diff --git a/spiffworkflow-backend/bin/run_server_locally b/spiffworkflow-backend/bin/run_server_locally index c1e960a5a..e0bc15826 100755 --- a/spiffworkflow-backend/bin/run_server_locally +++ b/spiffworkflow-backend/bin/run_server_locally @@ -17,25 +17,9 @@ if [[ -z "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]]; then export SPIFFWORKFLOW_BACKEND_ENV=development fi -if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then - script_dir="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - - BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../../sample-process-models" - if [[ ! -d "$BPMN_SPEC_ABSOLUTE_DIR" ]]; then - BPMN_SPEC_ABSOLUTE_DIR="${script_dir}/../../sample-process-models" - if [[ ! -d "$BPMN_SPEC_ABSOLUTE_DIR" ]]; then - >&2 echo "ERROR: Could not find a location for the sample processes. Last tried: $BPMN_SPEC_ABSOLUTE_DIR" - exit 1 - fi - fi - export BPMN_SPEC_ABSOLUTE_DIR - pushd "$BPMN_SPEC_ABSOLUTE_DIR" - if [[ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]]; then - >&2 echo "ERROR: please do not use the main branch of sample-process-models. use dev" - exit 1 - fi - popd -fi +BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models) +export BPMN_SPEC_ABSOLUTE_DIR +echo "$BPMN_SPEC_ABSOLUTE_DIR" export FLASK_SESSION_SECRET_KEY=super_secret_key export APPLICATION_ROOT="/" @@ -46,6 +30,7 @@ else export FLASK_DEBUG=1 if [[ "${SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP:-}" != "false" ]]; then + echo "RUNING STUFF" SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py fi FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000 diff --git a/spiffworkflow-backend/bin/save_all_bpmn.py b/spiffworkflow-backend/bin/save_all_bpmn.py index fd44bb549..b7b616284 100644 --- a/spiffworkflow-backend/bin/save_all_bpmn.py +++ b/spiffworkflow-backend/bin/save_all_bpmn.py @@ -9,6 +9,7 @@ def main() -> None: """Main.""" app = create_app() with app.app_context(): + print("HEY") failing_process_models = DataSetupService.save_all_process_models() for bpmn_errors in failing_process_models: print(bpmn_errors) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/data_setup_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/data_setup_service.py index c9c0647ed..96f662ec9 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/data_setup_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/data_setup_service.py @@ -50,8 +50,8 @@ class DataSetupService: ) ) - current_app.logger.debug( - "DataSetupService.save_all_process_models() end" - ) + current_app.logger.debug( + "DataSetupService.save_all_process_models() end" + ) db.session.commit() return failing_process_models From 83e9a08b900779121233d3df7a81fa9061a4a841 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 9 Jan 2023 14:23:40 -0500 Subject: [PATCH 2/8] fix setting the bpmn dir in start scripts w/ burnettk --- spiffworkflow-backend/bin/find_sample_process_models | 8 ++++---- spiffworkflow-backend/bin/run_server_locally | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spiffworkflow-backend/bin/find_sample_process_models b/spiffworkflow-backend/bin/find_sample_process_models index f5b6d1cf8..525996399 100755 --- a/spiffworkflow-backend/bin/find_sample_process_models +++ b/spiffworkflow-backend/bin/find_sample_process_models @@ -18,13 +18,13 @@ if [[ -z "${BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then exit 1 fi fi - export BPMN_SPEC_ABSOLUTE_DIR - pushd "$BPMN_SPEC_ABSOLUTE_DIR" + + pushd "$BPMN_SPEC_ABSOLUTE_DIR" >/dev/null 2>&1 if [[ "$(git rev-parse --abbrev-ref HEAD)" == "main" ]]; then >&2 echo "ERROR: please do not use the main branch of sample-process-models. use dev" exit 1 fi - popd + popd >/dev/null 2>&1 fi -echo "$BPMN_SPEC_ABSOLUTE_DIR" +realpath "$BPMN_SPEC_ABSOLUTE_DIR" diff --git a/spiffworkflow-backend/bin/run_server_locally b/spiffworkflow-backend/bin/run_server_locally index e0bc15826..17691b9e4 100755 --- a/spiffworkflow-backend/bin/run_server_locally +++ b/spiffworkflow-backend/bin/run_server_locally @@ -19,7 +19,6 @@ fi BPMN_SPEC_ABSOLUTE_DIR=$(./bin/find_sample_process_models) export BPMN_SPEC_ABSOLUTE_DIR -echo "$BPMN_SPEC_ABSOLUTE_DIR" export FLASK_SESSION_SECRET_KEY=super_secret_key export APPLICATION_ROOT="/" From 33653fb1b4ec98c47d404830c91058bd24b7c19f Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 9 Jan 2023 14:35:36 -0500 Subject: [PATCH 3/8] checkout sample to test out docker build w/ burnettk --- .github/workflows/backend_tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index 388f3d3b8..89cca7be1 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -215,6 +215,11 @@ jobs: with: # Disabling shallow clone is recommended for improving relevancy of reporting in sonarcloud fetch-depth: 0 + - name: Checkout Samples + uses: actions/checkout@v3 + with: + repository: sartography/sample-process-models + path: sample-process-models - name: start_backend run: ./bin/build_and_run_with_docker_compose timeout-minutes: 20 From 799a5da2311da461f01b614cfefb0c0f349e82a6 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 9 Jan 2023 14:40:59 -0500 Subject: [PATCH 4/8] pyl w/ burnettk --- .../src/spiffworkflow_backend/services/data_setup_service.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/data_setup_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/data_setup_service.py index 96f662ec9..1dd384acf 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/data_setup_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/data_setup_service.py @@ -50,8 +50,6 @@ class DataSetupService: ) ) - current_app.logger.debug( - "DataSetupService.save_all_process_models() end" - ) + current_app.logger.debug("DataSetupService.save_all_process_models() end") db.session.commit() return failing_process_models From f35db3aa707e4b0e446e20416f387dd2e46e3538 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 9 Jan 2023 14:49:36 -0500 Subject: [PATCH 5/8] fixed typeguard tests w/ burnettk --- .../spiffworkflow_backend/routes/process_models_controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py index b0030c042..bb14f8b5e 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py @@ -42,7 +42,7 @@ from spiffworkflow_backend.services.spec_file_service import SpecFileService def process_model_create( - modified_process_group_id: str, body: Dict[str, Union[str, bool, int]] + modified_process_group_id: str, body: Dict[str, Union[str, bool, int, None, list]] ) -> flask.wrappers.Response: """Process_model_create.""" body_include_list = [ @@ -93,7 +93,7 @@ def process_model_delete( def process_model_update( - modified_process_model_identifier: str, body: Dict[str, Union[str, bool, int]] + modified_process_model_identifier: str, body: Dict[str, Union[str, bool, int, None, list]] ) -> Any: """Process_model_update.""" process_model_identifier = modified_process_model_identifier.replace(":", "/") From c18eafa8129102c5bd5a69480c2a0141ee91c07c Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 9 Jan 2023 15:53:13 -0500 Subject: [PATCH 6/8] fixed typeguard tests w/ burnettk --- spiffworkflow-backend/poetry.lock | 4 ++-- spiffworkflow-backend/pyproject.toml | 2 +- .../routes/process_models_controller.py | 3 ++- .../routes/secrets_controller.py | 6 +++--- .../process_instance_report_service.py | 19 +++++++++++-------- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/spiffworkflow-backend/poetry.lock b/spiffworkflow-backend/poetry.lock index c63b889bb..b726c91af 100644 --- a/spiffworkflow-backend/poetry.lock +++ b/spiffworkflow-backend/poetry.lock @@ -1851,7 +1851,7 @@ lxml = "*" type = "git" url = "https://github.com/sartography/SpiffWorkflow" reference = "main" -resolved_reference = "4195453a46638f23e87c3ffdb038717c2d8abd00" +resolved_reference = "5eed83ab12f67c01c7836424a22fc425a33fc55d" [[package]] name = "SQLAlchemy" @@ -2222,7 +2222,7 @@ testing = ["flake8 (<5)", "func-timeout", "jaraco.functools", "jaraco.itertools" [metadata] lock-version = "1.1" python-versions = ">=3.9,<3.12" -content-hash = "bbbd1c8bdce7f3dd7ec17c62b85dc7c95045fe500a759bb1a89c93add58a2a25" +content-hash = "832c1b6cd8d9aebc8529fdce11167bddcb3634fd0767dd2e490b74ababcf2714" [metadata.files] alabaster = [ diff --git a/spiffworkflow-backend/pyproject.toml b/spiffworkflow-backend/pyproject.toml index c41350d84..b43d1ec3d 100644 --- a/spiffworkflow-backend/pyproject.toml +++ b/spiffworkflow-backend/pyproject.toml @@ -79,7 +79,7 @@ pytest = "*" coverage = {extras = ["toml"], version = "^6.1"} safety = "^2.3.1" mypy = ">=0.961" -typeguard = "^2.13.2" +typeguard = "^2" xdoctest = {extras = ["colors"], version = "^1.0.1"} sphinx = "^5.0.2" sphinx-autobuild = ">=2021.3.14" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py index bb14f8b5e..4e129deb6 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py @@ -93,7 +93,8 @@ def process_model_delete( def process_model_update( - modified_process_model_identifier: str, body: Dict[str, Union[str, bool, int, None, list]] + modified_process_model_identifier: str, + body: Dict[str, Union[str, bool, int, None, list]], ) -> Any: """Process_model_update.""" process_model_identifier = modified_process_model_identifier.replace(":", "/") diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/secrets_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/secrets_controller.py index fdf4c7fae..e922d5a1a 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/secrets_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/secrets_controller.py @@ -1,7 +1,6 @@ """APIs for dealing with process groups, process models, and process instances.""" import json from typing import Dict -from typing import Optional from flask import g from flask import jsonify @@ -15,9 +14,10 @@ from spiffworkflow_backend.services.secret_service import SecretService from spiffworkflow_backend.services.user_service import UserService -def secret_show(key: str) -> Optional[str]: +def secret_show(key: str) -> Response: """Secret_show.""" - return SecretService.get_secret(key) + secret = SecretService.get_secret(key) + return make_response(jsonify(secret), 200) def secret_list( diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py index 8d37b859f..a4b6a9b18 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py @@ -3,10 +3,11 @@ import re from dataclasses import dataclass from typing import Any from typing import Optional +from typing import Type import sqlalchemy from flask_bpmn.api.api_error import ApiError -from flask_bpmn.models.db import db +from flask_bpmn.models.db import SpiffworkflowBaseDBModel from sqlalchemy import and_ from sqlalchemy import func from sqlalchemy import or_ @@ -113,16 +114,16 @@ class ProcessInstanceReportService: {"Header": "status", "accessor": "status"}, ], "filter_by": [ - {"field_name": "initiated_by_me", "field_value": True}, - {"field_name": "has_terminal_status", "field_value": True}, + {"field_name": "initiated_by_me", "field_value": "true"}, + {"field_name": "has_terminal_status", "field_value": "true"}, ], "order_by": ["-start_in_seconds", "-id"], }, "system_report_completed_instances_with_tasks_completed_by_me": { "columns": cls.builtin_column_options(), "filter_by": [ - {"field_name": "with_tasks_completed_by_me", "field_value": True}, - {"field_name": "has_terminal_status", "field_value": True}, + {"field_name": "with_tasks_completed_by_me", "field_value": "true"}, + {"field_name": "has_terminal_status", "field_value": "true"}, ], "order_by": ["-start_in_seconds", "-id"], }, @@ -131,9 +132,9 @@ class ProcessInstanceReportService: "filter_by": [ { "field_name": "with_tasks_assigned_to_my_group", - "field_value": True, + "field_value": "true", }, - {"field_name": "has_terminal_status", "field_value": True}, + {"field_name": "has_terminal_status", "field_value": "true"}, ], "order_by": ["-start_in_seconds", "-id"], }, @@ -319,7 +320,9 @@ class ProcessInstanceReportService: return results @classmethod - def get_column_names_for_model(cls, model: db.Model) -> list[str]: # type: ignore + def get_column_names_for_model( + cls, model: Type[SpiffworkflowBaseDBModel] + ) -> list[str]: """Get_column_names_for_model.""" return [i.name for i in model.__table__.columns] From 73302c9ef69dfb7b8721522df522496ac7b29d2e Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 9 Jan 2023 16:00:02 -0500 Subject: [PATCH 7/8] fixed cypress config w/ burnettk --- spiffworkflow-frontend/cypress.config.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/spiffworkflow-frontend/cypress.config.js b/spiffworkflow-frontend/cypress.config.js index 3d6c7410e..770a3b0d9 100644 --- a/spiffworkflow-frontend/cypress.config.js +++ b/spiffworkflow-frontend/cypress.config.js @@ -24,12 +24,9 @@ const deleteVideosOnSuccess = (on) => { }) } -module.exports = defineConfig({ +const cypressConfig = { projectId: 'crax1q', - // since it's slow - videoCompression: useVideoCompression, - videoUploadOnPasses: false, chromeWebSecurity: false, e2e: { @@ -45,4 +42,11 @@ module.exports = defineConfig({ // https://github.com/cypress-io/cypress/issues/2353 // https://docs.cypress.io/guides/core-concepts/interacting-with-elements#Scrolling scrollBehavior: "center", -}); +} + +if (!process.env.CYPRESS_RECORD_KEY) { + // since it's slow + cypressConfig.videoCompression = false +} + +module.exports = defineConfig(cypressConfig) From fa3d727b6073d4abcd8755bc9b9b139c378574d7 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 9 Jan 2023 16:24:36 -0500 Subject: [PATCH 8/8] added in debug logging for launching call activity editor w/ burnettk --- spiffworkflow-backend/bin/run_server_locally | 1 - .../src/components/ReactDiagramEditor.tsx | 8 +++++--- .../src/routes/ProcessModelEditDiagram.tsx | 3 +++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/spiffworkflow-backend/bin/run_server_locally b/spiffworkflow-backend/bin/run_server_locally index 17691b9e4..3e9f712b6 100755 --- a/spiffworkflow-backend/bin/run_server_locally +++ b/spiffworkflow-backend/bin/run_server_locally @@ -29,7 +29,6 @@ else export FLASK_DEBUG=1 if [[ "${SPIFFWORKFLOW_BACKEND_RUN_DATA_SETUP:-}" != "false" ]]; then - echo "RUNING STUFF" SPIFFWORKFLOW_BACKEND_FAIL_ON_INVALID_PROCESS_MODELS=false poetry run python bin/save_all_bpmn.py fi FLASK_APP=src/spiffworkflow_backend poetry run flask run -p 7000 diff --git a/spiffworkflow-frontend/src/components/ReactDiagramEditor.tsx b/spiffworkflow-frontend/src/components/ReactDiagramEditor.tsx index 3e744ddce..82996b6aa 100644 --- a/spiffworkflow-frontend/src/components/ReactDiagramEditor.tsx +++ b/spiffworkflow-frontend/src/components/ReactDiagramEditor.tsx @@ -264,11 +264,13 @@ export default function ReactDiagramEditor({ handleLaunchMarkdownEditor(element, value, eventBus); }); - /** - * fixme: this is not in use yet, we need the ability to find bpmn files by id. - */ diagramModeler.on('spiff.callactivity.edit', (event: any) => { + console.log('Received event spiff.callactivity.edit'); if (onLaunchBpmnEditor) { + console.log( + 'Calling function onLaunchBpmnEditor with ', + event.processId + ); onLaunchBpmnEditor(event.processId); } }); diff --git a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx index cc3ac8789..f4984cfc4 100644 --- a/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx +++ b/spiffworkflow-frontend/src/routes/ProcessModelEditDiagram.tsx @@ -826,10 +826,13 @@ export default function ProcessModelEditDiagram() { }; const onLaunchBpmnEditor = (processId: string) => { + console.log('onLaunchBpmnEditor - processId: ', processId); + console.log('processes', processes); const processRef = processes.find((p) => { return p.identifier === processId; }); if (processRef) { + console.log('Found ProcessRef: ', processRef); const path = generatePath( '/admin/process-models/:process_model_path/files/:file_name', {