QuestionQ16

SDLC Automation

A company is implementing a CI/CD pipeline for an application using AWS CodePipeline and AWS CodeBuild. The company requires a solution to run unit tests and automatically create code coverage reports before any code is deployed to production. The CI/CD pipeline execution must fail when code coverage is below 80%.

Which solution meets these requirements?

  • A Create an AWS Lambda function to run unit tests and generate code coverage reports. Add a Lambda invoke action to a stage in the CodePipeline pipeline. Create an Amazon EventBridge scheduled rule to run hourly to monitor the Lambda function's output. Configure the rule to fail the pipeline if coverage is less than 80%.
  • B Create an AWS Step Functions workflow to run unit tests and generate code coverage reports. Add a Step Functions test action to a stage in the CodePipeline pipeline to invoke the workflow. Configure the workflow to fail if the code coverage is less than 80%.
  • C Create a CodeBuild project with a buildspec.yml file that includes commands to run unit tests and generate code coverage reports. Add a CodeBuild test action to a stage in the CodePipeline pipeline. Configure the CodeBuild test action to use the source artifacts from the source action as input. Modify the buildspec.yml file to fail the build if coverage is less than 80%.
  • D Create a CodeBuild project with Jenkins installed. Configure Jenkins to run unit tests and generate code coverage reports. Add a Jenkins test action to a stage in the CodePipeline pipeline. Configure the Jenkins test action to output the coverage report as an output artifact. Configure an approval action to fail the pipeline if code coverage is less than 80%.
Explanation

An AWS CodeBuild test action runs the commands defined in buildspec.yml against its input source artifact. The buildspec can run unit tests, produce code coverage reports, and explicitly exit with a failure status when coverage is less than 80%. A failed CodeBuild action fails the pipeline execution, preventing a subsequent production deployment.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!