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

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

commit 7be0df884c262c81d8e4dab6ac80f8817862c59e
Author: mintsweet <[email protected]>
AuthorDate: Mon Feb 26 19:32:24 2024 +1300

    feat: missed circleci transformation
---
 .../plugins/components/scope-config-form/index.tsx |   9 ++
 .../plugins/components/scope-config-form/misc.ts   |   4 +
 config-ui/src/plugins/register/circleci/index.ts   |   1 +
 .../plugins/register/circleci/transformation.tsx   | 172 +++++++++++++++++++++
 config-ui/src/release/stable.ts                    |   1 +
 5 files changed, 187 insertions(+)

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 910a02b7c..af16ba298 100644
--- a/config-ui/src/plugins/components/scope-config-form/index.tsx
+++ b/config-ui/src/plugins/components/scope-config-form/index.tsx
@@ -33,6 +33,7 @@ import { BitbucketServerTransformation } from 
'@/plugins/register/bitbucket-serv
 import { AzureTransformation } from '@/plugins/register/azure';
 import { TapdTransformation } from '@/plugins/register/tapd';
 import { BambooTransformation } from '@/plugins/register/bamboo';
+import { CircleCITransformation } from '@/plugins/register/circleci';
 import { operator } from '@/utils';
 
 import { TIPS_MAP } from './misc';
@@ -216,6 +217,14 @@ export const ScopeConfigForm = ({
                 />
               )}
 
+              {plugin === 'circleci' && (
+                <CircleCITransformation
+                  entities={entities}
+                  transformation={transformation}
+                  setTransformation={setTransformation}
+                />
+              )}
+
               {plugin === 'github' && (
                 <GitHubTransformation
                   entities={entities}
diff --git a/config-ui/src/plugins/components/scope-config-form/misc.ts 
b/config-ui/src/plugins/components/scope-config-form/misc.ts
index 5188ee38a..19e6575a0 100644
--- a/config-ui/src/plugins/components/scope-config-form/misc.ts
+++ b/config-ui/src/plugins/components/scope-config-form/misc.ts
@@ -31,6 +31,10 @@ export const TIPS_MAP: Record<string, { name: string; link: 
string }> = {
     name: 'BitBucket',
     link: DOC_URL.PLUGIN.BITBUCKET.TRANSFORMATION,
   },
+  circleci: {
+    name: 'CircleCI',
+    link: DOC_URL.PLUGIN.CIRCLECI.TRANSFORMATION,
+  },
   github: {
     name: 'GitHub',
     link: DOC_URL.PLUGIN.GITHUB.TRANSFORMATION,
diff --git a/config-ui/src/plugins/register/circleci/index.ts 
b/config-ui/src/plugins/register/circleci/index.ts
index de415db39..5f16858cb 100644
--- a/config-ui/src/plugins/register/circleci/index.ts
+++ b/config-ui/src/plugins/register/circleci/index.ts
@@ -17,3 +17,4 @@
  */
 
 export * from './config';
+export * from './transformation';
diff --git a/config-ui/src/plugins/register/circleci/transformation.tsx 
b/config-ui/src/plugins/register/circleci/transformation.tsx
new file mode 100644
index 000000000..90a00377d
--- /dev/null
+++ b/config-ui/src/plugins/register/circleci/transformation.tsx
@@ -0,0 +1,172 @@
+/*
+ * 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 { CaretRightOutlined } from '@ant-design/icons';
+import { theme, Collapse, Tag, Input } from 'antd';
+
+import { ExternalLink, HelpTooltip } from '@/components';
+import { DOC_URL } from '@/release';
+
+interface Props {
+  entities: string[];
+  transformation: any;
+  setTransformation: React.Dispatch<React.SetStateAction<any>>;
+}
+
+export const CircleCITransformation = ({ entities, transformation, 
setTransformation }: Props) => {
+  const { token } = theme.useToken();
+
+  const panelStyle: React.CSSProperties = {
+    marginBottom: 24,
+    background: token.colorFillAlter,
+    borderRadius: token.borderRadiusLG,
+    border: 'none',
+  };
+
+  return (
+    <Collapse
+      bordered={false}
+      defaultActiveKey={['CICD']}
+      expandIcon={({ isActive }) => <CaretRightOutlined rotate={isActive ? 90 
: 0} rev="" />}
+      style={{ background: token.colorBgContainer }}
+      size="large"
+      items={renderCollapseItems({
+        entities,
+        panelStyle,
+        transformation,
+        onChangeTransformation: setTransformation,
+      })}
+    />
+  );
+};
+
+const renderCollapseItems = ({
+  entities,
+  panelStyle,
+  transformation,
+  onChangeTransformation,
+}: {
+  entities: string[];
+  panelStyle: React.CSSProperties;
+  transformation: any;
+  onChangeTransformation: any;
+}) =>
+  [
+    {
+      key: 'CICD',
+      label: 'CI/CD',
+      style: panelStyle,
+      children: (
+        <>
+          <h3 style={{ marginBottom: 16 }}>
+            <span>Deployment</span>
+            <Tag style={{ marginLeft: 4 }} color="blue">
+              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>
+          <div>Convert a CircleCI Workflow Run as a DevLake Deployment when: 
</div>
+          <div style={{ margin: '8px 0', paddingLeft: 28 }}>
+            <span>
+              The name of the <strong>CircleCI workflow</strong> or 
<strong>one of its jobs</strong> matches
+            </span>
+            <Input
+              style={{ width: 200, margin: '0 8px' }}
+              placeholder="(deploy|push-image)"
+              value={transformation.deploymentPattern ?? ''}
+              onChange={(e) =>
+                onChangeTransformation({
+                  ...transformation,
+                  deploymentPattern: e.target.value,
+                  productionPattern: !e.target.value ? '' : 
transformation.productionPattern,
+                })
+              }
+            />
+            <i style={{ color: '#E34040' }}>*</i>
+            <HelpTooltip content="CircleCI Workflows: 
https://circleci.com/docs/workflows/"; />
+          </div>
+          <div style={{ margin: '8px 0', paddingLeft: 28 }}>
+            <span>If the name also matches</span>
+            <Input
+              style={{ width: 200, margin: '0 8px' }}
+              placeholder="prod(.*)"
+              value={transformation.productionPattern ?? ''}
+              onChange={(e) =>
+                onChangeTransformation({
+                  ...transformation,
+                  productionPattern: e.target.value,
+                })
+              }
+            />
+            <span>, this Deployment is a ‘Production Deployment’</span>
+            <HelpTooltip content="If you leave this field empty, all DevLake 
Deployments will be tagged as in the Production environment." />
+          </div>
+        </>
+      ),
+    },
+    {
+      key: 'ADDITIONAL',
+      label: 'Additional Settings',
+      style: panelStyle,
+      children: (
+        <>
+          <p>
+            Enable the <ExternalLink 
link={DOC_URL.PLUGIN.REFDIFF}>RefDiff</ExternalLink> plugin to pre-calculate
+            version-based metrics
+            <HelpTooltip content="Calculate the commits diff between two 
consecutive tags that match the following RegEx. Issues closed by PRs which 
contain these commits will also be calculated. The result will be shown in 
table.refs_commits_diffs and table.refs_issues_diffs." />
+          </p>
+          <div className="refdiff">
+            Compare the last
+            <Input
+              style={{ margin: '0 8px', width: 60 }}
+              placeholder="10"
+              value={transformation.refdiff?.tagsLimit ?? ''}
+              onChange={(e) =>
+                onChangeTransformation({
+                  ...transformation,
+                  refdiff: {
+                    ...transformation?.refdiff,
+                    tagsLimit: +e.target.value,
+                  },
+                })
+              }
+            />
+            tags that match the
+            <Input
+              style={{ margin: '0 8px', width: 200 }}
+              placeholder="(regex)$"
+              value={transformation.refdiff?.tagsPattern ?? ''}
+              onChange={(e) =>
+                onChangeTransformation({
+                  ...transformation,
+                  refdiff: {
+                    ...transformation?.refdiff,
+                    tagsPattern: e.target.value,
+                  },
+                })
+              }
+            />
+            for calculation
+          </div>
+        </>
+      ),
+    },
+  ].filter((it) => entities.includes(it.key) || it.key === 'ADDITIONAL');
diff --git a/config-ui/src/release/stable.ts b/config-ui/src/release/stable.ts
index 6ad932862..f31119b49 100644
--- a/config-ui/src/release/stable.ts
+++ b/config-ui/src/release/stable.ts
@@ -50,6 +50,7 @@ const URLS = {
     },
     CIRCLECI: {
       RATE_LIMIT: 
'https://devlake.apache.org/docs/Configuration/CircleCI#fixed-rate-limit-optional',
+      TRANSFORMATION: 
'https://devlake.apache.org/docs/Configuration/CircleCI#step-13---adding-scope-config-optional',
     },
     GITHUB: {
       BASIS: 'https://devlake.apache.org/docs/Configuration/GitHub',

Reply via email to