Skip to content

Commit

Permalink
npalmGH-240 start adding workflow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
larmitage-bjss committed Feb 14, 2024
1 parent d55f6e5 commit a4d2096
Show file tree
Hide file tree
Showing 12 changed files with 243 additions and 248 deletions.
93 changes: 48 additions & 45 deletions __tests__/action-docs-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,39 @@ describe("Test output", () => {
expect(markdown).toEqual(expected);
});

// test("A minimal action definition.", async () => {
// const markdown = await generateActionMarkdownDocs({
// actionFile: path.join(fixtureDir, "minimal_action.yml"),
// });
// const expected = <string>(
// readFileSync(path.join(fixtureDir, "minimal_action.output"), "utf-8")
// );
test("A minimal workflow definition.", async () => {
const markdown = await generateActionMarkdownDocs({
actionFile: path.join(fixtureDir, "minimal_workflow.yml"),
includeNameHeader: true,
});
const expected = <string>(
readFileSync(path.join(fixtureDir, "minimal_workflow.output"), "utf-8")
);

// expect(markdown).toEqual(expected);
// });
expect(markdown).toEqual(expected);
});

// test("All fields action definition.", async () => {
// const markdown = await generateActionMarkdownDocs({
// actionFile: path.join(fixtureDir, "all_fields_action.yml"),
// });
// const expected = <string>(
// readFileSync(path.join(fixtureDir, "all_fields_action.output"), "utf-8")
// );
test("All fields workflow definition.", async () => {
const markdown = await generateActionMarkdownDocs({
actionFile: path.join(fixtureDir, "all_fields_workflow.yml"),
includeNameHeader: true,
});
const expected = <string>(
readFileSync(path.join(fixtureDir, "all_fields_workflow.output"), "utf-8")
);

// expect(markdown).toEqual(expected);
// });
// });
expect(markdown).toEqual(expected);
});
});

// describe("Test update readme ", () => {
// test("Empty readme (all fields)", async () => {
// await testReadme({
// actionFile: path.join(fixtureDir, "all_fields_action.yml"),
// originalReadme: path.join(fixtureDir, "all_fields_readme.input"),
// fixtureReadme: path.join(fixtureDir, "all_fields_readme.output"),
// });
// });
describe("Test update readme ", () => {
test("Empty readme (all fields)", async () => {
await testReadme({
actionFile: path.join(fixtureDir, "all_fields_workflow.yml"),
originalReadme: path.join(fixtureDir, "all_fields_readme.input"),
fixtureReadme: path.join(fixtureDir, "all_fields_readme.output"),
});
});

// test("Filled readme (all fields)", async () => {
// await testReadme({
Expand Down Expand Up @@ -104,26 +106,26 @@ describe("Test output", () => {
// fixtureReadme: path.join(fixtureDir, "two_actions_readme.output"),
// });
// });
// });

// describe("Test usage format", () => {
// test("Multi-line descriptions.", async () => {
// await testReadme({
// actionFile: path.join(fixtureDir, "workflow.yml"),
// originalReadme: path.join(fixtureDir, "action_usage_readme.input"),
// fixtureReadme: path.join(fixtureDir, "action_usage_readme.output"),
// });
// });

// test("With and without defaults.", async () => {
// await testReadme({
// actionFile: path.join(fixtureDir, "all_fields_action.yml"),
// originalReadme: path.join(fixtureDir, "all_fields_usage_readme.input"),
// fixtureReadme: path.join(fixtureDir, "all_fields_usage_readme.output"),
// });
// });
});

// describe("Test usage format", () => {
// test("Multi-line descriptions.", async () => {
// await testReadme({
// actionFile: path.join(fixtureDir, "workflow.yml"),
// originalReadme: path.join(fixtureDir, "action_usage_readme.input"),
// fixtureReadme: path.join(fixtureDir, "action_usage_readme.output"),
// });
// });

// test("With and without defaults.", async () => {
// await testReadme({
// actionFile: path.join(fixtureDir, "all_fields_action.yml"),
// originalReadme: path.join(fixtureDir, "all_fields_usage_readme.input"),
// fixtureReadme: path.join(fixtureDir, "all_fields_usage_readme.output"),
// });
// });
// });

interface ReadmeTestFixtures {
actionFile: string;
originalReadme: string;
Expand All @@ -142,6 +144,7 @@ async function testReadme(
actionFile: files.actionFile,
updateReadme: true,
readmeFile: files.originalReadme,
includeNameHeader: true,
...overwriteOptions,
});

Expand Down
27 changes: 0 additions & 27 deletions __tests__/fixtures/workflow/all_fields_action.output

This file was deleted.

32 changes: 0 additions & 32 deletions __tests__/fixtures/workflow/all_fields_action.yml

This file was deleted.

75 changes: 4 additions & 71 deletions __tests__/fixtures/workflow/all_fields_readme.input
Original file line number Diff line number Diff line change
@@ -1,74 +1,7 @@
<!-- action-docs-header action="__tests__/fixtures/all_fields_action.yml" -->
## An Action
<!-- action-docs-header action="__tests__/fixtures/all_fields_action.yml" -->
<!-- action-docs-header action="__tests__/fixtures/workflow/all_fields_action.yml" -->

<!-- action-docs-description action="__tests__/fixtures/all_fields_action.yml" -->
### Description
<!-- action-docs-usage action="__tests__/fixtures/workflow/all_fields_action.yml" project="npalm/action-docs" version="v1" -->

Default test
<!-- action-docs-description action="__tests__/fixtures/all_fields_action.yml" -->
<!-- action-docs-inputs action="__tests__/fixtures/workflow/all_fields_action.yml" -->

<!-- action-docs-usage action="__tests__/fixtures/all_fields_action.yml" project="npalm/action-docs" version="v1" -->
### Usage

```yaml
- uses: npalm/action-docs@v1
with:
inputA:
# A description A
#
# Required: false
# Default: ""

inputB:
# A description B
#
# Required: true
# Default: ""

inputC:
# A description C
#
# Required: true
# Default: C

inputD:
# A description D
#
# Required: false
# Default: D

inputE:
# A description E
#
# Required: false
# Default: false
```
<!-- action-docs-usage action="__tests__/fixtures/all_fields_action.yml" project="npalm/action-docs" version="v1" -->

<!-- action-docs-inputs action="__tests__/fixtures/all_fields_action.yml" -->
### Inputs

| name | description | required | default |
| --- | --- | --- | --- |
| `inputA` | <p>A description A</p> | `false` | `""` |
| `inputB` | <p>A description B</p> | `true` | `""` |
| `inputC` | <p>A description C</p> | `true` | `C` |
| `inputD` | <p>A description D</p> | `false` | `D` |
| `inputE` | <p>A description E</p> | `false` | `false` |
<!-- action-docs-inputs action="__tests__/fixtures/all_fields_action.yml" -->

<!-- action-docs-outputs action="__tests__/fixtures/all_fields_action.yml" -->
### Outputs

| name | description |
| --- | --- |
| `outputA` | <p>A description A</p> |
| `outputB` | <p>A description B</p> |
<!-- action-docs-outputs action="__tests__/fixtures/all_fields_action.yml" -->

<!-- action-docs-runs action="__tests__/fixtures/all_fields_action.yml" -->
### Runs

This action is a `node12` action.
<!-- action-docs-runs action="__tests__/fixtures/all_fields_action.yml" -->
<!-- action-docs-outputs action="__tests__/fixtures/workflow/all_fields_action.yml" -->
110 changes: 53 additions & 57 deletions __tests__/fixtures/workflow/all_fields_readme.output
Original file line number Diff line number Diff line change
@@ -1,74 +1,70 @@
<!-- action-docs-header action="__tests__/fixtures/all_fields_action.yml" -->
<!-- action-docs-header action="__tests__/fixtures/workflow/all_fields_action.yml" -->
## A Workflow
<!-- action-docs-header action="__tests__/fixtures/workflow/all_fields_action.yml" -->

<!-- action-docs-header action="__tests__/fixtures/all_fields_action.yml" -->

<!-- action-docs-description action="__tests__/fixtures/all_fields_action.yml" -->
## Description

Default test
<!-- action-docs-description action="__tests__/fixtures/all_fields_action.yml" -->

<!-- action-docs-usage action="__tests__/fixtures/all_fields_action.yml" project="npalm/action-docs" version="v1" -->
## Usage
<!-- action-docs-usage action="__tests__/fixtures/workflow/all_fields_action.yml" project="npalm/action-docs" version="v1" -->
### Usage

```yaml
- uses: npalm/action-docs@v1
with:
inputA:
# A description A
#
# Required: false
# Default: ""
jobs:
job1:
uses: ***PROJECT***@***VERSION***
with:
inputA:
# A description A
#
# Type: string
# Required: false
# Default: ""

inputB:
# A description B
#
# Required: true
# Default: ""
inputB:
# A description B
#
# Type: string
# Required: true
# Default: ""

inputC:
# A description C
#
# Required: true
# Default: C
inputC:
# A description C
#
# Type: string
# Required: true
# Default: C

inputD:
# A description D
#
# Required: false
# Default: D
inputD:
# A description D
#
# Type: string
# Required: false
# Default: D

inputE:
# A description E
#
# Required: false
# Default: false
inputE:
# A description E
#
# Type: string
# Required: false
# Default: false
```
<!-- action-docs-usage action="__tests__/fixtures/all_fields_action.yml" project="npalm/action-docs" version="v1" -->
<!-- action-docs-usage action="__tests__/fixtures/workflow/all_fields_action.yml" project="npalm/action-docs" version="v1" -->

<!-- action-docs-inputs action="__tests__/fixtures/all_fields_action.yml" -->
## Inputs
<!-- action-docs-inputs action="__tests__/fixtures/workflow/all_fields_action.yml" -->
### Inputs

| name | description | required | default |
| --- | --- | --- | --- |
| `inputA` | <p>A description A</p> | `false` | `""` |
| `inputB` | <p>A description B</p> | `true` | `""` |
| `inputC` | <p>A description C</p> | `true` | `C` |
| `inputD` | <p>A description D</p> | `false` | `D` |
| `inputE` | <p>A description E</p> | `false` | `false` |
<!-- action-docs-inputs action="__tests__/fixtures/all_fields_action.yml" -->
| name | description | type | required | default |
| --- | --- | --- | --- | --- |
| `inputA` | <p>A description A</p> | `string` | `false` | `""` |
| `inputB` | <p>A description B</p> | `string` | `true` | `""` |
| `inputC` | <p>A description C</p> | `string` | `true` | `C` |
| `inputD` | <p>A description D</p> | `string` | `false` | `D` |
| `inputE` | <p>A description E</p> | `string` | `false` | `false` |
<!-- action-docs-inputs action="__tests__/fixtures/workflow/all_fields_action.yml" -->

<!-- action-docs-outputs action="__tests__/fixtures/all_fields_action.yml" -->
## Outputs
<!-- action-docs-outputs action="__tests__/fixtures/workflow/all_fields_action.yml" -->
### Outputs

| name | description |
| --- | --- |
| `outputA` | <p>A description A</p> |
| `outputB` | <p>A description B</p> |
<!-- action-docs-outputs action="__tests__/fixtures/all_fields_action.yml" -->

<!-- action-docs-runs action="__tests__/fixtures/all_fields_action.yml" -->
## Runs
<!-- action-docs-outputs action="__tests__/fixtures/workflow/all_fields_action.yml" -->

This action is a `node12` action.
<!-- action-docs-runs action="__tests__/fixtures/all_fields_action.yml" -->
Loading

0 comments on commit a4d2096

Please sign in to comment.