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

NX Actions v3 (WIP) #18

Open
ronnetzer opened this issue Feb 3, 2022 · 0 comments
Open

NX Actions v3 (WIP) #18

ronnetzer opened this issue Feb 3, 2022 · 0 comments
Milestone

Comments

@ronnetzer
Copy link
Member

ronnetzer commented Feb 3, 2022

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:

  • [ ]
@ronnetzer ronnetzer added this to the v3 milestone Feb 6, 2022
@ronnetzer ronnetzer pinned this issue Feb 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant