Updating changes based on review comments
Signed-off-by: Tavi Nolan <Tavi.Nolan@fmr.com>
This commit is contained in:
+5
-7
@@ -1,14 +1,14 @@
|
||||
---
|
||||
id: dry run testing
|
||||
title: Dry Run Testing
|
||||
description: Documentation on how to enable and implement dry run testing in actions
|
||||
description: How to enable and implement dry run testing in actions
|
||||
---
|
||||
|
||||
Scaffolder templates can be tested using the dry run feature of scaffolder actions. This allows you to simulate the effects of running a scaffolder action without making any actual changes to your environment, for example creating a webhook in Github. Once dry run is enabled in the scaffolder action, you can add handling to actions you use in your scaffolder templates to define how an action should operate in a dry run scenario.
|
||||
|
||||
## Enabling dry run testing
|
||||
|
||||
To enable dry run for your scaffolder action you need to add 'supportsDryRun: true' to the configuration object of 'createTemplateAction' in the function where the behavior of your action is defined:
|
||||
To enable dry run for your scaffolder action you need to add `supportsDryRun: true` to the configuration object of `createTemplateAction` in the function where the behavior of your action is defined:
|
||||
|
||||
```typescript
|
||||
export function exampleAction() {
|
||||
@@ -38,7 +38,7 @@ export function exampleAction() {
|
||||
|
||||
## Adding handling for dry run
|
||||
|
||||
To add handling for dry run functionality you need to add a check for 'ctx.isDryRun' inside the handler of the configuration object which is being passed into 'createTemplateAction' in the function where the behavior of your action is defined. Once the check is successful, you can perform the desired actions expected in a dry run, e.g. outputting non-sensitive inputs.
|
||||
To add handling for dry run functionality you need to add a check for `ctx.isDryRun` inside the handler of the configuration object which is being passed into `createTemplateAction` in the function where the behavior of your action is defined. Once the check is successful, you can perform the desired actions expected in a dry run, e.g. outputting non-sensitive inputs.
|
||||
|
||||
```typescript
|
||||
async handler(ctx) {
|
||||
@@ -91,9 +91,7 @@ If you're using backend permissions, pass a front-end auth token from a current
|
||||
|
||||
You can also query the dry run endpoint directly in code, for example:
|
||||
|
||||
`dry-run.js`
|
||||
|
||||
```javascript
|
||||
```javascript title="dry-run.js"
|
||||
const template = yaml.load(
|
||||
await fs.readFile('path/to/templates/template.yaml', 'utf-8'),
|
||||
);
|
||||
@@ -115,7 +113,7 @@ const response = await fetch(
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: 'Bearer <YOUR_API_KEY>', // replace 'YOUR_API_KEY' with your actual API key
|
||||
Authorization: 'Bearer <FRONT_END_TOKEN>', // replace 'FRONT_END_TOKEN' with your actual front-end auth token
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
},
|
||||
@@ -120,7 +120,8 @@
|
||||
"features/software-templates/writing-custom-step-layouts",
|
||||
"features/software-templates/authorizing-scaffolder-template-details",
|
||||
"features/software-templates/migrating-to-rjsf-v5",
|
||||
"features/software-templates/migrating-from-v1beta2-to-v1beta3"
|
||||
"features/software-templates/migrating-from-v1beta2-to-v1beta3",
|
||||
"features/software-templates/dry-run-testing"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
+1
-1
@@ -64,6 +64,7 @@ nav:
|
||||
- Writing Custom Actions: 'features/software-templates/writing-custom-actions.md'
|
||||
- Writing Custom Step Layouts: 'features/software-templates/writing-custom-step-layouts.md'
|
||||
- Migrating from v1beta2 to v1beta3 templates: 'features/software-templates/migrating-from-v1beta2-to-v1beta3.md'
|
||||
- Dry Run Testing: 'plugins/dry-run-testing.md'
|
||||
- Backstage Search:
|
||||
- Overview: 'features/search/README.md'
|
||||
- Getting Started: 'features/search/getting-started.md'
|
||||
@@ -139,7 +140,6 @@ nav:
|
||||
- URL Reader: 'plugins/url-reader.md'
|
||||
- Testing:
|
||||
- Testing with Jest: 'plugins/testing.md'
|
||||
- Dry Run Testing: 'plugins/dry-run-testing.md'
|
||||
- Publishing:
|
||||
- Publish private: 'plugins/publish-private.md'
|
||||
- Add to Directory: 'plugins/add-to-directory.md'
|
||||
|
||||
Reference in New Issue
Block a user