From e9322b29c18cd41a4e6f8e87c5060c7a0c8d8908 Mon Sep 17 00:00:00 2001 From: usama9500 <96994784+usama9500@users.noreply.github.com> Date: Mon, 26 Jun 2023 19:40:42 +0500 Subject: [PATCH 1/5] fixing main (#351) --- .../find_an_Instance_assigned_to_myself.md | 6 ------ .../navigate_to_an_active_process_instance.md | 5 +---- docs/how_to/resume_a_process.md | 1 - docs/how_to/view_process_variables.md | 1 - docs/index.md | 17 ++++++++++++++++- docs/learn_basics/learn_basics.md | 4 ++-- docs/spiffworkflow/process_groups_and_models.md | 1 - 7 files changed, 19 insertions(+), 16 deletions(-) delete mode 100644 docs/spiffworkflow/process_groups_and_models.md diff --git a/docs/how_to/find_an_Instance_assigned_to_myself.md b/docs/how_to/find_an_Instance_assigned_to_myself.md index cfc28eb26..866adea37 100644 --- a/docs/how_to/find_an_Instance_assigned_to_myself.md +++ b/docs/how_to/find_an_Instance_assigned_to_myself.md @@ -31,9 +31,3 @@ If the Instance can not be find by searhing the list, follow these steps to sear [How to find an Instance assigned to someone else](https://github.com/sartography/spiff-arena/blob/main/docs/how_to/find_an_Instance_assigned_to_someone_else.md) -## **Outcome** - -| ✅ Success | 🚫 Error | -| ------------------------------------------------------------ | :------------------------------------------------------------ | -| The system will then display the parent process that contains the active instance searched for. [How to view process variables](https://github.com/sartography/spiff-arena/blob/main/docs/how_to/view_process_variables.md) | Process instance Id does not exist ![suspend_status](images\process_instance_not_found.png) Repeat Step 2 with correct Id. Note: if the instance is not active anymore, you should be able to search for it.| - diff --git a/docs/how_to/navigate_to_an_active_process_instance.md b/docs/how_to/navigate_to_an_active_process_instance.md index 29f45fe00..bedbeab23 100644 --- a/docs/how_to/navigate_to_an_active_process_instance.md +++ b/docs/how_to/navigate_to_an_active_process_instance.md @@ -48,10 +48,7 @@ If the desired task or process you would like to view is not found in the parent A pop-up menu will appear. Select ‘View Call Activity Diagram’ to navigate to the sub-process. -```{image} images/call_activity_popup.png - - ---- +![Untitled](images/call_activity_popup.png) ## **Outcome** diff --git a/docs/how_to/resume_a_process.md b/docs/how_to/resume_a_process.md index 96e0d9c3b..07af13cfa 100644 --- a/docs/how_to/resume_a_process.md +++ b/docs/how_to/resume_a_process.md @@ -4,5 +4,4 @@ | ⚙ How do I get there \| Menu hierarchy | | --- | | Find an **active** Process Instance | ---- diff --git a/docs/how_to/view_process_variables.md b/docs/how_to/view_process_variables.md index 96e0d9c3b..07af13cfa 100644 --- a/docs/how_to/view_process_variables.md +++ b/docs/how_to/view_process_variables.md @@ -4,5 +4,4 @@ | ⚙ How do I get there \| Menu hierarchy | | --- | | Find an **active** Process Instance | ---- diff --git a/docs/index.md b/docs/index.md index d4e2ae021..f79880cb8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,8 +1,9 @@ # Welcome to SpiffWorkflow's documentation ```{toctree} -:maxdepth: 2 +:maxdepth: 3 :caption: Getting Started +UsingSpiffdemo/Getting_Started.md learn_basics/learn_basics.md quick_start/quick_start.md ``` @@ -51,6 +52,20 @@ learn_basics/bpmn_terminology.md ``` +```{toctree} +:maxdepth: 3 +:caption: Fix me unlinked files +how_to/complete_a_task_on_behalf_of_another_user.md +how_to/edit_process_variables.md +how_to/find_an_Instance_assigned_to_myself.md +how_to/find_an_Instance_assigned_to_someone_else.md +how_to/navigate_to_an_active_process_instance.md +how_to/resume_a_process.md +how_to/suspend_a_process.md +how_to/view_process_variables.md +spiffworkflow/process_instance.md +``` + ## Indices and tables diff --git a/docs/learn_basics/learn_basics.md b/docs/learn_basics/learn_basics.md index 83fd82b81..71bfae53a 100644 --- a/docs/learn_basics/learn_basics.md +++ b/docs/learn_basics/learn_basics.md @@ -36,7 +36,7 @@ Tasks represent activities or work that needs to be performed as part of a proce | **Task** | **Symbol** | **Description** | |---------------|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Service |![Untitled](images/Service_task.png) | Task that uses a Web service, an automated application, or other kinds of service in completing the task. | +| Service |
![Untitled](images/Service_task.png) | Task that uses a Web service, an automated application, or other kinds of service in completing the task. | | Send |![Untitled](images/Send.png) | Task that sends a Message to another pool. The Task is completed once the Message has been sent. | | Receive | ![Untitled](images/Receive.png) | A Receive Task indicates that the process has to wait for a message to arrive in order to continue. The Task is completed once the| message has received. | | User | ![Untitled](images/User.png) | A User Task represents that a human performer performs the Task with the use of a software application. | @@ -50,7 +50,7 @@ Tasks represent activities or work that needs to be performed as part of a proce Artifacts are used to provide additional information or documentation within a process. They include data objects (representing information or data needed for the process), annotations (providing explanatory or descriptive text), and groups (used to visually group related elements). | **Artifact** | **Symbol** | **Description** | |---------------|------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Data Object |![Untitled](images/Data_Object.png) | Data objects can represent data placed to the process, data resulting from the process, data that needs to be collected | +| Data Object |
![Untitled](images/Data_Object.png) | Data objects can represent data placed to the process, data resulting from the process, data that needs to be collected | | Data Storage |![Untitled](images/Data_Storage.png) | Data storage provides the ability to store or access data that is associated with a business model. If your process outputs any data, it will become necessary to store that data. | | Group |
![Untitled](images/Group.png) | Groups organize tasks or processes that have significance in the overall process.​​ | | Annotation |
![Untitled](images/Annotation.png) | Annotations allow you to describe the business process and flow objects in more detail. | diff --git a/docs/spiffworkflow/process_groups_and_models.md b/docs/spiffworkflow/process_groups_and_models.md deleted file mode 100644 index e4ca97d1a..000000000 --- a/docs/spiffworkflow/process_groups_and_models.md +++ /dev/null @@ -1 +0,0 @@ -# Navigating Spiffworkflow From 6ba2d23e0922c47c227d520765501d5ca33132df Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 26 Jun 2023 11:33:27 -0400 Subject: [PATCH 2/5] added build command for docs and created github action w/ burnettk --- .github/workflows/docs.yml | 42 ++++++++++++++++++++++++++++++++++++++ docs/bin/build | 27 ++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/docs.yml create mode 100755 docs/bin/build diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 000000000..461534450 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,42 @@ +name: Docs + +on: + - push + - pull_request + +defaults: + run: + working-directory: docs + +jobs: + build: + name: build-docs + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v3.3.0 + + - name: Set up Python + uses: actions/setup-python@v4.6.1 + with: + python-version: 3.11 + + - name: Upgrade pip + run: | + pip install --constraint=.github/workflows/constraints.txt pip + pip --version + + - name: Upgrade pip in virtual environments + shell: python + run: | + import os + import pip + + with open(os.environ["GITHUB_ENV"], mode="a") as io: + print(f"VIRTUALENV_PIP={pip.__version__}", file=io) + - name: Pip Install + run: | + pip install -r requirements.txt + - name: Build + run: | + ./bin/build --ci diff --git a/docs/bin/build b/docs/bin/build new file mode 100755 index 000000000..c8fa07819 --- /dev/null +++ b/docs/bin/build @@ -0,0 +1,27 @@ +#!/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 + +run_ci="false" +if grep -qE -- "--ci\>" <<<"$@" ; then + run_ci="true" +fi + +rm -rf _build/html + +sphinx_command="sphinx-autobuild" +if [[ "$run_ci" == "true" ]]; then + sphinx_command="sphinx-build" +fi + +#>> sphinx-build --help 2>&1 | grep -E '^ +\-[aWn]\>' +# -a write all files (default: only write new and changed +# -j N build in parallel with N processes where possible +# -n nit-picky mode, warn about all missing references +# -W turn warnings into errors +"$sphinx_command" . _build/html -W -a -n -j auto From e9fdb9b0e93f063ca10aef7a8117de1357824ad9 Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 26 Jun 2023 11:36:20 -0400 Subject: [PATCH 3/5] remove unnecessary pip upgrade for docs w/ burnettk --- .github/workflows/docs.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 461534450..7b6ddb9df 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -20,20 +20,6 @@ jobs: uses: actions/setup-python@v4.6.1 with: python-version: 3.11 - - - name: Upgrade pip - run: | - pip install --constraint=.github/workflows/constraints.txt pip - pip --version - - - name: Upgrade pip in virtual environments - shell: python - run: | - import os - import pip - - with open(os.environ["GITHUB_ENV"], mode="a") as io: - print(f"VIRTUALENV_PIP={pip.__version__}", file=io) - name: Pip Install run: | pip install -r requirements.txt From 9cf9bb6bf0537883762d95f650e03de647f165fc Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 26 Jun 2023 11:38:45 -0400 Subject: [PATCH 4/5] notify slack if build docs failed w/ burnettk --- .github/workflows/docs.yml | 2 +- .github/workflows/slack_notify.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7b6ddb9df..8dc896221 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: Docs +name: Build Docs on: - push diff --git a/.github/workflows/slack_notify.yml b/.github/workflows/slack_notify.yml index f3c640752..886f968ad 100644 --- a/.github/workflows/slack_notify.yml +++ b/.github/workflows/slack_notify.yml @@ -2,7 +2,7 @@ name: Slack Notification on: workflow_run: - workflows: ["Backend Tests", "Frontend Tests", "Docker Image For Main Builds", "Release Builds"] + workflows: ["Backend Tests", "Frontend Tests", "Docker Image For Main Builds", "Release Builds", "Build Docs"] types: [completed] jobs: From b13b716424ecd310d074c842db77a6fa1930fcfa Mon Sep 17 00:00:00 2001 From: Kevin Burnett <18027+burnettk@users.noreply.github.com> Date: Mon, 26 Jun 2023 10:07:41 -0700 Subject: [PATCH 5/5] parallel tests with xdist (#335) * parallel tests with xdist * add pytest-xdist as dev dep * put back spiff * update messaging * get more in line with main --------- Co-authored-by: burnettk Co-authored-by: jasquat --- spiffworkflow-backend/bin/recreate_db | 7 ++++ spiffworkflow-backend/bin/tests-par | 21 ++++++++++ spiffworkflow-backend/poetry.lock | 38 ++++++++++++++++++- spiffworkflow-backend/pyproject.toml | 1 + .../spiffworkflow_backend/config/__init__.py | 7 +++- .../config/unit_testing.py | 6 ++- 6 files changed, 77 insertions(+), 3 deletions(-) create mode 100755 spiffworkflow-backend/bin/tests-par diff --git a/spiffworkflow-backend/bin/recreate_db b/spiffworkflow-backend/bin/recreate_db index 13a3bede6..4535d6f48 100755 --- a/spiffworkflow-backend/bin/recreate_db +++ b/spiffworkflow-backend/bin/recreate_db @@ -94,3 +94,10 @@ if [[ -n "${SPIFFWORKFLOW_BACKEND_ENV:-}" ]] && ! grep -Eq '^(local_development| fi FLASK_APP=src/spiffworkflow_backend poetry run flask db upgrade fi + +# for ./bin/tests-par (parallel tests with xdist) +if [[ -f "./src/instance/db_unit_testing.sqlite3" ]] ; then + for i in $(seq 0 16); do + cp ./src/instance/db_unit_testing.sqlite3 ./src/instance/db_unit_testing_gw$i.sqlite3 + done +fi diff --git a/spiffworkflow-backend/bin/tests-par b/spiffworkflow-backend/bin/tests-par new file mode 100755 index 000000000..f8b4de274 --- /dev/null +++ b/spiffworkflow-backend/bin/tests-par @@ -0,0 +1,21 @@ +#!/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 [[ ! -f ./src/instance/db_unit_testing_gw0.sqlite3 ]] ; then + >&2 echo -e "ERROR: please run the following command first in order to set up and migrate the sqlite unit_testing database:\n\n\tSPIFFWORKFLOW_BACKEND_DATABASE_TYPE=sqlite ./bin/recreate_db clean" + exit 1 +fi + +# check if python package pytest-xdist is installed +if ! python -c "import xdist" &>/dev/null; then + >&2 echo -e "ERROR: please install the python package pytest-xdist by running poetry install" + exit 1 +fi + +SPIFFWORKFLOW_BACKEND_DATABASE_TYPE=sqlite poet test -n auto -x --ff diff --git a/spiffworkflow-backend/poetry.lock b/spiffworkflow-backend/poetry.lock index d16ae8f02..34e178c20 100644 --- a/spiffworkflow-backend/poetry.lock +++ b/spiffworkflow-backend/poetry.lock @@ -643,6 +643,21 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "execnet" +version = "1.9.0" +description = "execnet: rapid multi-Python deployment" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +files = [ + {file = "execnet-1.9.0-py2.py3-none-any.whl", hash = "sha256:a295f7cc774947aac58dde7fdc85f4aa00c42adf5d8f5468fc630c1acf30a142"}, + {file = "execnet-1.9.0.tar.gz", hash = "sha256:8f694f3ba9cc92cab508b152dcfe322153975c29bda272e2fd7f3f00f36e47c5"}, +] + +[package.extras] +testing = ["pre-commit"] + [[package]] name = "filelock" version = "3.11.0" @@ -1852,6 +1867,27 @@ pytest = ">=5.0" [package.extras] dev = ["pre-commit", "pytest-asyncio", "tox"] +[[package]] +name = "pytest-xdist" +version = "3.3.1" +description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-xdist-3.3.1.tar.gz", hash = "sha256:d5ee0520eb1b7bcca50a60a518ab7a7707992812c578198f8b44fdfac78e8c93"}, + {file = "pytest_xdist-3.3.1-py3-none-any.whl", hash = "sha256:ff9daa7793569e6a68544850fd3927cd257cc03a7ef76c95e86915355e82b5f2"}, +] + +[package.dependencies] +execnet = ">=1.1" +pytest = ">=6.2.0" + +[package.extras] +psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] +testing = ["filelock"] + [[package]] name = "python-dateutil" version = "2.8.2" @@ -2839,4 +2875,4 @@ tests-strict = ["codecov (==2.0.15)", "pytest (==4.6.0)", "pytest (==4.6.0)", "p [metadata] lock-version = "2.0" python-versions = ">=3.10,<3.12" -content-hash = "67863394f8de94eaddd20964ae383c6dc3416bbdec623e399b5a8a0d163e5178" +content-hash = "de301503903ea357212400d7cf27feffe5a73b2733c0b4f2c39cabf3de3b9bc7" diff --git a/spiffworkflow-backend/pyproject.toml b/spiffworkflow-backend/pyproject.toml index 341249752..5994128af 100644 --- a/spiffworkflow-backend/pyproject.toml +++ b/spiffworkflow-backend/pyproject.toml @@ -82,6 +82,7 @@ prometheus-flask-exporter = "^0.22.3" sqlalchemy = "^2.0.7" marshmallow-sqlalchemy = "^0.29.0" spiff-element-units = "^0.3.0" +pytest-xdist = "^3.3.1" [tool.poetry.dev-dependencies] pytest = "^7.1.2" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py index 08489df27..f8aac7977 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/__init__.py @@ -18,11 +18,16 @@ class ConfigurationError(Exception): def setup_database_configs(app: Flask) -> None: + worker_id = os.environ.get("PYTEST_XDIST_WORKER") + parallel_test_suffix = "" + if worker_id is not None: + parallel_test_suffix = f"_{worker_id}" + if app.config.get("SPIFFWORKFLOW_BACKEND_DATABASE_URI") is None: database_name = f"spiffworkflow_backend_{app.config['ENV_IDENTIFIER']}" if app.config.get("SPIFFWORKFLOW_BACKEND_DATABASE_TYPE") == "sqlite": app.config["SQLALCHEMY_DATABASE_URI"] = ( - f"sqlite:///{app.instance_path}/db_{app.config['ENV_IDENTIFIER']}.sqlite3" + f"sqlite:///{app.instance_path}/db_{app.config['ENV_IDENTIFIER']}{parallel_test_suffix}.sqlite3" ) elif app.config.get("SPIFFWORKFLOW_BACKEND_DATABASE_TYPE") == "postgres": app.config["SQLALCHEMY_DATABASE_URI"] = ( diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py index 92997dd1c..f6711f420 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/unit_testing.py @@ -15,6 +15,10 @@ SPIFFWORKFLOW_BACKEND_GIT_COMMIT_ON_SAVE = False # NOTE: set this here since nox shoves tests and src code to # different places and this allows us to know exactly where we are at the start +worker_id = environ.get("PYTEST_XDIST_WORKER") +parallel_test_suffix = "" +if worker_id is not None: + parallel_test_suffix = f"_{worker_id}" SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR = os.path.join( os.path.dirname(__file__), "..", @@ -23,5 +27,5 @@ SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR = os.path.join( "tests", "spiffworkflow_backend", "files", - "bpmn_specs", + f"bpmn_specs{parallel_test_suffix}", )