【问题标题】:Refactor circleci config.yml file for ReactJs为 ReactJs 重构 circleci config.yml 文件
【发布时间】:2023-01-25 03:30:13
【问题描述】:

我是 CI/CD 的新手。我使用create-react-app 创建了一个基本的 React 应用程序。我为 circleci 添加了以下配置。它在 circleci 中运行良好,没有问题。但是有很多冗余代码,比如在多个地方使用了相同的步骤。我想按照最佳实践重构此配置文件。

 version: 2.1
    orbs:
      node: circleci/node@4.7.0
    
    jobs:
      build:
        docker:
          - image: cimg/node:17.2.0
        steps:
          - checkout
          - node/install-packages:
              pkg-manager: npm
          - run:
              command: npm run build
              name: Build app
          - persist_to_workspace:
              root: ~/project
              paths:
                - .
      test:
        docker:
          - image: cimg/node:17.2.0
        steps:
          - checkout
          - node/install-packages:
              pkg-manager: npm
          - run:
              command: npm run test
              name: Test app
          - persist_to_workspace:
              root: ~/project
              paths:
                - .
      eslint:
        docker:
          - image: cimg/node:17.2.0
        steps:
          - checkout
          - node/install-packages:
              pkg-manager: npm
          - run:
              command: npm run lint
              name: Lint app
          - persist_to_workspace:
              root: ~/project
              paths:
                - .
    workflows:
      on_commit:
        jobs:
          - build
          - test
          - eslint

【问题讨论】:

    标签: continuous-integration continuous-deployment circleci


    【解决方案1】:

    我可以看到您正在为多个作业安装包。您可以查看save_cacherestore_cache 选项。

    【讨论】:

      猜你喜欢
      • 2020-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-03
      • 2019-03-11
      • 2020-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多