LoginSignup
6
3

More than 5 years have passed since last update.

Travis CIでYarn(pkg)を使う設定 (node.js)

Posted at

最小の設定と条件

node.jsのプロジェクトにおいて、Travis CIでnpm installの代わりにyarn installを使う方法は、以下の.travis.yml設定と実行条件を両方満たすことです。
(2017/01/05現在)

.travis.ymlの設定

travis.yml
language: node_js
node_js:
  - 4
  - 5
  - 6
  - 7
  - node
dist: trusty
sudo: false
cache: yarn

必須なのはdist: trusty, sudo: false, cache: yarnで、それぞれ以下のような意味合いです。

なお、Yarn(pkg)の実行には、Node4以上を必要とするためテスト対象のNodeバージョンには4以上(.travis.ymlnode_jsディレクティブ)を指定1します。

yarn installが実行される条件

  • yarn.lockファイルがプロジェクトディレクトリ直下に存在すること

正しく動作すると、Travis CIのビルドJobの中で下図のようにyarnが実行されます。
Kobito.hGvKu5.png

最小サンプルのTravis CI BuildとGitHubリポジトリを作成してみました。参考にしてみてください。

背景

これを書いたのは、Yarn(pkg)のTravis CI設定ページTravis CIのYarn(pkg)サポート告知ページの情報が古くなっていることが背景でした。

それでは、素敵なYarn(pkg)とTravis CIライフをお過ごしください。


  1. 4未満を指定した場合はYarn(pkg)のエラーによりテスト失敗になります 

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3