From 0e01da88dfd9748b61ce93a8ed320d1a52819ebe Mon Sep 17 00:00:00 2001 From: Lucas Hanson Date: Wed, 31 Aug 2022 11:14:24 -0700 Subject: [PATCH] feat: Support local package path install in CICD synth action pre-public release (#160) * adding temp npm install of ddk core package * parameterizing local package path * adding param to pipeilne * adding api --- API.md | 22 ++++++++++++++++++++++ src/cicd/actions.ts | 7 ++++--- src/cicd/pipelines.ts | 2 ++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/API.md b/API.md index da401e7d..02cac1b1 100644 --- a/API.md +++ b/API.md @@ -3723,6 +3723,7 @@ const getSynthActionProps: GetSynthActionProps = { ... } | codeartifactDomainOwner | string | *No description.* | | codeartifactRepository | string | *No description.* | | codePipelineSource | aws-cdk-lib.pipelines.IFileSetProducer | *No description.* | +| localPackagePath | string | *No description.* | | partition | string | *No description.* | | region | string | *No description.* | | rolePolicyStatements | aws-cdk-lib.aws_iam.PolicyStatement[] | *No description.* | @@ -3789,6 +3790,16 @@ public readonly codePipelineSource: IFileSetProducer; --- +##### `localPackagePath`Optional + +```typescript +public readonly localPackagePath: string; +``` + +- *Type:* string + +--- + ##### `partition`Optional ```typescript @@ -4457,6 +4468,7 @@ const synthActionProps: SynthActionProps = { ... } | codeartifactDomain | string | *No description.* | | codeartifactDomainOwner | string | *No description.* | | codeartifactRepository | string | *No description.* | +| localPackagePath | string | *No description.* | | rolePolicyStatements | aws-cdk-lib.aws_iam.PolicyStatement[] | *No description.* | | synthAction | aws-cdk-lib.pipelines.CodeBuildStep | *No description.* | @@ -4502,6 +4514,16 @@ public readonly codeartifactRepository: string; --- +##### `localPackagePath`Optional + +```typescript +public readonly localPackagePath: string; +``` + +- *Type:* string + +--- + ##### `rolePolicyStatements`Optional ```typescript diff --git a/src/cicd/actions.ts b/src/cicd/actions.ts index 20a695ca..5784aeae 100644 --- a/src/cicd/actions.ts +++ b/src/cicd/actions.ts @@ -20,6 +20,7 @@ export interface GetSynthActionProps { readonly codeartifactRepository?: string; readonly codeartifactDomain?: string; readonly codeartifactDomainOwner?: string; + readonly localPackagePath?: string; } export interface CodeCommitSourceActionProps { @@ -38,7 +39,7 @@ export function getCodeCommitSourceAction(scope: Construct, props: CodeCommitSou export function getSynthAction(props: GetSynthActionProps): CodeBuildStep { var installCommands; - installCommands = [`npm install -g aws-cdk@${props.cdkVersion ? props.cdkVersion : ''}`]; + installCommands = [`npm install -g aws-cdk@${props.cdkVersion ? props.cdkVersion : 'latest'}`]; // if (all([codeArtifactRepository, codeArtifactDomain, codeArtifactDomainOwner])) { // if (!rolePolicyStatements) { @@ -47,8 +48,8 @@ export function getSynthAction(props: GetSynthActionProps): CodeBuildStep { // install_commands.psuh(`aws codeartifact login --tool pip --repository ${codeArtifactRepository} --domain ${codeArtifactDomain} --domain-owner ${codeArtifactDomainOwner}`); // } - - installCommands.push('pip install -r requirements.txt'); + const localPackagePath = props.localPackagePath ?? 'package/'; + installCommands.push(`npm install ${localPackagePath} || true`); // will need to be replaced with `npm install aws-ddk-core@${version}` when available return new CodeBuildStep('Synth', { input: props.codePipelineSource, installCommands: installCommands, diff --git a/src/cicd/pipelines.ts b/src/cicd/pipelines.ts index a718302e..d1d6d61b 100644 --- a/src/cicd/pipelines.ts +++ b/src/cicd/pipelines.ts @@ -27,6 +27,7 @@ export interface SynthActionProps { readonly codeartifactDomainOwner?: string; readonly rolePolicyStatements?: PolicyStatement[]; readonly synthAction?: CodeBuildStep; + readonly localPackagePath?: string; } export interface AddApplicationStageProps { @@ -118,6 +119,7 @@ export class CICDPipelineStack extends Stack { codeartifactRepository: props.codeartifactRepository, // || this._artifactory_config.get('repository'), codeartifactDomain: props.codeartifactDomain, // || this._artifactory_config.get('domain'), codeartifactDomainOwner: props.codeartifactDomainOwner, //|| this._artifactory_config.get('domain_owner') + localPackagePath: props.localPackagePath, }); return this; }