Skip to content

Commit 080b28e

Browse files
🩹 [Patch]: Run tests on all OS'es (#19)
## Description This pull request includes significant changes to the GitHub Actions workflows and a script file. The changes aim to consolidate workflow configurations, improve error handling, and add new validation settings. ### Workflow Consolidation and Improvements: * [`.github/workflows/Action-Test.yml`](diffhunk://#diff-a12ae5c885b0673c0ff6f70c2670886907590d624626e07da4c52e01aeaf56a4L20-R28): Consolidated multiple test jobs into a single reusable workflow by referencing `TestWorkflow.yml` and using matrix strategy for operating systems. * [`.github/workflows/TestWorkflow.yml`](diffhunk://#diff-242a265d6d6bfff6094c9285345022d0e6d7ddde58504dfc80249fafbd89ba2cR1-R239): Created a new reusable workflow with multiple test jobs, including `ActionTestBasic`, `ActionTestWithScript`, `ActionTestCommands`, `ActionTestWithoutToken`, and `ActionTestWithPAT`. ### Validation Settings: * [`.github/workflows/Linter.yml`](diffhunk://#diff-482e65806ed9e4a7320f14964764086b91fed4a28d12e4efde1776472e147e79R32): Added a new validation setting `VALIDATE_JSCPD` to the environment variables. ### Script File Enhancements: * [`scripts/main.ps1`](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011R33-R45): Improved error handling in the `Install-PSResource` function by adding a retry mechanism with a delay. * [`scripts/main.ps1`](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011L4-R5): Made minor formatting changes to the script output. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [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 b19f29e commit 080b28e

File tree

4 files changed

+261
-168
lines changed

4 files changed

+261
-168
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/Linter.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ jobs:
2929
GITHUB_TOKEN: ${{ github.token }}
3030
VALIDATE_MARKDOWN_PRETTIER: false
3131
VALIDATE_YAML_PRETTIER: false
32+
VALIDATE_JSCPD: false

0 commit comments

Comments
 (0)