docs(core): include documentation about inputs for launch templates (#26266)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
There is no documentation on how to use inputs with steps for launch
tempaltes
## Expected Behavior
There is now documentation on how to use/configure inputs for steps in
launch templates

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
This commit is contained in:
Jonathan Cammisuli 2024-06-06 11:17:08 -04:00 committed by GitHub
parent 15e1f78021
commit 88161e00c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -131,9 +131,9 @@ You can find the [list of Nx Cloud reusable steps here](https://github.com/nrwl/
launch-templates: launch-templates:
template-one: template-one:
init-steps: init-steps:
- uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/checkout/main.yaml' - uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/checkout/main.yaml'
- name: 'Install Node Modules' - name: 'Install Node Modules'
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-node-modules/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-node-modules/main.yaml'
``` ```
### `launch-templates.<template-name>.init-steps[*].script` ### `launch-templates.<template-name>.init-steps[*].script`
@ -165,6 +165,24 @@ launch-templates:
echo $MY_STEP_ENV # prints "step-env-var" echo $MY_STEP_ENV # prints "step-env-var"
``` ```
### `launch-templates.<template-name>.init-steps[*].inputs`
An init-step's `inputs` is defined by the step file in the [`launch-template.<template-name>.init-steps[*].uses`](#launch-templatestemplate-nameinit-stepsuses) property. Refer to the step file's documentation for specific inputs.
[Validation](#validating-launch-templates) can also be done to validate the step against the step file's defined inputs
```yaml {% fileName=".nx/workflows/agents.yaml" %}
launch-templates:
template-one:
init-steps:
- name: Restore Node Modules Cache
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
inputs:
env: 'package-lock.json|yarn.lock|pnpm-lock.yaml'
paths: 'node_modules'
base-branch: 'main'
```
## Full Example ## Full Example
This is an example of a launch template using all pre-built features: This is an example of a launch template using all pre-built features:
@ -187,27 +205,27 @@ launch-templates:
- name: Checkout - name: Checkout
# using a reusable step in an external GitHub repo, # using a reusable step in an external GitHub repo,
# this step is provided by Nx Cloud: https://github.com/nrwl/nx-cloud-workflows/tree/main/workflow-steps # this step is provided by Nx Cloud: https://github.com/nrwl/nx-cloud-workflows/tree/main/workflow-steps
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/checkout/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/checkout/main.yaml'
- name: Restore Node Modules Cache - name: Restore Node Modules Cache
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/cache/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
# the cache step requires configuration via env vars # the cache step requires configuration via env vars
# https://github.com/nrwl/nx-cloud-workflows/tree/main/workflow-steps/cache#options # https://github.com/nrwl/nx-cloud-workflows/tree/main/workflow-steps/cache#options
env: inputs:
KEY: 'package-lock.json|yarn.lock|pnpm-lock.yaml' env: 'package-lock.json|yarn.lock|pnpm-lock.yaml'
PATHS: 'node_modules' paths: 'node_modules'
BASE_BRANCH: 'main' base-branch: 'main'
- name: Restore Browser Binary Cache - name: Restore Browser Binary Cache
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/cache/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
env: inputs:
KEY: 'package-lock.json|yarn.lock|pnpm-lock.yaml|"browsers"' env: 'package-lock.json|yarn.lock|pnpm-lock.yaml|"browsers"'
PATHS: | paths: |
'~/.cache/Cypress' '~/.cache/Cypress'
'~/.cache/ms-playwright' '~/.cache/ms-playwright'
BASE_BRANCH: 'main' base-branch: 'main'
- name: Install Node Modules - name: Install Node Modules
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-node-modules/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-node-modules/main.yaml'
- name: Install Browsers (if needed) - name: Install Browsers (if needed)
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-browsers/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-browsers/main.yaml'
# You can also run a custom script to configure various things on the agent machine # You can also run a custom script to configure various things on the agent machine
- name: Run a custom script - name: Run a custom script
script: | script: |
@ -240,25 +258,25 @@ launch-templates:
MY_ENV_VAR: shared MY_ENV_VAR: shared
init-steps: init-steps:
- name: Checkout - name: Checkout
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/checkout/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/checkout/main.yaml'
- name: Restore Node Modules Cache - name: Restore Node Modules Cache
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/cache/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
env: inputs:
KEY: 'package-lock.json|yarn.lock|pnpm-lock.yaml' env: 'package-lock.json|yarn.lock|pnpm-lock.yaml'
PATHS: 'node_modules' paths: 'node_modules'
BASE_BRANCH: 'main' base-branch: 'main'
- name: Restore Browser Binary Cache - name: Restore Browser Binary Cache
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/cache/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
env: inputs:
KEY: 'package-lock.json|yarn.lock|pnpm-lock.yaml|"browsers"' env: 'package-lock.json|yarn.lock|pnpm-lock.yaml|"browsers"'
PATHS: | paths: |
'~/.cache/Cypress' '~/.cache/Cypress'
'~/.cache/ms-playwright' '~/.cache/ms-playwright'
BASE_BRANCH: 'main' base-branch: 'main'
- name: Install Node Modules - name: Install Node Modules
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-node-modules/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-node-modules/main.yaml'
- name: Install Browsers (if needed) - name: Install Browsers (if needed)
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-browsers/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-browsers/main.yaml'
- name: Run a custom script - name: Run a custom script
script: | script: |
git config --global user.email test@test.com git config --global user.email test@test.com
@ -278,15 +296,15 @@ launch-templates:
image: 'ubuntu22.04-node20.11-v7' image: 'ubuntu22.04-node20.11-v7'
init-steps: init-steps:
- name: Checkout - name: Checkout
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/checkout/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/checkout/main.yaml'
- name: Restore Node Modules Cache - name: Restore Node Modules Cache
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/cache/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
env: inputs:
KEY: 'package-lock.json|yarn.lock|pnpm-lock.yaml' env: 'package-lock.json|yarn.lock|pnpm-lock.yaml'
PATHS: 'node_modules' paths: 'node_modules'
BASE_BRANCH: 'main' base-branch: 'main'
- name: Install Node Modules - name: Install Node Modules
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-node-modules/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-node-modules/main.yaml'
- name: Install Rust - name: Install Rust
script: | script: |
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh -s -- -y
@ -369,14 +387,14 @@ launch-templates:
image: 'ubuntu22.04-node20.11-v7' image: 'ubuntu22.04-node20.11-v7'
init-steps: init-steps:
- name: Checkout - name: Checkout
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/checkout/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/checkout/main.yaml'
- name: Auth to Registry - name: Auth to Registry
script: | script: |
# create .npmrc with @myorg scoped packages pointing to GH npm registry # create .npmrc with @myorg scoped packages pointing to GH npm registry
echo "@myorg:registry=https://npm.pkg.github.com" >> .npmrc echo "@myorg:registry=https://npm.pkg.github.com" >> .npmrc
echo "//npm.pkg.github.com/:_authToken=${SOME_AUTH_TOKEN}" >> .npmrc echo "//npm.pkg.github.com/:_authToken=${SOME_AUTH_TOKEN}" >> .npmrc
- name: Install Node Modules - name: Install Node Modules
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-node-modules/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-node-modules/main.yaml'
``` ```
Pass `SOME_AUTH_TOKEN` via `--with-env-vars` Pass `SOME_AUTH_TOKEN` via `--with-env-vars`
@ -397,7 +415,7 @@ launch-templates:
image: 'ubuntu22.04-node20.11-v7' image: 'ubuntu22.04-node20.11-v7'
init-steps: init-steps:
- name: Checkout - name: Checkout
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/checkout/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/checkout/main.yaml'
- name: Install nvm - name: Install nvm
script: | script: |
# run nvm install script # run nvm install script
@ -412,7 +430,7 @@ launch-templates:
# confirm that the node version has changed # confirm that the node version has changed
script: node -v script: node -v
- name: Install Node Modules - name: Install Node Modules
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/install-node-modules/main.yaml' uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-node-modules/main.yaml'
# Continue setup steps as needed # Continue setup steps as needed
``` ```