[pipelines] generate CodeBuild reports within @aws-cdk/cdk-pipelines
See original GitHub issueDescription
To be able to easily use @aws-cdk/assert within @aws-cdk/cdk-pipelines. and use the reports function of CodeBuild.
Use Case
Running tests on CDK using @aws-cdk/assert to increase the ability to Fail Fast and implement TDD.
Proposed Solution
I have considered 2 options so far: ( there may be other options, and there may well be some other/better way to do this )
Option1: add a testAction that adds another stage to codepipeline using another codebuild project :
const pipeline = new CdkPipeline(this, 'Pipeline', {
pipelineName: 'PipelineWithTests',
sourceAction: ...
synthAction: ...
testAction: simpleTestAction(...)
});
Where the new testAction includes support for reports in the buildSpec.
Option2: Enable adding reports to the existing SimpleSynthAction(and npm yarn variants) buildSpec: adding the needed changes to the build step commands “yarn build && yarn test”. and adding along the lines of the bellow to the build spec perhaps with a testEnable Flag in the SynthAction.
reports:
jest_reports:
files:
- <report filename>
file-format: JUNITXML
base-directory: <test report directory>
Other
I understand that this can be done by creating a codeBuild on its own and adding to the pipeline, but that breaks the elegance and simplicity of using cdk-pipelines which dose a great job at simplifying the codepipeline/buid experience.
I would expect that jest tests would be ran by yarn or npm as described in the @aws-cdk/assert docs. Reference: test-report-jest
This is a 🚀 Feature Request
Issue Analytics
- State:
- Created 3 years ago
- Reactions:19
- Comments:8 (3 by maintainers)
Top GitHub Comments
@BrianFarnhill if you drop back to SimpleSynthAction from SimpleSynthAction.standardNpmSynth it already has the testCommand available. So would just be to do the second part as you have described above.
would become
Based on the sample you shared, this is a working example I came up with to get both test and coverage reports working: