Skip to content

Commit 77c3c59

Browse files
🌟[Major] Introducing Get-PSModuleSettings GitHub Action (#1)
This release introduces a new GitHub Action, `Get-PSModuleSettings`, which replaces the previous template action in [PSModule/Process-PSModule](https://github.com/PSModule/Process-PSModule). The action is designed to load and process PowerShell module workflow settings from configuration files, compute job run conditions, and output structured settings and test suite information for use in CI pipelines. ## How It Works The `Get-PSModuleSettings` action: 1. **Loads settings** from a specified configuration file (supporting JSON, YAML, or PSD1 formats) 2. **Validates settings** against a comprehensive JSON schema to ensure correctness 3. **Applies defaults** for any missing configuration values 4. **Generates test suite matrices** for multiple operating systems (Linux, macOS, Windows) based on test discovery 5. **Computes job run conditions** based on PR state (open, updated, merged, abandoned) 6. **Outputs structured JSON** containing all settings, test suites, and run conditions for downstream workflow steps ### Configuration Format Support The action supports three configuration formats: - **JSON** - Standard JSON configuration files - **YAML/YML** - Human-readable YAML format - **PSD1** - PowerShell Data File format (native PowerShell hashtables) ### Test Suite Generation The action automatically discovers and categorizes tests into three types: - **SourceCode tests** - Static analysis and linting of source code - **PSModule tests** - Tests for the built PowerShell module - **Module tests** - Integration and functional tests with test matrices for each OS Test discovery supports: - `*.Configuration.ps1` - Test configuration files - `*.Container.ps1` - Test container files - `*.Tests.ps1` - Standard Pester test files ### Job Run Conditions The action calculates intelligent run conditions for each workflow job based on: - Pull request state (open, updated, merged, abandoned) - Configuration skip flags - Test suite availability - Ensures abandoned PRs don't waste CI resources --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent dddfeff commit 77c3c59

File tree

13 files changed

+983
-49
lines changed

13 files changed

+983
-49
lines changed

.github/linters/.powershell-psscriptanalyzer.psd1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
}
5151
}
5252
ExcludeRules = @(
53+
'PSAvoidUsingWriteHost', # Write-Host is acceptable in GitHub Actions runners
5354
'PSMissingModuleManifestField', # This rule is not applicable until the module is built.
5455
'PSUseToExportFieldsInManifest'
5556
)

.github/workflows/Action-Test.yml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ permissions:
1717
pull-requests: read
1818

1919
jobs:
20-
ActionTestBasic:
21-
name: Action-Test - [Basic]
20+
ActionTestValid:
21+
name: Action-Test - [Valid Configuration]
2222
runs-on: ubuntu-latest
2323
steps:
2424
# Need to check out as part of the test, as its a local action
@@ -28,6 +28,33 @@ jobs:
2828
persist-credentials: false
2929

3030
- name: Action-Test
31+
id: get-settings
3132
uses: ./
3233
with:
33-
Subject: PSModule
34+
SettingsPath: './tests/scenarios/valid/PSModule.yml'
35+
36+
ActionTestInvalidMissingTestConfig:
37+
name: Action-Test - [Invalid - Missing Test Config]
38+
runs-on: ubuntu-latest
39+
steps:
40+
# Need to check out as part of the test, as its a local action
41+
- name: Checkout repo
42+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
43+
with:
44+
persist-credentials: false
45+
46+
- name: Action-Test (Expect Failure)
47+
id: get-settings
48+
continue-on-error: true
49+
uses: ./
50+
with:
51+
SettingsPath: './tests/scenarios/invalid-percent-target/PSModule.yml'
52+
53+
- name: Verify Action Failed as Expected
54+
shell: pwsh
55+
run: |
56+
if ('${{ steps.get-settings.outcome }}' -eq 'success') {
57+
Write-Error 'Expected action to fail for invalid configuration, but it succeeded'
58+
exit 1
59+
}
60+
Write-Host '✓ Action failed as expected for invalid configuration'

.github/workflows/Linter.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jobs:
2828
uses: super-linter/super-linter@d5b0a2ab116623730dd094f15ddc1b6b25bf7b99 # v8.3.2
2929
env:
3030
GITHUB_TOKEN: ${{ github.token }}
31+
VALIDATE_BIOME_FORMAT: false
32+
VALIDATE_BIOME_LINT: false
33+
VALIDATE_GITHUB_ACTIONS_ZIZMOR: false
34+
VALIDATE_JSCPD: false
3135
VALIDATE_JSON_PRETTIER: false
3236
VALIDATE_MARKDOWN_PRETTIER: false
3337
VALIDATE_YAML_PRETTIER: false

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2025 PSModule
3+
Copyright (c) 2026 PSModule
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
# Template-Action
1+
# Get-PSModuleSettings
22

3-
A template repository for GitHub Actions
4-
5-
## Usage
6-
7-
### Inputs
8-
9-
### Secrets
10-
11-
### Outputs
12-
13-
### Example
14-
15-
```yaml
16-
Example here
17-
```
3+
This GitHub Action is a part of the [PSModule framework](https://github.com/PSModule).

action.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
name: Template-Action
2-
description: A template action for GitHub Actions using PowerShell
1+
name: Get-PSModuleSettings
2+
description: Get settings for a PowerShell module workflow
33
author: PSModule
44
branding:
5-
icon: upload-cloud
6-
color: white
5+
icon: settings
6+
color: blue
77

88
inputs:
9-
Subject:
10-
description: The subject to greet
9+
Name:
10+
description: Name of the module.
11+
required: false
12+
SettingsPath:
13+
description: Path to the settings file (json, yaml/yml, or psd1)
1114
required: false
12-
default: World
1315
Debug:
1416
description: Enable debug output.
1517
required: false
@@ -30,15 +32,29 @@ inputs:
3032
required: false
3133
default: ${{ github.workspace }}
3234

35+
outputs:
36+
Settings:
37+
description: The complete settings object as JSON, including test suites
38+
value: ${{ fromJson(steps.Get-PSModuleSettings.outputs.result).Settings }}
39+
3340
runs:
3441
using: composite
3542
steps:
36-
- name: Template-Action
43+
- name: Get-PSModuleSettings
3744
uses: PSModule/GitHub-Script@8b9d2739d6896975c0e5448d2021ae2b94b6766a # v1.7.6
45+
id: Get-PSModuleSettings
3846
env:
39-
PSMOUDLE_TEMPLATE_ACTION_INPUT_Subject: ${{ inputs.Subject }}
47+
PSMODULE_GET_SETTINGS_INPUT_Name: ${{ inputs.Name }}
48+
PSMODULE_GET_SETTINGS_INPUT_SettingsPath: ${{ inputs.SettingsPath }}
49+
PSMODULE_GET_SETTINGS_INPUT_Debug: ${{ inputs.Debug }}
50+
PSMODULE_GET_SETTINGS_INPUT_Verbose: ${{ inputs.Verbose }}
51+
PSMODULE_GET_SETTINGS_INPUT_Version: ${{ inputs.Version }}
52+
PSMODULE_GET_SETTINGS_INPUT_Prerelease: ${{ inputs.Prerelease }}
53+
PSMODULE_GET_SETTINGS_INPUT_WorkingDirectory: ${{ inputs.WorkingDirectory }}
4054
with:
41-
Name: Template-Action
55+
Name: Get-PSModuleSettings
56+
ShowInfo: false
57+
ShowOutput: true
4258
Debug: ${{ inputs.Debug }}
4359
Prerelease: ${{ inputs.Prerelease }}
4460
Verbose: ${{ inputs.Verbose }}

0 commit comments

Comments
 (0)