This is an automated email from the ASF dual-hosted git repository.

mintsweet pushed a commit to branch feat-dora-config
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git

commit 2988b982903b06def386477314e19ba813749245
Author: mintsweet <0x1304...@gmail.com>
AuthorDate: Wed Sep 18 13:45:32 2024 +1200

    feat: improve the circleci transformation cicd configuration
---
 .../plugins/components/scope-config-form/index.tsx |   2 +
 .../register/circleci/assets/workflow-run.jpeg     | Bin 0 -> 197685 bytes
 .../plugins/register/circleci/transformation.tsx   |  40 ++++++---
 .../src/plugins/register/circleci/workflow-run.tsx |  97 +++++++++++++++++++++
 4 files changed, 129 insertions(+), 10 deletions(-)

diff --git a/config-ui/src/plugins/components/scope-config-form/index.tsx 
b/config-ui/src/plugins/components/scope-config-form/index.tsx
index dae5e8000..162b728de 100644
--- a/config-ui/src/plugins/components/scope-config-form/index.tsx
+++ b/config-ui/src/plugins/components/scope-config-form/index.tsx
@@ -231,6 +231,8 @@ export const ScopeConfigForm = ({
 
               {plugin === 'circleci' && (
                 <CircleCITransformation
+                  plugin="circleci"
+                  connectionId={connectionId}
                   entities={entities}
                   transformation={transformation}
                   setTransformation={setTransformation}
diff --git a/config-ui/src/plugins/register/circleci/assets/workflow-run.jpeg 
b/config-ui/src/plugins/register/circleci/assets/workflow-run.jpeg
new file mode 100644
index 000000000..5f401517f
Binary files /dev/null and 
b/config-ui/src/plugins/register/circleci/assets/workflow-run.jpeg differ
diff --git a/config-ui/src/plugins/register/circleci/transformation.tsx 
b/config-ui/src/plugins/register/circleci/transformation.tsx
index 90a00377d..4dd285076 100644
--- a/config-ui/src/plugins/register/circleci/transformation.tsx
+++ b/config-ui/src/plugins/register/circleci/transformation.tsx
@@ -19,16 +19,27 @@
 import { CaretRightOutlined } from '@ant-design/icons';
 import { theme, Collapse, Tag, Input } from 'antd';
 
-import { ExternalLink, HelpTooltip } from '@/components';
+import { ShowMore, ExternalLink, HelpTooltip } from '@/components';
+import { CheckMatchedItems } from '@/plugins';
 import { DOC_URL } from '@/release';
 
+import { WorkflowRun } from './workflow-run';
+
 interface Props {
+  plugin: string;
+  connectionId: ID;
   entities: string[];
   transformation: any;
   setTransformation: React.Dispatch<React.SetStateAction<any>>;
 }
 
-export const CircleCITransformation = ({ entities, transformation, 
setTransformation }: Props) => {
+export const CircleCITransformation = ({
+  plugin,
+  connectionId,
+  entities,
+  transformation,
+  setTransformation,
+}: Props) => {
   const { token } = theme.useToken();
 
   const panelStyle: React.CSSProperties = {
@@ -46,6 +57,8 @@ export const CircleCITransformation = ({ entities, 
transformation, setTransforma
       style={{ background: token.colorBgContainer }}
       size="large"
       items={renderCollapseItems({
+        plugin,
+        connectionId,
         entities,
         panelStyle,
         transformation,
@@ -56,11 +69,15 @@ export const CircleCITransformation = ({ entities, 
transformation, setTransforma
 };
 
 const renderCollapseItems = ({
+  plugin,
+  connectionId,
   entities,
   panelStyle,
   transformation,
   onChangeTransformation,
 }: {
+  plugin: string;
+  connectionId: ID;
   entities: string[];
   panelStyle: React.CSSProperties;
   transformation: any;
@@ -79,10 +96,12 @@ const renderCollapseItems = ({
               DORA
             </Tag>
           </h3>
-          <p style={{ marginBottom: 16 }}>
-            Use Regular Expression to define Deployments in DevLake in order 
to measure DORA metrics.{' '}
-            <ExternalLink link={DOC_URL.PLUGIN.CIRCLECI.TRANSFORMATION}>Learn 
more</ExternalLink>
-          </p>
+          <ShowMore
+            text={<p>Use Regular Expression to define Deployments to measure 
DORA metrics.</p>}
+            btnText="See how to configure"
+          >
+            <WorkflowRun />
+          </ShowMore>
           <div>Convert a CircleCI Workflow Run as a DevLake Deployment when: 
</div>
           <div style={{ margin: '8px 0', paddingLeft: 28 }}>
             <span>
@@ -90,7 +109,7 @@ const renderCollapseItems = ({
             </span>
             <Input
               style={{ width: 200, margin: '0 8px' }}
-              placeholder="(deploy|push-image)"
+              placeholder="(?i)(deploy|push-image)"
               value={transformation.deploymentPattern ?? ''}
               onChange={(e) =>
                 onChangeTransformation({
@@ -104,10 +123,10 @@ const renderCollapseItems = ({
             <HelpTooltip content="CircleCI Workflows: 
https://circleci.com/docs/workflows/"; />
           </div>
           <div style={{ margin: '8px 0', paddingLeft: 28 }}>
-            <span>If the name also matches</span>
+            <span>If the name or its branch matches</span>
             <Input
               style={{ width: 200, margin: '0 8px' }}
-              placeholder="prod(.*)"
+              placeholder="(?i)(prod|release)"
               value={transformation.productionPattern ?? ''}
               onChange={(e) =>
                 onChangeTransformation({
@@ -116,9 +135,10 @@ const renderCollapseItems = ({
                 })
               }
             />
-            <span>, this Deployment is a ‘Production Deployment’</span>
+            <span>, this deployment will be regarded as a ‘Production 
Deployment’</span>
             <HelpTooltip content="If you leave this field empty, all DevLake 
Deployments will be tagged as in the Production environment." />
           </div>
+          <CheckMatchedItems plugin={plugin} connectionId={connectionId} 
transformation={transformation} />
         </>
       ),
     },
diff --git a/config-ui/src/plugins/register/circleci/workflow-run.tsx 
b/config-ui/src/plugins/register/circleci/workflow-run.tsx
new file mode 100644
index 000000000..4eefc108f
--- /dev/null
+++ b/config-ui/src/plugins/register/circleci/workflow-run.tsx
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import { Input } from 'antd';
+import styled from 'styled-components';
+
+import { ExternalLink } from '@/components';
+
+import Picture from './assets/workflow-run.jpeg';
+
+const Wrapper = styled.div`
+  padding: 8px 16px;
+  width: 100%;
+  font-size: 12px;
+  background-color: #fff;
+  box-sizing: border-box;
+  overflow: hidden;
+
+  li {
+    margin-bottom: 20px;
+
+    &:last-child {
+      margin-bottom: 0;
+    }
+  }
+
+  span.blue {
+    color: #7497f7;
+  }
+
+  span.yellow {
+    color: #f4be55;
+  }
+
+  span.red {
+    color: #ff8b8b;
+  }
+`;
+
+export const WorkflowRun = () => {
+  return (
+    <Wrapper>
+      <h5>Example - Convert all runs of CircleCI workflow 
‘test-build-and-deploy’ to production deployments</h5>
+      <ol>
+        <li>Go to your CircleCI Pipelines page.</li>
+        <li>
+          Locate the workflows executed in each pipeline (see the ‘Workflow’ 
column). You will see some pipeline run
+          includes the workflow ‘test-build-and-deploy’.
+          <img src={Picture} width="100%" alt="" />
+        </li>
+        <li>
+          <div>
+            In the first input field, enter the following regex to define 
which workflow run is a deployment (see
+            ‘test-build-and-deploy’ in the <span 
className="yellow">yellow</span> rectangle)
+          </div>
+          <div style={{ marginTop: 10 }}>
+            The name of the <strong>CircleCI workflow</strong> or <strong>one 
of its jobs</strong> matches
+            <Input style={{ width: 240 }} size="small" disabled 
value="(?i)test-build-and-deploy" />
+          </div>
+        </li>
+        <li>
+          <div>
+            In the second input field, enter the following regex to identify 
the production deployments (as shown in the{' '}
+            <span className="red">red</span> rectangle). If left empty, all 
deployments in the{' '}
+            <span className="yellow">yellow</span> rectangle will be regarded 
as Production Deployments.
+          </div>
+          <div style={{ marginTop: 10 }}>
+            If the name or its branch matches <Input style={{ width: 100 }} 
size="small" disabled value="main" />, this
+            deployment will be classified as a ‘Production Deployment’
+          </div>
+        </li>
+      </ol>
+      <div>
+        For more information, please refer to{' '}
+        <ExternalLink 
link="https://devlake.apache.org/docs/Configuration/CircleCI/#transformations";>
+          this documentation
+        </ExternalLink>
+        .
+      </div>
+    </Wrapper>
+  );
+};

Reply via email to