Skip to content

DerYeger/yarn-setup-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Yarn Setup

GitHub Action for setting up a Yarn environment. Caches dependencies for reduced execution times.

Features

  • 🔽 Performs a checkout using actions/checkout.
  • ⚒️ Sets up a Node.js environment using the specified node-version with actions/setup-node.
  • 💽 Caches and retrieves node_modules for reduced execution time. Based on actions/cache.
  • ⌛ Runs yarn install with the cached node_modules.

Usage

steps:
  - name: Yarn setup
    uses: DerYeger/yarn-setup-action@master
    with:
      node-version: 16

Inputs

  • node-version: The version of Node.js that will be used.

Outputs

  • cache-hit: Indicates a cache hit.

Example

Splitting long jobs into multiple allows for parallel execution and thus faster workflow execution. However, every job requires its own setup and environment initialization. This Action allows for easy installation of dependencies while maintaining fast execution times thanks to built-in caching.

The following example workflow demonstrates parallel execution of three jobs (build, lint and test), which run in parallel. They all depend on the prepare job, which either validates that dependencies are cached or installs (then caches) them itself. This setup ensures that each of the following jobs has access to Node.js and dependencies with minimal overhead (usually in the order of 3 to 5 seconds, depending on the project and postinstall setup).

name: CI

on: [pull_request, push]

jobs:
  prepare:
    name: Prepare
    runs-on: ubuntu-latest
    steps:
      - uses: DerYeger/yarn-setup-action@master
        with:
          node-version: 16
  build:
    name: Build
    runs-on: ubuntu-latest
    needs: prepare
    steps:
      - uses: DerYeger/yarn-setup-action@master
        with:
          node-version: 16
      - run: yarn build
  lint:
    name: Lint
    runs-on: ubuntu-latest
    needs: prepare
    steps:
      - uses: DerYeger/yarn-setup-action@master
        with:
          node-version: 16
      - run: yarn lint
  test:
    name: Test
    runs-on: ubuntu-latest
    needs: prepare
    steps:
      - uses: DerYeger/yarn-setup-action@master
        with:
          node-version: 16
      - run: yarn test

License

MIT - Copyright © Jan Müller

About

GitHub Action for setting up a Yarn environment. Caches dependencies for reduced execution times.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks