Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ignore build cache at workflow level #2295

Merged
merged 9 commits into from
Dec 24, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const ConfigToolbar = ({
if (configHeaderTab === ConfigHeaderTabType.INHERITED) {
return (
<div className="flexbox dc__align-items-center dc__gap-6">
<ICInfoOutlineGrey className="p-2 icon-dim-20 dc__no-shrink" />
<ICInfoOutlineGrey className="p-2 icon-dim-20 dc__no-shrink scn-6" />
<span className="cn-9 fs-12 fw-4 lh-20">Inherited from</span>
<BaseConfigurationNavigation baseConfigurationURL={baseConfigurationURL} />
</div>
Expand All @@ -148,7 +148,7 @@ const ConfigToolbar = ({
<>
{headerMessage && configHeaderTab === ConfigHeaderTabType.VALUES && !showProtectedTabs && (
<div className="flexbox dc__align-items-center dc__gap-6">
<ICInfoOutlineGrey className="p-2 icon-dim-20 dc__no-shrink" />
<ICInfoOutlineGrey className="p-2 icon-dim-20 dc__no-shrink scn-6" />
<span className="cn-9 fs-12 fw-4 lh-20">{headerMessage}</span>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ const DeploymentTemplate = ({

return (
<div className="flexbox dc__gap-6 dc__align-items-center dc__border-top-n1 bc-n50 py-6 px-10">
<ICInfoOutlineGrey className="flex icon-dim-16 p-2 dc__no-shrink" />
<ICInfoOutlineGrey className="flex icon-dim-16 dc__no-shrink scn-6" />
<div className="flexbox">
<span className="cn-8 fs-12 fw-4 lh-20 dc__truncate">
Application metrics is {!baseDeploymentTemplateData?.isAppMetricsEnabled ? 'not' : ''} enabled
Expand Down
9 changes: 5 additions & 4 deletions src/assets/icons/ic-info-outline-grey.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/ApplicationGroup/CreateAppGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export default function CreateAppGroup({
<GenericEmptyState
title={title}
image={Info}
imageClassName="h-20"
imageClassName="h-20 scn-6"
styles={{ height: 'calc(100vh - 420px)' }}
/>
)
Expand Down
7 changes: 6 additions & 1 deletion src/components/CIPipelineN/CIPipeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export default function CIPipeline({
const [isSecurityModuleInstalled, setSecurityModuleInstalled] = useState<boolean>(false)
const [selectedEnv, setSelectedEnv] = useState<EnvironmentWithSelectPickerType>()
const [environments, setEnvironments] = useState<EnvironmentWithSelectPickerType[]>([])
// NOTE: don't want to show the warning until fetch; therefore true by default
const [isBlobStorageConfigured, setIsBlobStorageConfigured] = useState(true)
const [formData, setFormData] = useState<PipelineFormType>({
name: '',
args: [],
Expand Down Expand Up @@ -475,13 +477,14 @@ export default function CIPipeline({
validateStage(BuildStageVariable.Build, ciPipelineResponse.form)
validateStage(BuildStageVariable.PostBuild, ciPipelineResponse.form)
setFormData(ciPipelineResponse.form)
setIsBlobStorageConfigured(ciPipelineResponse.isBlobStorageConfigured)
setCIPipeline(ciPipelineResponse.ciPipeline)
await getInitialPlugins(ciPipelineResponse.form)
await getEnvironments(ciPipelineResponse.ciPipeline.environmentId)
setIsAdvanced(true)
}
} else {
const ciPipelineResponse = await getInitData(appId, true, !isJobCard)
const ciPipelineResponse = await getInitData(appId, true, isJobCard)
if (ciPipelineResponse) {
setFormData(ciPipelineResponse.result.form)
await getInitialPlugins(ciPipelineResponse.result.form)
Expand Down Expand Up @@ -810,6 +813,7 @@ export default function CIPipeline({
handleDisableParentModalCloseUpdate,
handleValidateMandatoryPlugins,
mandatoryPluginData,
isBlobStorageConfigured,
uploadFile,
}),
[
Expand All @@ -824,6 +828,7 @@ export default function CIPipeline({
pluginDataStore,
availableTags,
mandatoryPluginData,
isBlobStorageConfigured,
],
)

Expand Down
52 changes: 48 additions & 4 deletions src/components/CIPipelineN/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
PipelineFormType,
SelectPicker,
ResourceKindType,
WORKFLOW_CACHE_CONFIG_ENUM,

Check failure on line 25 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Module '"@devtron-labs/devtron-fe-common-lib"' has no exported member 'WORKFLOW_CACHE_CONFIG_ENUM'.
} from '@devtron-labs/devtron-fe-common-lib'
import Tippy from '@tippyjs/react'
import { BuildStageVariable, DOCUMENTATION, TriggerType } from '../../config'
Expand All @@ -37,6 +38,7 @@
import { EnvironmentList } from './EnvironmentList'

const MandatoryPluginWarning = importComponentFromFELibrary('MandatoryPluginWarning')
const CacheConfiguration = importComponentFromFELibrary('CacheConfiguration', null, 'function')

export const Sidebar = ({
isJobView,
Expand All @@ -60,6 +62,7 @@
isVirtualEnvironment,
getPrePostStageInEnv,
mandatoryPluginData,
isBlobStorageConfigured,
} = useContext(pipelineContext)

const [addConfigSecret, setAddConfigSecret] = useState<boolean>(false)
Expand Down Expand Up @@ -279,8 +282,8 @@
const triggerValue = isPreBuildTab ? formData.preBuildStage.triggerType : formData.postBuildStage.triggerType

return (
<div className="sidebar-action-container sidebar-action-container-border">
<div className="dc__uppercase fw-6 fs-12 cn-6 mb-12">
<div className="sidebar-action-container sidebar-action-container-border flexbox-col dc__gap-4">
<div className="dc__uppercase fw-6 fs-12 cn-6">
Trigger {isPreBuildTab ? 'PRE' : 'POST'}-DEPLOYMENT STAGE
</div>
<div>
Expand Down Expand Up @@ -310,6 +313,35 @@
)
}

const handleSetIsInheriting = () => {
// MOTE: don't do anything if in oss
if (!formData.workflowCacheConfig) {

Check failure on line 318 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'workflowCacheConfig' does not exist on type 'PipelineFormType'.
return
}

const newWorkflowCacheConfigType =
formData.workflowCacheConfig.type === WORKFLOW_CACHE_CONFIG_ENUM.INHERIT

Check failure on line 323 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'workflowCacheConfig' does not exist on type 'PipelineFormType'.
? WORKFLOW_CACHE_CONFIG_ENUM.OVERRIDE
: WORKFLOW_CACHE_CONFIG_ENUM.INHERIT

setFormData({ ...formData, workflowCacheConfig: {

Check failure on line 327 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Object literal may only specify known properties, and 'workflowCacheConfig' does not exist in type 'SetStateAction<PipelineFormType>'.
...formData.workflowCacheConfig,

Check failure on line 328 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'workflowCacheConfig' does not exist on type 'PipelineFormType'.
type: newWorkflowCacheConfigType,
...(newWorkflowCacheConfigType === WORKFLOW_CACHE_CONFIG_ENUM.INHERIT ? {
value: formData.workflowCacheConfig.globalValue

Check failure on line 331 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'workflowCacheConfig' does not exist on type 'PipelineFormType'.
} : {}),
}})
}

const handleSetUseRemoteCache = () => {
// MOTE: don't do anything if in oss
if (!formData.workflowCacheConfig) {

Check failure on line 338 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'workflowCacheConfig' does not exist on type 'PipelineFormType'.
return
}

setFormData({ ...formData, workflowCacheConfig: { ...formData.workflowCacheConfig, value: !formData.workflowCacheConfig.value } })

Check failure on line 342 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Object literal may only specify known properties, and 'workflowCacheConfig' does not exist in type 'SetStateAction<PipelineFormType>'.

Check failure on line 342 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'workflowCacheConfig' does not exist on type 'PipelineFormType'.

Check failure on line 342 in src/components/CIPipelineN/Sidebar.tsx

View workflow job for this annotation

GitHub Actions / ci

Property 'workflowCacheConfig' does not exist on type 'PipelineFormType'.
}

return (
<div>
{activeStageName !== BuildStageVariable.Build ? (
Expand Down Expand Up @@ -348,8 +380,8 @@
)}
</div>
) : (
<div className="sidebar-action-container pr-20">
<div className="dc__uppercase fw-6 fs-12 cn-6 mb-12">
<div className="sidebar-action-container pr-20 flexbox-col dc__gap-4">
<div className="dc__uppercase fw-6 fs-12 cn-6">
Trigger {isJobCard ? 'JOB' : 'BUILD'} PIPELINE
</div>
<div>
Expand Down Expand Up @@ -379,6 +411,18 @@
)}
{isCdPipeline && activeStageName !== BuildStageVariable.Build && renderConfigSecret()}

{!isCdPipeline && CacheConfiguration && activeStageName === BuildStageVariable.Build && formData.workflowCacheConfig && (
<div className='sidebar-action-container sidebar-action-container-border dc__border-top-n1'>
<CacheConfiguration
isInheriting={formData.workflowCacheConfig.type === WORKFLOW_CACHE_CONFIG_ENUM.INHERIT}
handleSetIsInheriting={handleSetIsInheriting}
useRemoteCache={formData.workflowCacheConfig.value}
handleSetUseRemoteCache={handleSetUseRemoteCache}
isBlobStorageConfigured={isBlobStorageConfigured}
/>
</div>
)}

{!isCdPipeline && (
<div className="sidebar-action-container pr-20">
<div className="fw-6 fs-13 cn-9 mb-8">📙 Need help?</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/app/details/triggerView/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export const IGNORE_CACHE_INFO = {
IgnoreCache: {
title: 'Ignore Cache',
infoText: 'Ignoring cache will lead to longer build time.',
infoTooltipContent:
'Ignores existing Docker layer caches. A new cache will be generated and stored for future pipeline runs.',
},
}
export const BRANCH_REGEX_MODAL_MESSAGING = {
Expand Down
16 changes: 14 additions & 2 deletions src/components/app/details/triggerView/ciMaterial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ import {
SourceTypeMap,
CommonNodeAttr,
noop,
Tooltip,
} from '@devtron-labs/devtron-fe-common-lib'
import { CIMaterialProps, CIMaterialState, RegexValueType } from './types'
import { ReactComponent as Play } from '../../../../assets/icons/misc/arrow-solid-right.svg'
import { ReactComponent as ICInfoOutline } from '@Icons/ic-info-outline-grey.svg'
import { ReactComponent as Info } from '../../../../assets/icons/info-filled.svg'
import { ReactComponent as Storage } from '../../../../assets/icons/ic-storage.svg'
import { ReactComponent as OpenInNew } from '../../../../assets/icons/ic-open-in-new.svg'
Expand Down Expand Up @@ -164,8 +166,18 @@ class CIMaterial extends Component<CIMaterialProps, CIMaterialState> {
data-testid="set-clone-directory"
>
<div className="mr-5">
<div className="fs-13 fw-6">{IGNORE_CACHE_INFO.IgnoreCache.title}</div>
<div className="fs-12 fw-4">{IGNORE_CACHE_INFO.IgnoreCache.infoText}</div>
<div className="fs-13 fw-6 lh-20">{IGNORE_CACHE_INFO.IgnoreCache.title}</div>

<div className='flex dc__gap-4'>
<span className="fs-12 fw-4 lh-16">{IGNORE_CACHE_INFO.IgnoreCache.infoText}</span>

<Tooltip content={IGNORE_CACHE_INFO.IgnoreCache.infoTooltipContent} alwaysShowTippyOnHover>
{/* NOTE: need to wrap react elements with html elements when passing as children to tooltip */}
<div>
<ICInfoOutline className='dc__no-shrink icon-dim-16 flex scn-6' />
</div>
</Tooltip>
</div>
</div>
</Checkbox>
)
Expand Down
48 changes: 38 additions & 10 deletions src/components/ciPipeline/ciPipeline.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,20 @@ import {
PluginType,
RefVariableType,
PipelineBuildStageType,
getModuleConfigured,
ModuleNameMap,
VariableTypeFormat,
} from '@devtron-labs/devtron-fe-common-lib'
import { importComponentFromFELibrary } from '@Components/common'
import { Routes, SourceTypeMap, TriggerType, ViewType } from '../../config'
import { getSourceConfig, getWebhookDataMetaConfig } from '../../services/service'
import { CiPipelineSourceTypeBaseOptions } from '../CIPipelineN/ciPipeline.utils'
import { PatchAction } from './types'
import { CIPipelineBuildType, PatchAction } from './types'
import { safeTrim } from '../../util/Util'
import { ChangeCIPayloadType } from '../workflowEditor/types'

const isFELibAvailable = importComponentFromFELibrary('isFELibAvailable', null, 'function')

const emptyStepsData = () => {
return { id: 0, steps: [] }
}
Expand All @@ -54,18 +59,19 @@ export function getCIPipelineNameSuggestion(appId: string | number): Promise<any
export function getInitData(
appId: string | number,
includeWebhookData: boolean = false,
preFillName: boolean = true,
isJobCard: boolean
): Promise<any> {
return Promise.all([
getCIPipelineNameSuggestion(appId),
getPipelineMetaConfiguration(appId.toString(), includeWebhookData, true),
]).then(([pipelineNameRes, pipelineMetaConfig]) => {
getPipelineMetaConfiguration(appId.toString(), includeWebhookData, true, isJobCard),
getModuleConfigured(ModuleNameMap.BLOB_STORAGE),
]).then(([pipelineNameRes, pipelineMetaConfig, { result: { enabled: isBlobStorageConfigured } }]) => {
const scanEnabled =
window._env_ && (window._env_.RECOMMEND_SECURITY_SCANNING || window._env_.FORCE_SECURITY_SCANNING)
return {
result: {
form: {
name: preFillName ? pipelineNameRes.result : '',
name: !isJobCard ? pipelineNameRes.result : '',
args: [{ key: '', value: '' }],
materials: pipelineMetaConfig.result.materials,
gitHost: pipelineMetaConfig.result.gitHost,
Expand All @@ -79,9 +85,11 @@ export function getInitData(
postBuildStage: emptyStepsData(),
scanEnabled,
ciPipelineEditable: true,
workflowCacheConfig: pipelineMetaConfig.result.workflowCacheConfig ?? null
},
loadingData: false,
isAdvanced: false,
isBlobStorageConfigured,
},
}
})
Expand All @@ -92,8 +100,11 @@ export function getCIPipeline(appId: string, ciPipelineId: string): Promise<any>
return get(URL)
}

function getPipelineBaseMetaConfiguration(appId: string): Promise<any> {
return getSourceConfig(appId).then((response) => {
function getPipelineBaseMetaConfiguration(
appId: string,
queryParams: Record<'pipelineType', CIPipelineBuildType.CI_BUILD | CIPipelineBuildType.CI_JOB>
): Promise<any> {
return getSourceConfig(appId, queryParams).then((response) => {
const materials = response?.result?.material?.map((mat) => {
return {
id: 0,
Expand All @@ -116,6 +127,7 @@ function getPipelineBaseMetaConfiguration(appId: string): Promise<any> {
webhookEvents: undefined,
webhookConditionList: undefined,
ciPipelineSourceTypeOptions: _baseCiPipelineSourceTypeOptions,
workflowCacheConfig: response?.result?.workflowCacheConfig ?? null
},
}
})
Expand All @@ -125,8 +137,13 @@ export function getPipelineMetaConfiguration(
appId: string,
includeWebhookData: boolean = false,
isNewPipeline: boolean = true,
isJobCard = false,
): Promise<any> {
return getPipelineBaseMetaConfiguration(appId).then((baseResponse) => {
return getPipelineBaseMetaConfiguration(appId, isFELibAvailable ? {
// NOTE: need to send pipelineType to get corresponding workflowCacheConfig;
// since its enterprise only feature, will send queryParams only if fe-lib is present
pipelineType: isJobCard ? CIPipelineBuildType.CI_JOB : CIPipelineBuildType.CI_BUILD
} : null).then((baseResponse) => {
// if webhook data is not to be included, or materials not found, or multigit new pipeline, then return
const _materials = baseResponse.result.materials || []
if (!includeWebhookData || _materials.length == 0 || (isNewPipeline && _materials.length > 1)) {
Expand Down Expand Up @@ -170,8 +187,12 @@ export function getInitDataWithCIPipeline(
): Promise<any> {
return Promise.all([
getCIPipeline(appId, ciPipelineId),
getPipelineMetaConfiguration(appId, includeWebhookData, false),
]).then(([ciPipelineRes, pipelineMetaConfig]) => {
// NOTE: isJobCard parameter does not matter in this case
// isJobCard is only relevant to fetch workflowCacheConfig in meta config
// by default BE will send global cache config for that pipelineType (JOB or CI_BUILD)
getPipelineMetaConfiguration(appId, includeWebhookData, false, false),
getModuleConfigured(ModuleNameMap.BLOB_STORAGE),
]).then(([ciPipelineRes, pipelineMetaConfig, { result: { enabled: isBlobStorageConfigured } }]) => {
const ciPipeline = ciPipelineRes?.result
const pipelineMetaConfigResult = pipelineMetaConfig?.result
return parseCIResponse(
Expand All @@ -181,6 +202,7 @@ export function getInitDataWithCIPipeline(
pipelineMetaConfigResult.gitHost,
pipelineMetaConfigResult.webhookEvents,
pipelineMetaConfigResult.ciPipelineSourceTypeOptions,
isBlobStorageConfigured,
)
})
}
Expand Down Expand Up @@ -305,6 +327,9 @@ function createCIPatchRequest(ciPipeline, formData, isExternalCI: boolean, webho
linkedCount: ciPipeline.linkedCount,
isExternal: isExternalCI,
isManual: formData.triggerType == TriggerType.Manual,
...(formData.workflowCacheConfig ? {
workflowCacheConfig: formData.workflowCacheConfig,
} : {}),
ciMaterial: formData.materials
.filter((mat) => mat.isSelected)
.map((mat) => {
Expand Down Expand Up @@ -480,6 +505,7 @@ function parseCIResponse(
gitHost,
webhookEvents,
ciPipelineSourceTypeOptions,
isBlobStorageConfigured?: boolean,
) {
if (ciPipeline) {
if (ciPipeline.beforeDockerBuildScripts) {
Expand Down Expand Up @@ -544,10 +570,12 @@ function parseCIResponse(
counterX: +ciPipeline.customTag?.counterX || 0,
},
enableCustomTag: ciPipeline.enableCustomTag,
workflowCacheConfig: ciPipeline.workflowCacheConfig ?? null,
},
loadingData: false,
showPreBuild: ciPipeline.beforeDockerBuildScripts?.length > 0,
showPostBuild: ciPipeline.afterDockerBuildScripts?.length > 0,
isBlobStorageConfigured: isBlobStorageConfigured ?? false,
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export const InputForSelectedOption = ({
</div>
</div>
<div className="flex mt-4 flex-justify-start">
<Info className="icon-dim-16" />
<Info className="icon-dim-16 scn-6" />
<div className="ml-4 fs-11 fw-4 cn-7">Browser time zone: {timeZone} </div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/workflowEditor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ export interface PipelineContext {
handleDisableParentModalCloseUpdate?: (disableParentModalClose: boolean) => void
handleValidateMandatoryPlugins: (params: HandleValidateMandatoryPluginsParamsType) => void
mandatoryPluginData: MandatoryPluginDataType
isBlobStorageConfigured?: boolean
uploadFile: (file: UploadFileProps) => Promise<UploadFileDTO>
}

Expand Down
Loading
Loading