Skip to content

Commit 4a32e68

Browse files
🚀 [Feature]: Enter the Matrix (#12)
## Description - Fixes #13 - Add testing of source code and module as matrix of different OS'es. - Add test, build and publish as stages, and use artifacts to pass build module. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [x] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 336136c commit 4a32e68

27 files changed

+681
-116
lines changed

.github/workflows/Linter.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ run-name: "Linter - [${{ github.event.pull_request.title }} #${{ github.event.pu
44

55
on: [pull_request]
66

7+
permissions:
8+
contents: read
9+
packages: read
10+
statuses: write # To report GitHub Actions status checks
11+
712
jobs:
813
Lint:
914
name: Lint code base
1015
runs-on: ubuntu-latest
1116
steps:
1217
- name: Checkout repo
1318
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
1421

1522
- name: Lint code base
16-
uses: github/super-linter@latest
23+
uses: super-linter/super-linter@latest
1724
env:
1825
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/Workflow-Test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ run-name: "Workflow-Test - [${{ github.event.pull_request.title }} #${{ github.e
44

55
on: [pull_request]
66

7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
711
jobs:
812
WorkflowTestDefault:
9-
uses: ./.github/workflows/workflow.test.yml
13+
uses: ./.github/workflows/workflow.yml
1014
secrets: inherit
1115
with:
12-
Name: PSModule
16+
Name: PSModuleTest
1317
Path: tests/src
1418
ModulesOutputPath: tests/outputs/modules
1519
DocsOutputPath: tests/outputs/docs
1620
TestProcess: true
17-
PreRelease: true

.github/workflows/workflow.test.yml

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

.github/workflows/workflow.yml

Lines changed: 138 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,59 @@ on:
4949
env:
5050
GITHUB_TOKEN: ${{ github.token }} # Used for GitHub CLI authentication
5151

52+
permissions:
53+
contents: write
54+
pull-requests: write
55+
5256
jobs:
53-
Process-PSModule:
54-
name: Process module
55-
runs-on: ubuntu-latest
57+
TestSourceCode:
58+
name: Test source code
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
shell: [pwsh]
63+
os: [ubuntu-latest, macos-latest, windows-latest]
64+
include:
65+
- shell: powershell
66+
os: windows-latest
67+
runs-on: ${{ matrix.os }}
5668
steps:
5769
- name: Checkout Code
5870
uses: actions/checkout@v4
71+
with:
72+
fetch-depth: 0
5973

6074
- name: Initialize environment
6175
uses: PSModule/Initialize-PSModule@v1
6276
with:
6377
Version: ${{ inputs.Version }}
6478
Prerelease: ${{ inputs.Prerelease }}
79+
Shell: ${{ matrix.shell }}
6580

6681
- name: Test source code
6782
uses: PSModule/Test-PSModule@v1
6883
if: ${{ inputs.SkipTests != true }}
6984
with:
7085
Name: ${{ inputs.Name }}
7186
Path: ${{ inputs.Path }}
87+
Shell: ${{ matrix.shell }}
7288
RunModuleTests: false
7389

90+
BuildModule:
91+
name: Build module
92+
runs-on: ubuntu-latest
93+
steps:
94+
- name: Checkout Code
95+
uses: actions/checkout@v4
96+
with:
97+
fetch-depth: 0
98+
99+
- name: Initialize environment
100+
uses: PSModule/Initialize-PSModule@v1
101+
with:
102+
Version: ${{ inputs.Version }}
103+
Prerelease: ${{ inputs.Prerelease }}
104+
74105
- name: Build module
75106
uses: PSModule/Build-PSModule@v1
76107
with:
@@ -79,12 +110,116 @@ jobs:
79110
ModulesOutputPath: ${{ inputs.ModulesOutputPath }}
80111
DocsOutputPath: ${{ inputs.DocsOutputPath }}
81112

113+
- name: Upload module artifact
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: ${{ inputs.Name }}-module
117+
path: ${{ inputs.ModulesOutputPath }}
118+
if-no-files-found: error
119+
retention-days: 1
120+
121+
- name: Upload docs artifact
122+
uses: actions/upload-artifact@v4
123+
with:
124+
name: ${{ inputs.Name }}-docs
125+
path: ${{ inputs.DocsOutputPath }}
126+
if-no-files-found: error
127+
retention-days: 1
128+
129+
TestBuildModule:
130+
name: Test built module
131+
needs: BuildModule
132+
strategy:
133+
fail-fast: false
134+
matrix:
135+
shell: [pwsh]
136+
os: [ubuntu-latest, macos-latest, windows-latest]
137+
include:
138+
- shell: powershell
139+
os: windows-latest
140+
runs-on: ${{ matrix.os }}
141+
steps:
142+
- name: Initialize environment
143+
uses: PSModule/Initialize-PSModule@v1
144+
with:
145+
Version: ${{ inputs.Version }}
146+
Prerelease: ${{ inputs.Prerelease }}
147+
Shell: ${{ matrix.shell }}
148+
149+
- name: Download module artifact
150+
uses: actions/download-artifact@v4
151+
with:
152+
name: ${{ inputs.Name }}-module
153+
path: ${{ inputs.ModulesOutputPath }}
154+
82155
- name: Test built module
83156
uses: PSModule/Test-PSModule@v1
84157
if: ${{ inputs.SkipTests != true }}
85158
with:
86159
Name: ${{ inputs.Name }}
87160
Path: ${{ inputs.ModulesOutputPath }}
161+
Shell: ${{ matrix.shell }}
162+
163+
LintDocs:
164+
name: Lint documentation
165+
needs: BuildModule
166+
runs-on: ubuntu-latest
167+
steps:
168+
- name: Checkout Code
169+
uses: actions/checkout@v4
170+
with:
171+
fetch-depth: 0
172+
173+
- name: Download docs artifact
174+
uses: actions/download-artifact@v4
175+
with:
176+
name: ${{ inputs.Name }}-docs
177+
path: ${{ inputs.DocsOutputPath }}
178+
179+
- name: Git add - For linting
180+
run: |
181+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
182+
git config --global user.name "github-actions[bot]"
183+
git add .
184+
git commit -m "Update documentation"
185+
186+
- name: Lint documentation
187+
uses: super-linter/super-linter/slim@latest
188+
env:
189+
GITHUB_TOKEN: ${{ github.token }}
190+
VALIDATE_NATURAL_LANGUAGE: true
191+
VALIDATE_MARKDOWN: true
192+
193+
PublishModule:
194+
name: Publish module
195+
needs:
196+
- TestSourceCode
197+
- TestBuildModule
198+
- LintDocs
199+
runs-on: ubuntu-latest
200+
steps:
201+
- name: Checkout Code
202+
uses: actions/checkout@v4
203+
with:
204+
fetch-depth: 0
205+
206+
- name: Initialize environment
207+
uses: PSModule/Initialize-PSModule@v1
208+
with:
209+
Version: ${{ inputs.Version }}
210+
Prerelease: ${{ inputs.Prerelease }}
211+
212+
- name: Download module artifact
213+
uses: actions/download-artifact@v4
214+
with:
215+
name: ${{ inputs.Name }}-module
216+
path: ${{ inputs.ModulesOutputPath }}
217+
218+
- name: Download docs artifact
219+
uses: actions/download-artifact@v4
220+
with:
221+
name: ${{ inputs.Name }}-docs
222+
path: ${{ inputs.DocsOutputPath }}
88223

89224
- name: Publish module
90225
uses: PSModule/Publish-PSModule@v1

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,14 @@ permissions:
112112
contents: write # Required to create releases
113113
pull-requests: write # Required to create comments on the PRs
114114
```
115+
116+
## Compatibility
117+
118+
The action is compatible with the following configurations:
119+
120+
| OS | Shell |
121+
| --- | --- |
122+
| windows-latest | pwsh |
123+
| windows-latest | powershell |
124+
| macos-latest | pwsh |
125+
| ubuntu-latest | pwsh |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@{
2+
ModuleVersion = '0.0.0'
3+
RootModule = 'PSModuleTest.psm1'
4+
}

0 commit comments

Comments
 (0)