Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.

NX Actions v3 (WIP)Β #18

@ronnetzer

Description

@ronnetzer

Background

Nx has released their own distributed tasks execution feature for NX Cloud.
Supporting this feature will make nx-affected-matrix way of usage a bit weird (and the action name is a bit unrelated) and it will also require changing some of the inputs of nx-distributed-task.

Therefore, instead of changing the existing actions, 2 new actions will be created: nx-orchestrator and nx-executor.

Specification

nx-affected-matrix & nx-distributed-task:

  • will be marked deprecated
  • will continue to receive fixes and features that don't introduce breaking changes
  • docs will be updated to refer to a migration guide to the new action

nx-orchestrator:

Inputs

targets - comma-separated list of targets to run
projects - all | affected | comma-separated list of projects to run per target, default is affected
nx-cloud - boolean, if true will use nxCloud with DTE feature
cwd - in case the nx repo is not in the workspace's root
args - space-separated list of args that will be passed to nx
debug - boolean, debug mode

nx-executor:

Inputs

data - the outputted matrix from nx-orchestrator, required if not running with nx-cloud
artifacts - boolean, if true will upload all the artifacts per target
nx-cloud - boolean, if true will use nxCloud with DTE feature
cwd - in case the nx repo is not in the workspace's root
args - space-separated list of args that will be passed to nx
debug - boolean, debug mode

Usage

With GH Actions matrix

jobs:
  setup:
    name: Calculate Affected
    ...
    outputs:
      hasChanges: ${{ steps.affected.outputs.hasChanges }}
      matrix: ${{ steps.affected.outputs.matrix }}
    steps:
      ... # checkout, setup node, npm ci
      - uses: @e-square/nx-orchestrator
         id: affected
         with:
           targets: 'lint,test,build'

distributed-tasks:
    name: ${{ matrix.target }} (${{ matrix.distribution }})
    needs: [setup]
    ...
    strategy:
      fail-fast: false
      matrix: ${{ fromJSON(needs.setup.outputs.matrix) }}
    steps:
      ...  # checkout, setup node, npm ci
      - uses: @e-square/nx-executor
         with:
           data: ${{ toJSON(matrix) }}
           artifacts: true

With NX Cloud and DTE (reference):

jobs:
  main:
    name: Lint Test Build
    ...
    steps:
      ... # checkout, setup node, npm ci
      - uses: @e-square/nx-orchestrator
         with:
           targets: 'lint,test,build'
           nx-cloud: true

agents:
    name: NX Agent
    ...
    strategy:
      matrix:
        agent: [1, 2, 3, 4]
    steps:
      ...  # checkout, setup node, npm ci
      - uses: @e-square/nx-executor
         with:
           nx-cloud: true

Tasks:

  • [ ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions