【问题标题】:How to use lerna.js with travis ci?如何将 lerna.js 与 travis ci 一起使用?
【发布时间】:2018-11-18 01:13:06
【问题描述】:

我正在使用lerna.js,但我很难找到有关使用Travis 设置monorepo 的适当文档。我只找到了这个repo 和这个blog post,但它们都是最小的和次优的。

我怎样才能完成以下所有任务?

  1. 跨所有包运行测试和 linter
  2. 在每个包中缓存node_modules
  3. 最好为每个包声明一个不同的.travis.yml 文件

我设法做到了第 1 点:

env:
  matrix:
    - PACKAGE=contracts

matrix:
  include:
  - stage: tests
    name: "unit tests"
    script:
      - cd packages/contracts
      - npm install && npm run test
  - stage: tests
    name: "unit tests with coverage"
    script:
      - cd packages/contracts
      - npm install && npm run test
    env: SOLIDITY_COVERAGE=true
  - stage: tests
    name: "static tests"
    script:
      - cd packages/contracts
      - npm install && npm run lint

但是,构建速度非常慢,因为 node_modules 没有被缓存。同样,以自上而下的方式声明所有测试是一个相当冗长的过程,我更喜欢通过单独的 .travis.yml 文件自下而上。

【问题讨论】:

    标签: travis-ci lerna


    【解决方案1】:

    一种相当老套的方法,但Truffle 是如何解决这个问题的:

    install:
      - npm install -g lerna
      - npm install -g yarn
      - npm run bootstrap
    
    script:
      - npm run ci
    

    瞧瞧这个ci 脚本的用法。本质上,他们将处理多个子包的复杂性推迟到了一个 bash 脚本,这很好,但对 Travis 来说有点虚伪。

    我最终切换到了 CircleCI,因为它们的语法在某种程度上更直观且易于使用。

    【讨论】:

      猜你喜欢
      • 2012-09-19
      • 2013-05-21
      • 1970-01-01
      • 1970-01-01
      • 2018-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-29
      相关资源
      最近更新 更多