使用CodeCatalyst来构建CI/CD工作流

Amazon CodeCatalyst 工作流是CI/CD pipeline。在日常CI/CD中,会面临以下挑战:

  • 发布高质量的更新越来越复杂,速度越来越慢
  • 与其他人合作的效率不高
  • 管理应用的环境越来越复杂
  • 创建新的项目花费时间

CodeCatalyst是集成的DevOps服务,让开发团队在AWS上快速构建和发布应用,

CodeCatalyst Workflows help you reliably deliver high-quality application updates frequently, quickly and securely. CodeCatalyst uses a visual editor — or if you prefer YAML — to quickly assemble and configure actions to compose workflows that automate your CI/CD pipeline, test reporting and other manual processes. Workflows use provisioned compute, lambda compute, custom container images and a managed build infrastructure to scale execution easily without sacrificing flexibility

Prerequisites

If you would like to follow along with this walkthrough, you will need to:

Walkthrough

Modern Three-tier Web Application architecture including a presentation, application and data layer

项目创建完成后,进入CI/CD > Workflows,可以看到两个workflow,点击ApplicationDeploymentPipeline,会进入下图的页面。这个workflow包括6个action:

  1. ensures that CDK is configured in the account;
  2. builds the backend, written in Python, including unit tests;
  3. deploys the backend to either AWS Lambda or AWS Fargate depending on which you selected when you launched the project;
  4. runs a series of integration tests on the deployed backend;
  5. builds the frontend, written with Vue, including unit tests; and finally,
  6. deploys the frontend to Amazon Simple Storage Service (Amazon S3) and Amazon CloudFront .

Six step Workflow described in the prior paragraph

如果点击每个action会看到细节,例如点击build_backend, 在日志页面,可以看到build action执行了一系列步骤,比如pip安装依赖,然后pytest和coverage运行一系列单元测试。对于Java还会有构建的过程。

Logs from the build action including pip, pytest, and coverage

如果切换到report页面,会看到单元测试的结果:

Results of the unit tests including code and branch coverage

点击右上角的编辑 按钮,可以看到workflow是如果定义的,如果打开的是yaml模式,可以切换成Visual模式。点击WorkflowSource可以看到workflow在push或pull时被触发,另外可以添加额外branch的触发:

Trigger configuration showing various options

现在看下build_frontend行为,在configure页面可以看到build阶段执行的命令:

Shell commands run in the build action

接下来我们看下integration_test的行为,里面也定义了一系列要执行的命令。

Test report configuration dialog including success criteria

最后,让我们检查deploy_frontend行为。这些行为都是包括了一系列命令行,而且CodeCatalyst也支持自已创建action。

总结

本文介绍了CodeCatalyst如何帮你快速的创建自动化工作流,创建CI/CD pipeline