W3cubDocs

/Yarn

6. Continuous Integration

Yarn can easily be used in various continuous integration systems. To speed up builds, the Yarn cache directory can be saved across builds.

Yarn is preinstalled on AppVeyor, so you don’t need to do anything extra in order to use it as part of your build.

To speed up your builds, you can cache Yarn’s cache folder by adding this to your appveyor.yml:

cache:
 - "%LOCALAPPDATA%\\Yarn"

Yarn is pre-installed on CircleCI. You can quickly get up and running by following their Yarn documentation.

Yarn is pre-installed Codeship Basic.

If you are using Codeship Pro (with Docker), it is recommended to install Yarn via our Debian/Ubuntu package instead.

Travis CI detects the use of Yarn by the presence of yarn.lock in the repository root. If it is available, Travis CI will install yarn if necessary, and execute yarn as the default install command.

If your install phase requires more, it is necessary to install Yarn yourself until it is pre-installed on build images.

There are a couple of ways to install Yarn; one with sudo, the other without. If you are using the container-based environment use the latter.

sudo-enabled builds

sudo: required
before_install: # if "install" is overridden
  # Repo for Yarn
  - sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg
  - echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  - sudo apt-get update -qq
  - sudo apt-get install -y -qq yarn
cache:
  yarn: true

It is recommended that you lock in a specific version of Yarn, so that all your builds use the same version of Yarn, and you can test new Yarn releases before switching over. You can do this by adding the version number to the apt-get install call:

sudo apt-get install -y -qq yarn=0.27.5-1

container-based builds

Container-based builds do not have the sudo privilege, so they must rely on other means to install. For example:

sudo: false
before_install:
  - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.27.5
  - export PATH=$HOME/.yarn/bin:$PATH
cache:
  yarn: true

Semaphore has Yarn pre-installed for all supported Node.js versions, and no user interaction is required for the Yarn cache to work.

To assure that your local Yarn version matches the one on Semaphore, add the lines below to your setup commands, in Project Settings.

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
# install-package is a tool for caching APT installations in Semaphore
# defining a package version is optional
install-package yarn=<version>

Yarn is pre-installed on SolanoCI. You can quickly get up and running by following their Yarn documentation. For an example configuration file, check out one of their sample configuration files.

© 2016–2017 Yarn Contributors
Licensed under the BSD License.
https://yarnpkg.com/en/docs/install-ci