From d2e2478e06761a18a31409b06a0d76df2fef4b33 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 17 May 2023 14:04:48 -0400 Subject: [PATCH 1/6] fixed pyl issues and set max threads based on cpu cores w/ burnettk --- spiffworkflow-backend/bin/boot_server_in_docker | 4 ++-- spiffworkflow-frontend/src/App.tsx | 4 ++-- .../src/components/ScrollToTop.tsx | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spiffworkflow-backend/bin/boot_server_in_docker b/spiffworkflow-backend/bin/boot_server_in_docker index a26adc739..96d3d79fd 100755 --- a/spiffworkflow-backend/bin/boot_server_in_docker +++ b/spiffworkflow-backend/bin/boot_server_in_docker @@ -75,14 +75,14 @@ if [[ -z "${SPIFFWORKFLOW_BACKEND_THREADS_PER_WORKER:-}" ]]; then # I/O heavy, make it larger threads_to_use_per_core=3 - # just making up a number here for num_cores_multiple_for_threads # https://stackoverflow.com/a/55423170/6090676 # if we had access to python (i'm not sure i want to run another python script here), # we could do something like this (on linux) to get the number of cores available to this process and a better estimate of a # reasonable num_cores_multiple_for_threads # if hasattr(os, 'sched_getaffinity') # number_of_available_cores = os.sched_getaffinity(0) - num_cores_multiple_for_threads=2 + # BUT the python solution isn't even as portable as this one, which is mostly posix compliant and works on linux/mac/freebsd. + num_cores_multiple_for_threads=$(getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSORS_ONLN 2>/dev/null || echo 1) SPIFFWORKFLOW_BACKEND_THREADS_PER_WORKER=$((threads_to_use_per_core * num_cores_multiple_for_threads)) export SPIFFWORKFLOW_BACKEND_THREADS_PER_WORKER diff --git a/spiffworkflow-frontend/src/App.tsx b/spiffworkflow-frontend/src/App.tsx index 17afca14d..cddc30615 100644 --- a/spiffworkflow-frontend/src/App.tsx +++ b/spiffworkflow-frontend/src/App.tsx @@ -3,6 +3,7 @@ import { Content } from '@carbon/react'; import { BrowserRouter, Routes, Route } from 'react-router-dom'; import { defineAbility } from '@casl/ability'; +import React from 'react'; import NavigationBar from './components/NavigationBar'; import HomePageRoutes from './routes/HomePageRoutes'; @@ -15,8 +16,7 @@ import { AbilityContext } from './contexts/Can'; import UserService from './services/UserService'; import ErrorDisplay from './components/ErrorDisplay'; import APIErrorProvider from './contexts/APIErrorContext'; -import ScrollToTop from "./components/ScrollToTop"; -import React from "react"; +import ScrollToTop from './components/ScrollToTop'; export default function App() { if (!UserService.isLoggedIn()) { diff --git a/spiffworkflow-frontend/src/components/ScrollToTop.tsx b/spiffworkflow-frontend/src/components/ScrollToTop.tsx index 01d0b5806..7d8c6f1a6 100644 --- a/spiffworkflow-frontend/src/components/ScrollToTop.tsx +++ b/spiffworkflow-frontend/src/components/ScrollToTop.tsx @@ -1,12 +1,12 @@ -import { useEffect } from "react"; -import { useLocation } from "react-router-dom"; +import { useEffect } from 'react'; +import { useLocation } from 'react-router-dom'; export default function ScrollToTop() { - const { pathname } = useLocation(); + const { pathname } = useLocation(); - useEffect(() => { - window.scrollTo(0, 0); - }, [pathname]); + useEffect(() => { + window.scrollTo(0, 0); + }, [pathname]); - return null; -} \ No newline at end of file + return null; +} From f0feb6bb7383b7b48f355e470cf56cbda45c1e76 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 17 May 2023 14:06:50 -0400 Subject: [PATCH 2/6] ignore windows tests in ci w/ burnettk --- .github/workflows/backend_tests.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/backend_tests.yml b/.github/workflows/backend_tests.yml index 9e7cb8212..9d36ebc3b 100644 --- a/.github/workflows/backend_tests.yml +++ b/.github/workflows/backend_tests.yml @@ -50,12 +50,15 @@ jobs: session: "tests", database: "sqlite", } - - { - python: "3.10", - os: "windows-latest", - session: "tests", - database: "sqlite", - } + # FIXME: tests cannot pass on windows and we currently cannot debug + # since none of us have a windows box that can run the python app. + # so ignore windows tests until we can get it fixed. + # - { + # python: "3.10", + # os: "windows-latest", + # session: "tests", + # database: "sqlite", + # } - { python: "3.11", os: "macos-latest", From c389bbff28d51d6882beebd641180321e4246102 Mon Sep 17 00:00:00 2001 From: burnettk Date: Wed, 17 May 2023 14:13:37 -0400 Subject: [PATCH 3/6] sort version keys --- spiffworkflow-frontend/src/routes/About.tsx | 24 +++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/spiffworkflow-frontend/src/routes/About.tsx b/spiffworkflow-frontend/src/routes/About.tsx index 1b1da8b73..786521d87 100644 --- a/spiffworkflow-frontend/src/routes/About.tsx +++ b/spiffworkflow-frontend/src/routes/About.tsx @@ -28,17 +28,19 @@ export default function About() { versionInfoDict: ObjectWithStringKeysAndValues | null ) => { if (versionInfoDict !== null && Object.keys(versionInfoDict).length) { - const tableRows = Object.keys(versionInfoDict).map((key) => { - const value = versionInfoDict[key]; - return ( - - - {key} - - {value} - - ); - }); + const tableRows = Object.keys(versionInfoDict) + .sort() + .map((key) => { + const value = versionInfoDict[key]; + return ( + + + {key} + + {value} + + ); + }); return ( <>

From f71cf1450e5dc68c08870dada79c2dc995163a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 18 May 2023 11:03:52 +0200 Subject: [PATCH 4/6] ci: add deploy tag to commit to avoid race conditions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When parallel builds for different environments run on the same host at the same time then the one that finishes last overwrites the Docker image that was built first, since the commit will be the same. "So the last shall be first, and the first last: for many be called, but few chosen." Matthew 20:16, King James Bible Signed-off-by: Jakub SokoĊ‚owski --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6869169aa..c5e01c28c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -63,8 +63,9 @@ pipeline { stage('Build') { steps { script { dir("spiffworkflow-${params.COMPONENT}") { + /* Tag and Commit is combined to avoid clashes of parallel builds. */ image = docker.build( - "${params.DOCKER_NAME}:${env.GIT_COMMIT.take(8)}", + "${params.DOCKER_NAME}:${params.DOCKER_TAG}-${env.GIT_COMMIT.take(8)}", "--label=commit='${env.GIT_COMMIT.take(8)}' ." ) } From 7bfe43d617db1549b9b9f5c9feff7d56f18234f3 Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 18 May 2023 09:05:26 -0400 Subject: [PATCH 5/6] added example permission yaml for read only admin --- .../config/permissions/example_read_only.yml | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/example_read_only.yml diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/example_read_only.yml b/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/example_read_only.yml new file mode 100644 index 000000000..d201a555d --- /dev/null +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/permissions/example_read_only.yml @@ -0,0 +1,84 @@ +default_group: everybody + +groups: + admin: + users: [admin@spiffworkflow.org] + +permissions: + admin: + groups: [admin] + users: [] + allowed_permissions: [read] + uri: /* + + tasks-crud: + groups: [admin] + users: [] + allowed_permissions: [create, update, delete] + uri: /tasks/* + + process-instances-crud: + groups: [ admin ] + users: [ ] + allowed_permissions: [create, update, delete] + uri: /process-instances/* + + suspend: + groups: [admin] + users: [] + allowed_permissions: [create] + uri: /v1.0/process-instance-suspend + + terminate: + groups: [admin] + users: [] + allowed_permissions: [create] + uri: /v1.0/process-instance-terminate + + resume: + groups: [admin] + users: [] + allowed_permissions: [create] + uri: /v1.0/process-instance-resume + + reset: + groups: [admin] + users: [] + allowed_permissions: [create] + uri: /v1.0/process-instance-reset + + users-exist: + groups: [admin] + users: [] + allowed_permissions: [create] + uri: /v1.0/users/exists/by-username + + send-event: + groups: [admin] + users: [] + allowed_permissions: [create] + uri: /v1.0/send-event/* + + task-complete: + groups: [admin] + users: [] + allowed_permissions: [create] + uri: /v1.0/task-complete/* + + messages: + groups: [admin] + users: [] + allowed_permissions: [create] + uri: /v1.0/messages/* + + secrets: + groups: [admin] + users: [] + allowed_permissions: [create, update, delete] + uri: /v1.0/secrets/* + + task-data: + groups: [admin] + users: [] + allowed_permissions: [update] + uri: /v1.0/task-data/* From c4e236e7372bc4895464b2a9ef9c8daf2a70c14e Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 18 May 2023 10:11:24 -0400 Subject: [PATCH 6/6] if username and email are the same then display username only w/ burnettk --- .../src/components/NavigationBar.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spiffworkflow-frontend/src/components/NavigationBar.tsx b/spiffworkflow-frontend/src/components/NavigationBar.tsx index 54064dc17..b9301d9fc 100644 --- a/spiffworkflow-frontend/src/components/NavigationBar.tsx +++ b/spiffworkflow-frontend/src/components/NavigationBar.tsx @@ -97,6 +97,9 @@ export default function NavigationBar() { aboutLinkElement = About; } + const userEmail = UserService.getUserEmail(); + const username = UserService.getPreferredUsername(); + const profileToggletip = (
@@ -105,15 +108,13 @@ export default function NavigationBar() { className="user-profile-toggletip-button" type="button" > -
- {UserService.getPreferredUsername()[0].toUpperCase()} -
+
{username[0].toUpperCase()}

- {UserService.getPreferredUsername()} + {username}

-

{UserService.getUserEmail()}

+ {username !== userEmail &&

{userEmail}

}
{aboutLinkElement}