Skip to content

Commit d341348

Browse files
test matrix and reusable workflow
1 parent e843912 commit d341348

File tree

2 files changed

+215
-163
lines changed

2 files changed

+215
-163
lines changed

.github/workflows/Action-Test.yml

Lines changed: 7 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -17,168 +17,12 @@ permissions:
1717
pull-requests: read
1818

1919
jobs:
20-
ActionTestBasic:
21-
name: Action-Test - [Basic]
22-
runs-on: ubuntu-latest
23-
steps:
24-
# Need to check out as part of the test, as its a local action
25-
- name: Checkout repo
26-
uses: actions/checkout@v4
27-
28-
- name: Action-Test
29-
uses: ./
30-
with:
31-
Debug: true
32-
Verbose: true
33-
34-
ActionTestWithScript:
35-
name: Action-Test - [WithScript]
36-
runs-on: ubuntu-latest
37-
steps:
38-
# Need to check out as part of the test, as its a local action
39-
- name: Checkout repo
40-
uses: actions/checkout@v4
41-
42-
- name: Action-Test
43-
uses: ./
44-
with:
45-
Debug: true
46-
Verbose: true
47-
Script: |
48-
LogGroup 'Get-GitHubZen' {
49-
Get-GitHubZen
50-
}
51-
52-
LogGroup 'Get-GitHubViewer' {
53-
Get-GitHubViewer -Fields name, login, id, databaseID
54-
}
55-
56-
ActionTestCommands:
57-
name: Action-Test - [Commands]
58-
runs-on: ubuntu-latest
59-
steps:
60-
# Need to check out as part of the test, as its a local action
61-
- name: Checkout repo
62-
uses: actions/checkout@v4
63-
64-
- name: Action-Test
65-
uses: ./
66-
id: test
67-
with:
68-
Debug: true
69-
Verbose: true
70-
Prerelease: true
71-
ShowOutput: true
72-
Script: |
73-
$cat = Get-GitHubOctocat
74-
$zen = Get-GitHubZen
75-
Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat
76-
Set-GitHubOutput -Name 'WISECAT' -Value $cat
77-
Set-GitHubOutput -Name 'Zen' -Value $zen
78-
79-
- name: Run-test
80-
shell: pwsh
81-
env:
82-
result: ${{ steps.test.outputs.result }}
83-
WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }}
84-
run: |
85-
$result = $env:result | ConvertFrom-Json
86-
Set-GitHubStepSummary -Summary $env:WISECAT
87-
Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen'
88-
89-
ActionTestWithoutToken:
90-
name: Action-Test - [WithoutToken]
91-
runs-on: ubuntu-latest
92-
steps:
93-
# Need to check out as part of the test, as its a local action
94-
- name: Checkout repo
95-
uses: actions/checkout@v4
96-
97-
- name: Action-Test
98-
uses: ./
99-
with:
100-
Token: ''
101-
Script: |
102-
LogGroup 'My group' {
103-
'This is a group'
104-
}
105-
106-
ActionTestWithPAT:
107-
name: Action-Test - [WithPAT]
108-
runs-on: ubuntu-latest
109-
steps:
110-
# Need to check out as part of the test, as its a local action
111-
- name: Checkout repo
112-
uses: actions/checkout@v4
113-
114-
- name: Action-Test
115-
uses: ./
116-
with:
117-
Token: ${{ secrets.TEST_USER_PAT }}
118-
Script: |
119-
LogGroup 'Get-GitHubUser' {
120-
Get-GitHubUser | Format-Table -AutoSize
121-
}
122-
123-
ActionTestWithFGPAT:
20+
ActionTest:
21+
uses: ./.github/workflows/TestWorkflow.yml
22+
secrets: inherit
12423
strategy:
24+
fail-fast: false
12525
matrix:
126-
include:
127-
- name: Action-Test - [WithUserFGPAT]
128-
Token: TEST_USER_USER_FG_PAT
129-
- name: Action-Test - [WithOrgFGPAT]
130-
Token: TEST_USER_ORG_FG_PAT
131-
name: ${{ matrix.name }}
132-
runs-on: ubuntu-latest
133-
steps:
134-
# Need to check out as part of the test, as its a local action
135-
- name: Checkout repo
136-
uses: actions/checkout@v4
137-
138-
- name: Action-Test
139-
uses: ./
140-
with:
141-
Token: ${{ secrets[matrix.Token] }}
142-
Script: |
143-
LogGroup 'Get-GitHubUser' {
144-
Get-GitHubUser | Format-Table -AutoSize
145-
}
146-
147-
ActionTestWithGitHubApp:
148-
strategy:
149-
matrix:
150-
include:
151-
- name: Action-Test - [GitHubAppEnt]
152-
clientID: TEST_APP_ENT_CLIENT_ID
153-
privateKey: TEST_APP_ENT_PRIVATE_KEY
154-
- name: Action-Test - [GitHubAppOrg]
155-
clientID: TEST_APP_ORG_CLIENT_ID
156-
privateKey: TEST_APP_ORG_PRIVATE_KEY
157-
name: ${{ matrix.name }}
158-
runs-on: ubuntu-latest
159-
steps:
160-
# Need to check out as part of the test, as its a local action
161-
- name: Checkout repo
162-
uses: actions/checkout@v4
163-
164-
- name: Action-Test
165-
uses: ./
166-
with:
167-
ClientID: ${{ secrets[matrix.clientID] }}
168-
PrivateKey: ${{ secrets[matrix.privateKey] }}
169-
Script: |
170-
LogGroup 'Get-GitHubApp' {
171-
Get-GitHubApp | Format-Table -AutoSize
172-
}
173-
174-
LogGroup 'Get-GitHubAppInstallation' {
175-
Get-GitHubAppInstallation | Format-Table -AutoSize
176-
}
177-
178-
LogGroup 'Do something as an installation' {
179-
Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object {
180-
Connect-GitHub -Token $_.token -Silent
181-
Get-GitHubContext | Format-Table -AutoSize
182-
Get-GitHubGitConfig | Format-Table -AutoSize
183-
}
184-
}
26+
os: [ubuntu-latest, macos-latest, windows-latest]
27+
with:
28+
runs-on: ${{ matrix.os }}

.github/workflows/TestWorkflow.yml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
name: Action-Test
2+
3+
run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
runs-on:
9+
description: 'The operating system to run the tests on'
10+
required: true
11+
type: string
12+
secrets:
13+
TEST_USER_PAT:
14+
description: 'Personal Access Token for the test user'
15+
required: true
16+
TEST_USER_USER_FG_PAT:
17+
description: 'Personal Access Token for the test user with full gists scope'
18+
required: true
19+
TEST_USER_ORG_FG_PAT:
20+
description: 'Personal Access Token for the test user with full gists scope'
21+
required: true
22+
TEST_APP_ENT_CLIENT_ID:
23+
description: 'Client ID for the test GitHub App for the enterprise'
24+
required: true
25+
TEST_APP_ENT_PRIVATE_KEY:
26+
description: 'Private Key for the test GitHub App for the enterprise'
27+
required: true
28+
TEST_APP_ORG_CLIENT_ID:
29+
description: 'Client ID for the test GitHub App for the organization'
30+
required: true
31+
TEST_APP_ORG_PRIVATE_KEY:
32+
description: 'Private Key for the test GitHub App for the organization'
33+
required: true
34+
35+
concurrency:
36+
group: ${{ github.workflow }}-${{ github.ref }}
37+
cancel-in-progress: true
38+
39+
permissions:
40+
contents: read
41+
pull-requests: read
42+
43+
jobs:
44+
ActionTestBasic:
45+
name: Action-Test - [Basic] - [${{ inputs.runs-on }}]
46+
runs-on: ${{ inputs.runs-on }}
47+
steps:
48+
# Need to check out as part of the test, as its a local action
49+
- name: Checkout repo
50+
uses: actions/checkout@v4
51+
52+
- name: Action-Test
53+
uses: ./
54+
with:
55+
Debug: true
56+
Verbose: true
57+
58+
ActionTestWithScript:
59+
name: Action-Test - [WithScript] - [${{ inputs.runs-on }}]
60+
runs-on: ${{ inputs.runs-on }}
61+
steps:
62+
# Need to check out as part of the test, as its a local action
63+
- name: Checkout repo
64+
uses: actions/checkout@v4
65+
66+
- name: Action-Test
67+
uses: ./
68+
with:
69+
Debug: true
70+
Verbose: true
71+
Script: |
72+
LogGroup 'Get-GitHubZen' {
73+
Get-GitHubZen
74+
}
75+
76+
LogGroup 'Get-GitHubViewer' {
77+
Get-GitHubViewer -Fields name, login, id, databaseID
78+
}
79+
80+
ActionTestCommands:
81+
name: Action-Test - [Commands] - [${{ inputs.runs-on }}]
82+
runs-on: ${{ inputs.runs-on }}
83+
steps:
84+
# Need to check out as part of the test, as its a local action
85+
- name: Checkout repo
86+
uses: actions/checkout@v4
87+
88+
- name: Action-Test
89+
uses: ./
90+
id: test
91+
with:
92+
Debug: true
93+
Verbose: true
94+
Prerelease: true
95+
ShowOutput: true
96+
Script: |
97+
$cat = Get-GitHubOctocat
98+
$zen = Get-GitHubZen
99+
Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat
100+
Set-GitHubOutput -Name 'WISECAT' -Value $cat
101+
Set-GitHubOutput -Name 'Zen' -Value $zen
102+
103+
- name: Run-test
104+
shell: pwsh
105+
env:
106+
result: ${{ steps.test.outputs.result }}
107+
WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }}
108+
run: |
109+
$result = $env:result | ConvertFrom-Json
110+
Set-GitHubStepSummary -Summary $env:WISECAT
111+
Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen'
112+
113+
ActionTestWithoutToken:
114+
name: Action-Test - [WithoutToken] - [${{ inputs.runs-on }}]
115+
runs-on: ${{ inputs.runs-on }}
116+
steps:
117+
# Need to check out as part of the test, as its a local action
118+
- name: Checkout repo
119+
uses: actions/checkout@v4
120+
121+
- name: Action-Test
122+
uses: ./
123+
with:
124+
Token: ''
125+
Script: |
126+
LogGroup 'My group' {
127+
'This is a group'
128+
}
129+
130+
ActionTestWithPAT:
131+
name: Action-Test - [WithPAT] - [${{ inputs.runs-on }}]
132+
runs-on: ${{ inputs.runs-on }}
133+
steps:
134+
# Need to check out as part of the test, as its a local action
135+
- name: Checkout repo
136+
uses: actions/checkout@v4
137+
138+
- name: Action-Test
139+
uses: ./
140+
with:
141+
Token: ${{ secrets.TEST_USER_PAT }}
142+
Script: |
143+
LogGroup 'Get-GitHubUser' {
144+
Get-GitHubUser | Format-Table -AutoSize
145+
}
146+
147+
ActionTestWithFGPAT:
148+
strategy:
149+
matrix:
150+
include:
151+
- name: Action-Test - [WithUserFGPAT] - [${{ inputs.runs-on }}]
152+
Token: TEST_USER_USER_FG_PAT
153+
- name: Action-Test - [WithOrgFGPAT] - [${{ inputs.runs-on }}]
154+
Token: TEST_USER_ORG_FG_PAT
155+
name: ${{ matrix.name }}
156+
runs-on: ${{ inputs.runs-on }}
157+
steps:
158+
# Need to check out as part of the test, as its a local action
159+
- name: Checkout repo
160+
uses: actions/checkout@v4
161+
162+
- name: Action-Test
163+
uses: ./
164+
with:
165+
Token: ${{ secrets[matrix.Token] }}
166+
Script: |
167+
LogGroup 'Get-GitHubUser' {
168+
Get-GitHubUser | Format-Table -AutoSize
169+
}
170+
171+
ActionTestWithGitHubApp:
172+
strategy:
173+
matrix:
174+
include:
175+
- name: Action-Test - [GitHubAppEnt] - [${{ inputs.runs-on }}]
176+
clientID: TEST_APP_ENT_CLIENT_ID
177+
privateKey: TEST_APP_ENT_PRIVATE_KEY
178+
- name: Action-Test - [GitHubAppOrg] - [${{ inputs.runs-on }}]
179+
clientID: TEST_APP_ORG_CLIENT_ID
180+
privateKey: TEST_APP_ORG_PRIVATE_KEY
181+
name: ${{ matrix.name }}
182+
runs-on: ${{ inputs.runs-on }}
183+
steps:
184+
# Need to check out as part of the test, as its a local action
185+
- name: Checkout repo
186+
uses: actions/checkout@v4
187+
188+
- name: Action-Test
189+
uses: ./
190+
with:
191+
ClientID: ${{ secrets[matrix.clientID] }}
192+
PrivateKey: ${{ secrets[matrix.privateKey] }}
193+
Script: |
194+
LogGroup 'Get-GitHubApp' {
195+
Get-GitHubApp | Format-Table -AutoSize
196+
}
197+
198+
LogGroup 'Get-GitHubAppInstallation' {
199+
Get-GitHubAppInstallation | Format-Table -AutoSize
200+
}
201+
202+
LogGroup 'Do something as an installation' {
203+
Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object {
204+
Connect-GitHub -Token $_.token -Silent
205+
Get-GitHubContext | Format-Table -AutoSize
206+
Get-GitHubGitConfig | Format-Table -AutoSize
207+
}
208+
}

0 commit comments

Comments
 (0)