Skip to content

Commit 4ccb54f

Browse files
Run action unit tests on pull requests that touch an action
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 54ff4db commit 4ccb54f

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

.github/workflows/Test-Actions.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Test-Actions
2+
3+
run-name: "Test-Actions - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on:
6+
workflow_dispatch:
7+
pull_request:
8+
paths:
9+
- '.github/actions/**'
10+
- '.github/workflows/Test-Actions.yml'
11+
schedule:
12+
- cron: '0 0 * * *'
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
permissions:
19+
contents: read
20+
21+
jobs:
22+
TestActions:
23+
name: Test actions
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repo
27+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
28+
with:
29+
persist-credentials: false
30+
31+
- name: Install-PSModule
32+
uses: ./.github/actions/Install-PSModule
33+
34+
- name: Install test dependencies
35+
shell: pwsh
36+
run: |
37+
Install-PSResource -Name Pester -Version '[5.7.1,6.0.0)' -Repository PSGallery -TrustRepository
38+
Install-PSResource -Name PSSemVer -Repository PSGallery -TrustRepository
39+
40+
- name: Run action unit tests
41+
shell: pwsh
42+
run: |
43+
$testPaths = Get-ChildItem -Path '.github/actions' -Directory |
44+
ForEach-Object { Join-Path -Path $_.FullName -ChildPath 'tests' } |
45+
Where-Object { Test-Path -Path $_ }
46+
if (-not $testPaths) {
47+
throw 'No action test folders were found under .github/actions.'
48+
}
49+
50+
$configuration = New-PesterConfiguration
51+
$configuration.Run.Path = $testPaths
52+
$configuration.Run.Throw = $true
53+
$configuration.Output.Verbosity = 'Detailed'
54+
Invoke-Pester -Configuration $configuration

0 commit comments

Comments
 (0)