diff --git a/docs/plugins/dry-run-testing.md b/docs/features/software-templates/dry-run-testing.md similarity index 87% rename from docs/plugins/dry-run-testing.md rename to docs/features/software-templates/dry-run-testing.md index 18b7343920..fb2de0f672 100644 --- a/docs/plugins/dry-run-testing.md +++ b/docs/features/software-templates/dry-run-testing.md @@ -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 ', // replace 'YOUR_API_KEY' with your actual API key + Authorization: 'Bearer ', // replace 'FRONT_END_TOKEN' with your actual front-end auth token }, body: JSON.stringify(body), }, diff --git a/microsite/sidebars.json b/microsite/sidebars.json index 075025afbb..2e1d74f739 100644 --- a/microsite/sidebars.json +++ b/microsite/sidebars.json @@ -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" ] }, { diff --git a/mkdocs.yml b/mkdocs.yml index 045238e97e..3e8c7864c3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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'