Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config-ui/src/plugins/components/scope-config-form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { BitbucketTransformation } from '@/plugins/register/bitbucket';
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';
Expand Down Expand Up @@ -207,6 +208,14 @@ export const ScopeConfigForm = ({
/>
)}

{plugin === 'circleci' && (
<CircleCITransformation
entities={entities}
transformation={transformation}
setTransformation={setTransformation}
/>
)}

{plugin === 'github' && (
<GitHubTransformation
entities={entities}
Expand Down
4 changes: 4 additions & 0 deletions config-ui/src/plugins/components/scope-config-form/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions config-ui/src/plugins/register/circleci/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@
*/

export * from './config';
export * from './transformation';
172 changes: 172 additions & 0 deletions config-ui/src/plugins/register/circleci/transformation.tsx
Original file line number Diff line number Diff line change
@@ -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');
1 change: 1 addition & 0 deletions config-ui/src/release/stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,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',
Expand Down