Giter Club home page Giter Club logo

nrwl-nx-action's Introduction

Banner

Nrwl Nx Action

License GitHub Issues GitHub Stars

The action wraps the usage of the Nrwl Nx monorepo development toolkit.

Nx manages multiple projects linked each other with a dependecy graph. One of its key features is to permit to run one or more tasks only on the projects affected by our changes (by checking the difference between two Git references).

GitHub Action's workflows provide some information about the Git references concerned by the workflow, in a pull request context, we have the current commit and the last one from the base branch. Combined with Nx, we can determine the projects affected by the whole pull request.

It's more than useful in a CI/CD context: we are able to lint, build and deploy only the projects affected by a pull request for instance.

Copy-pasting the bash code to compute the reference bounds for Nx is not that maintenable. That's why we are open-sourcing this action to do the trick for you.

Usage

By default, the action will try to run the provided tasks only on the affected projects. This behavior can be modified using the different inputs (see below).

workflow.yml

---
- uses: mansagroup/nrwl-nx-action@v2
  with:
    targets: lint,build,deploy

This simple step will run three targets: lint, build and deploy, sequentially only on the affected projects. Nothing more. Simple. More examples below.

Inputs

This GitHub action can take several inputs to configure its behaviors:

Name Type Default Example Description
targets Comma-separated list ø lint,test,build List of targets to execute
projects Comma-separated list ø frontend,backend List of projects to use (more below)
all Boolean false true Run the targets on all the projects of the Nx workspace
affected Boolean true true Run the targets on the affected projects since the last modifications (more below)
parallel Boolean false true Run the tasks in parallel (can be expensive)
maxParallel Number 3 3 Number of tasks to execute in parallel (can be expensive)
args String ø --key="value" Optional args to append to the Nx commands
nxCloud Boolean false true Enable support of Nx Cloud
workingDirectory String ø myNxFolder Path to the Nx workspace, needed if not the repository root

Note: all and affected are mutually exclusive.

projects

When defined, will skip the all and affected inputs.

affected

When set to true, the affected detection will depend on the event type of the workflow:

  • Inside a pull request context, the action will use the base and head Git references
  • Otherwise, will compute the difference between the HEAD and the last commit

Examples

Run one target on all the affected projects (default)

This will run the build target on all the affected projects. This is the default behavior.

workflow.yml

---
- uses: mansagroup/nrwl-nx-action@v2
  with:
    targets: build
    affected: 'true' # Defaults to true, therefore optional

Run multiple targets to all projects

This will run three targets: lint, test and build to all the projects of the workspace.

workflow.yml

---
- uses: mansagroup/nrwl-nx-action@v2
  with:
    targets: lint,test,build
    all: 'true'

Run one target on some projects

This will run the build target on the frontend and backend projects only.

workflow.yml

---
- uses: mansagroup/nrwl-nx-action@v2
  with:
    targets: build
    projects: frontend,backend

Run one target on all the projects in parallel

This will run the lint target on all the projects of the workspace in parallel.

workflow.yml

---
- uses: mansagroup/nrwl-nx-action@v2
  with:
    targets: lint
    all: 'true'
    parallel: 'true'

Run one target on a Nx workspace located in another folder

This will run the build target on all the affected projects of a Nx workspace located in another folder than the repository root.

workflow.yml

---
- uses: mansagroup/nrwl-nx-action@v2
  with:
    targets: build
    workingDirectory: my-nx-subfolder

Run one target with Nx Cloud enabled

This will run the build target on all the affected projects with Nx Cloud enabled (by adding the --scan command option and both NX_BRANCH and NX_RUN_GROUP environment variables).

workflow.yml

---
- uses: mansagroup/nrwl-nx-action@v2
  with:
    targets: build
    nxCloud: 'true'

License

This project is MIT licensed.

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

nrwl-nx-action's People

Contributors

renovate-bot avatar renovate[bot] avatar jeremylvln avatar cyrus-za avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.