Skip to content

Commit 1fcb663

Browse files
🩹[Patch]: Workflow improvements (#55)
This pull request introduces several significant improvements to the GitHub Actions workflows, action implementation, and supporting test infrastructure. The most important changes include a complete overhaul of the release automation, enhancements to the action's prescript functionality, updates to workflow dependencies for improved security and reproducibility, and expanded test scripts for better validation and maintainability. **Workflow and Release Automation Updates:** * Replaces `.github/workflows/Auto-Release.yml` and `.github/release.yml` with a new `.github/workflows/Release.yml` workflow that is more targeted, triggers only on relevant changes, and uses a pinned version of the `PSModule/Release-GHRepository` action for deterministic releases. * Changes Dependabot update schedule from weekly to daily and introduces a cooldown period, improving dependency management responsiveness. **Action Implementation and Security:** * Refactors the action's execution logic to move prescript execution into a dedicated `src/prescript.ps1` script, which safely handles both inline scripts and file paths. Updates references in `action.yml` to use this new script and pins all GitHub Actions to specific commit SHAs for security and reproducibility. **Linter and Workflow Improvements:** * Updates linter workflow to use pinned versions of `actions/checkout` and `super-linter/super-linter`, disables certain validations for performance, and removes the `.github/linters/.jscpd.json` configuration file as duplicate code checks are now disabled. * Adds an exclusion for the `PSAvoidUsingWriteHost` rule in PowerShell Script Analyzer configuration, reflecting intentional usage for GitHub Actions output. **Documentation and Test Infrastructure:** * Enhances the `README.md` documentation for action inputs and outputs, improving formatting and clarity for users. * Adds new PowerShell test scripts (`tests/Prescript.ps1`, `tests/Show-Status.ps1`, `tests/Test-ActionResults.ps1`) to validate prescript execution, action status reporting, and aggregate test results with summary reporting. Updates test configuration to explicitly set code coverage paths. --- **Detailed list of most important changes:** **1. Workflow and Release Automation** - Replaces legacy auto-release workflows with a new, more secure and targeted `Release.yml` workflow, using pinned action versions and triggering only on relevant file changes. - Dependabot now checks for updates daily with a 7-day cooldown, improving dependency freshness. **2. Action Implementation and Security** - Moves prescript execution to a new `src/prescript.ps1` script that safely handles both inline and file-based scripts, and updates `action.yml` to use this script. - Pins all third-party GitHub Actions in workflows and action implementation to specific commit SHAs for enhanced security and reproducibility. **3. Linter and Workflow Improvements** - Updates linter workflow to use pinned versions and disables duplicate code checks and certain validations for performance; removes `.jscpd.json` as it is no longer needed. - Excludes `PSAvoidUsingWriteHost` in PowerShell linting to accommodate intentional usage in GitHub Actions. **4. Documentation and Test Infrastructure** - Improves documentation for action inputs and outputs in `README.md`, providing clearer descriptions and formatting. - Adds new test scripts for prescript validation, action status display, and aggregate action results, and updates test configuration for code coverage.
1 parent 882994c commit 1fcb663

19 files changed

Lines changed: 470 additions & 464 deletions

‎.github/dependabot.yml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ updates:
1111
- dependencies
1212
- github-actions
1313
schedule:
14-
interval: weekly
14+
interval: daily
15+
cooldown:
16+
default-days: 7

‎.github/linters/.jscpd.json‎

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

‎.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 intentionally used for GitHub Actions workflow commands and test output.
5354
'PSMissingModuleManifestField', # This rule is not applicable until the module is built.
5455
'PSUseToExportFieldsInManifest'
5556
)

‎.github/release.yml‎

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

‎.github/workflows/Action-Test.yml‎

Lines changed: 136 additions & 323 deletions
Large diffs are not rendered by default.

‎.github/workflows/Auto-Release.yml‎

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

‎.github/workflows/Linter.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout repo
22-
uses: actions/checkout@v6
22+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2323
with:
2424
fetch-depth: 0
25+
persist-credentials: false
2526

2627
- name: Lint code base
27-
uses: super-linter/super-linter@latest
28+
uses: super-linter/super-linter@d5b0a2ab116623730dd094f15ddc1b6b25bf7b99 # v8.3.2
2829
env:
2930
GITHUB_TOKEN: ${{ github.token }}
31+
VALIDATE_BIOME_FORMAT: false
32+
VALIDATE_JSCPD: false
3033
VALIDATE_JSON_PRETTIER: false
3134
VALIDATE_MARKDOWN_PRETTIER: false
3235
VALIDATE_YAML_PRETTIER: false
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
3+
run-name: "Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on:
6+
pull_request:
7+
branches:
8+
- main
9+
types:
10+
- closed
11+
- opened
12+
- reopened
13+
- synchronize
14+
- labeled
15+
paths:
16+
- 'action.yml'
17+
- 'src/**'
18+
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: write # Required to create releases
25+
pull-requests: write # Required to create comments on the PRs
26+
27+
jobs:
28+
Release:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout Code
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
33+
with:
34+
persist-credentials: false
35+
36+
- name: Release
37+
uses: PSModule/Release-GHRepository@88c70461c8f16cc09682005bcf3b7fca4dd8dc1a # v2.0.1

‎README.md‎

Lines changed: 70 additions & 70 deletions
Large diffs are not rendered by default.

‎action.yml‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ runs:
285285
using: composite
286286
steps:
287287
- name: Invoke-Pester (init)
288-
uses: PSModule/GitHub-Script@v1
288+
uses: PSModule/GitHub-Script@0097f3bbe3f413f3b577b9bcc600727b0ca3201a # v1.7.10
289289
env:
290290
PSMODULE_INVOKE_PESTER_INPUT_Path: ${{ inputs.Path }}
291291
PSMODULE_INVOKE_PESTER_INPUT_Run_Path: ${{ inputs.Run_Path }}
@@ -341,7 +341,7 @@ runs:
341341
Name: Invoke-Pester
342342
Script: |
343343
# Invoke-Pester (init)
344-
${{ github.action_path }}/scripts/init.ps1
344+
${{ github.action_path }}/src/init.ps1
345345
346346
- name: Invoke-Pester (exec)
347347
shell: pwsh
@@ -355,14 +355,15 @@ runs:
355355
PSMODULE_INVOKE_PESTER_INPUT_StepSummary_ShowConfiguration: ${{ inputs.StepSummary_ShowConfiguration }}
356356
PSMODULE_INVOKE_PESTER_INPUT_Debug: ${{ inputs.Debug }}
357357
PSMODULE_INVOKE_PESTER_INPUT_Verbose: ${{ inputs.Verbose }}
358+
PSMODULE_INVOKE_PESTER_INPUT_Prescript: ${{ inputs.Prescript }}
358359
id: test
359360
run: |
360361
# Invoke-Pester (exec)
361-
${{ inputs.Prescript }}
362-
${{ github.action_path }}/scripts/exec.ps1
362+
${{ github.action_path }}/src/prescript.ps1
363+
${{ github.action_path }}/src/exec.ps1
363364
364365
- name: Upload test results - [${{ steps.test.outputs.TestSuiteName }}-TestResults]
365-
uses: actions/upload-artifact@v5
366+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
366367
if: ${{ steps.test.outputs.TestResultEnabled == 'true' && (success() || failure()) }}
367368
with:
368369
name: ${{ steps.test.outputs.TestSuiteName }}-TestResults
@@ -371,7 +372,7 @@ runs:
371372
if-no-files-found: error
372373

373374
- name: Upload code coverage report - [${{ steps.test.outputs.TestSuiteName }}-CodeCoverage]
374-
uses: actions/upload-artifact@v5
375+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
375376
if: ${{ steps.test.outputs.CodeCoverageEnabled == 'true' && (success() || failure()) }}
376377
with:
377378
name: ${{ steps.test.outputs.TestSuiteName }}-CodeCoverage
@@ -398,4 +399,4 @@ runs:
398399
PSMODULE_INVOKE_PESTER_INTERNAL_TotalCount: ${{ steps.test.outputs.TotalCount }}
399400
run: |
400401
# Status
401-
${{ github.action_path }}/scripts/status.ps1
402+
${{ github.action_path }}/src/status.ps1

0 commit comments

Comments
 (0)