Skip to content

Commit 4605f86

Browse files
🩹[Patch] Move test module to PSModuleTest (#8)
- Move test module to `PSModuleTest`
1 parent 6921b3e commit 4605f86

File tree

8 files changed

+131
-79
lines changed

8 files changed

+131
-79
lines changed

.github/workflows/Workflow-Test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ on: [pull_request]
66

77
jobs:
88
WorkflowTestDefault:
9-
uses: ./.github/workflows/workflow.yml
9+
uses: ./.github/workflows/workflow.test.yml
1010
secrets: inherit
1111
with:
1212
Name: PSModule
13+
Path: tests/src
14+
ModulesOutputPath: tests/outputs/modules
15+
DocsOutputPath: tests/outputs/docs
1316
TestProcess: true
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Process-PSModule
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
APIKey:
7+
description: The API key to use when publishing modules
8+
required: true
9+
inputs:
10+
Name:
11+
type: string
12+
description: The name of the module to process. Scripts default to the repository name if nothing is specified.
13+
required: false
14+
Path:
15+
type: string
16+
description: The path to the source code of the module.
17+
required: false
18+
default: src
19+
ModulesOutputPath:
20+
type: string
21+
description: The path to the output directory for the modules.
22+
required: false
23+
default: outputs/modules
24+
DocsOutputPath:
25+
type: string
26+
description: The path to the output directory for the documentation.
27+
required: false
28+
default: outputs/docs
29+
SkipTests:
30+
type: boolean
31+
description: Whether to skip tests.
32+
required: false
33+
default: false
34+
TestProcess:
35+
type: boolean
36+
description: Whether to test the process.
37+
required: false
38+
default: false
39+
40+
env:
41+
GITHUB_TOKEN: ${{ github.token }} # Used for GitHub CLI authentication
42+
43+
jobs:
44+
Process-PSModule:
45+
name: Process module
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout Code
49+
uses: actions/checkout@v4
50+
51+
- name: Checkout tests -> PSModuleTest
52+
uses: actions/checkout@v4
53+
if: ${{ inputs.TestProcess == true }}
54+
with:
55+
repository: PSModule/PSModuleTest
56+
path: tests
57+
58+
- name: Delete outputs
59+
if: ${{ inputs.TestProcess == true }}
60+
shell: pwsh
61+
run: |
62+
Remove-Item -Path tests/outputs -Recurse -Force -Verbose
63+
64+
- name: Initialize environment
65+
uses: PSModule/Initialize-PSModule@v1
66+
67+
- name: Test source code
68+
uses: PSModule/Test-PSModule@v1
69+
if: ${{ inputs.SkipTests != true }}
70+
with:
71+
Name: ${{ inputs.Name }}
72+
Path: ${{ inputs.Path }}
73+
RunModuleTests: false
74+
75+
- name: Build module
76+
uses: PSModule/Build-PSModule@v1
77+
with:
78+
Name: ${{ inputs.Name }}
79+
Path: ${{ inputs.Path }}
80+
ModulesOutputPath: ${{ inputs.ModulesOutputPath }}
81+
DocsOutputPath: ${{ inputs.DocsOutputPath }}
82+
83+
- name: Test built module
84+
uses: PSModule/Test-PSModule@v1
85+
if: ${{ inputs.SkipTests != true }}
86+
with:
87+
Name: ${{ inputs.Name }}
88+
Path: ${{ inputs.ModulesOutputPath }}
89+
90+
- name: Publish module
91+
uses: PSModule/Publish-PSModule@v1
92+
with:
93+
Name: ${{ inputs.Name }}
94+
ModulePath: ${{ inputs.ModulesOutputPath }}
95+
DocsPath: ${{ inputs.DocsOutputPath }}
96+
APIKey: ${{ secrets.APIKEY }}
97+
WhatIf: ${{ inputs.TestProcess }}

.github/workflows/workflow.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ on:
1111
type: string
1212
description: The name of the module to process. Scripts default to the repository name if nothing is specified.
1313
required: false
14+
Path:
15+
type: string
16+
description: The path to the source code of the module.
17+
required: false
18+
default: src
19+
ModulesOutputPath:
20+
type: string
21+
description: The path to the output directory for the modules.
22+
required: false
23+
default: outputs/modules
24+
DocsOutputPath:
25+
type: string
26+
description: The path to the output directory for the documentation.
27+
required: false
28+
default: outputs/docs
1429
SkipTests:
1530
type: boolean
1631
description: Whether to skip tests.
@@ -41,29 +56,29 @@ jobs:
4156
if: ${{ inputs.SkipTests != true }}
4257
with:
4358
Name: ${{ inputs.Name }}
44-
Path: src
59+
Path: ${{ inputs.Path }}
4560
RunModuleTests: false
4661

4762
- name: Build module
4863
uses: PSModule/Build-PSModule@v1
4964
with:
5065
Name: ${{ inputs.Name }}
51-
Path: src
52-
ModulesOutputPath: outputs/modules
53-
DocsOutputPath: outputs/docs
66+
Path: ${{ inputs.Path }}
67+
ModulesOutputPath: ${{ inputs.ModulesOutputPath }}
68+
DocsOutputPath: ${{ inputs.DocsOutputPath }}
5469

5570
- name: Test built module
5671
uses: PSModule/Test-PSModule@v1
5772
if: ${{ inputs.SkipTests != true }}
5873
with:
5974
Name: ${{ inputs.Name }}
60-
Path: outputs/modules
75+
Path: ${{ inputs.ModulesOutputPath }}
6176

6277
- name: Publish module
6378
uses: PSModule/Publish-PSModule@v1
6479
with:
6580
Name: ${{ inputs.Name }}
66-
ModulePath: outputs/modules
67-
DocsPath: outputs/docs
81+
ModulePath: ${{ inputs.ModulesOutputPath }}
82+
DocsPath: ${{ inputs.DocsOutputPath }}
6883
APIKey: ${{ secrets.APIKEY }}
6984
WhatIf: ${{ inputs.TestProcess }}

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ The workflow is designed to be trigger on pull requests to the repository's defa
1818
When a pull request is opened, closed, reopened, synchronized (push), or labeled, the workflow will run.
1919
Depending on the labels in the pull requests, the workflow will result in different outcomes.
2020

21-
- [Initialize-PSModule](https://github.com/PSModule/Initialize-PSModule/) - To prepare the runner for all requirements of the framework.
22-
- [Test-PSModule](https://github.com/PSModule/Test-PSModule/) - Testing the source code using only PSScriptAnalyzer and the PSModule test suites.
23-
- [Build-PSModule](https://github.com/PSModule/Build-PSModule/) - To compile the repository into an efficient PowerShell module.
24-
- [Test-PSModule](https://github.com/PSModule/Test-PSModule/) - Testing the compiled module using PSScriptAnalyzer, PSModule test suites and custom module tests.
25-
- [Publish-PSModule](https://github.com/PSModule/Publish-PSModule/) - Publish the module to the PowerShell Gallery, publish docs to GitHub Pages, and create a release on the GitHub repository.
21+
- [Initialize-PSModule](https://github.com/PSModule/Initialize-PSModule/) - Prepares the runner with all the framework requirements.
22+
- [Test-PSModule](https://github.com/PSModule/Test-PSModule/) - Tests the source code using only PSScriptAnalyzer and the PSModule test suites.
23+
- [Build-PSModule](https://github.com/PSModule/Build-PSModule/) - Compiles the repository into an efficient PowerShell module.
24+
- [Test-PSModule](https://github.com/PSModule/Test-PSModule/) - Tests the compiled module using PSScriptAnalyzer, PSModule and module tests suites from the module repository.
25+
- [Publish-PSModule](https://github.com/PSModule/Publish-PSModule/) - Publishes the module to the PowerShell Gallery, docs to GitHub Pages, and creates a release on the GitHub repository.
2626

2727
To use the workflow, create a new file in the `.github/workflows` directory of the module repository and add the following content.
2828
<details>
@@ -64,6 +64,9 @@ jobs:
6464
| Name | Type | Description | Required | Default |
6565
| ---- | ---- | ----------- | -------- | ------- |
6666
| `Name` | `string` | The name of the module to process. This defaults to the repository name if nothing is specified. | `false` | N/A |
67+
| `Path` | `string` | The path to the source code of the module. | `false` | `src` |
68+
| `ModulesOutputPath` | `string` | The path to the output directory for the modules. | `false` | `outputs/modules` |
69+
| `DocsOutputPath` | `string` | The path to the output directory for the documentation. | `false` | `outputs/docs` |
6770
| `SkipTests` | `boolean` | Whether to skip the tests. | false | `false` |
6871
| `TestProcess` | `boolean` | Whether to test the process. | false | `false` |
6972

src/PSModule/PSModule.psd1

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/PSModule/PSModule.psm1

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/PSModule/public/Test-PSModule.ps1

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/PSModule.Tests.ps1

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)