Skip to content

Conversation

@shearn89
Copy link
Contributor

@shearn89 shearn89 commented Apr 16, 2020

Commit Message

feat(codebuild): allow taking the artifact name from the buildspec

This commit adds support for CodeBuild Artifacts to have names
controlled by a buildspec file, allowing the use of shell scripting to
sensibly name artifacts in CodeBuild projects generated from the CDK.
The previosuly required field name in S3ArtifactsProps is now optional,
and not providing it will set the overrideArtifactName on the underlying L1 to true.

Fixes #5955

End Commit Message


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

shearn89 and others added 2 commits April 16, 2020 12:49
This commit adds support for CodeBuild Artifacts to have names
controlled by a buildspec file, allowing the use of shell scripting to
sensibly name artifacts in CodeBuild projects generated from the CDK.

Fixes #5955
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: eb965d8
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: d524887
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@shearn89 shearn89 changed the title feat(codebuild): Support OverrideArtifactName on S3BuildProps feat(codebuild): Expose the overrideArtifactName property on S3ArtifactsProps Apr 16, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: c1f6757
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: cf6d658
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 7c171e7
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: ecef1e7
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@shearn89
Copy link
Contributor Author

@skinny85 - Hi, any chance this can get reviewed in the next week or so? It's a feature that would unblock me at work! Hopefully it's a small enough change, despite the various merges from master.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: cc930e6
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 395d53f
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@skinny85
Copy link
Contributor

I'll review it today - apologies for the delay @shearn89 !

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the contribution @shearn89 ! I have a few small comments, and one idea I wanted to run by you.

So, when useBuildSpecName is true, we ignore the name property completely. I wonder whether a slightly different design might work here.

Currently, name is required in S3ArtifactsProps. I wonder if, instead of adding the new useBuildSpecName property, we could make name optional. If name was not provided, we will just set overrideArtifactName in the implementation to true, and pass either undefined, or some random value (like project.node.uniqueId) for name (it's optional in the CFN resource, but we need to check whether its presence is not validated by the CodeBuild backend APIs).

What do you think?

@mergify mergify bot dismissed skinny85’s stale review April 28, 2020 13:54

Pull request has been modified.

@shearn89
Copy link
Contributor Author

shearn89 commented Apr 28, 2020

Hey @skinny85 - thanks for the review! I'm just about to push a commit with the proposed design change. I think it makes sense, and we shouldn't be changing any existing behaviour as the parameter is going from mandatory to optional. Given that this PR is the first time the overrideArtifactName parameter has been exposed I can't see that we'd be altering any existing behaviour!

(My TypeScript is not brilliant, so hopefully I've done it correctly! 🤞 )

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: ed1c25b
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

This commit reworks the implementation to instead make `name` optional.
If the `name` is not provided, `overrideArtifactName` will be set and
the buildspec name will be used.
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 3906e85
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: a7f78b9
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shearn89 , this looks amazing. I have one last question before I merge this in.

Thanks so much!

path: this.props.path,
namespaceType: this.props.includeBuildId === false ? 'NONE' : 'BUILD_ID',
name: this.props.name,
name: this.props.name == null ? project.node.uniqueId : this.props.name,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test that this is necessary - we can't just leave this as undefined? name is optional in CfnProject.ArtifactsProperty: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-codebuild.CfnProject.ArtifactsProperty.html#name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't - I'll do so today and set it to undefined if that works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, hopefully the integration tests pass!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure we're on the same page - by default, the integration tests act like snapshot tests. You need to specifically run the npm integ target to have them deployed. More info here: https://github.com/aws/aws-cdk/blob/master/CONTRIBUTING.md#integration-tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay! I'll run those this evening and let you know the outcome...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just ran the tests against my own account and all the aws-codebuild integration tests provision and tear down correctly, no errors visible in the CloudFormation console or build logs!

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 71ab99c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: f5b99c3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: dbf6778
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot dismissed skinny85’s stale review April 29, 2020 10:13

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 8c76e8d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fantastic. I'm really happy with where we ended up with this feature. Thanks so much for the awesome contribution @shearn89 !

@mergify
Copy link
Contributor

mergify bot commented Apr 30, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@skinny85 skinny85 changed the title feat(codebuild): Expose the overrideArtifactName property on S3ArtifactsProps feat(codebuild): allow taking the artifact name from the buildspec Apr 30, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 12c9654
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Apr 30, 2020

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit f7d3cd6 into aws:master Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose the overrideArtifactName property on S3ArtifactsProps

3 participants