From e843912a9420315ba1cb5509d2d7bf907d41598d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 12:43:07 +0100 Subject: [PATCH 01/13] Disable JSCPD linter --- .github/workflows/Linter.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index c02889b..9477fd5 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -29,3 +29,4 @@ jobs: GITHUB_TOKEN: ${{ github.token }} VALIDATE_MARKDOWN_PRETTIER: false VALIDATE_YAML_PRETTIER: false + VALIDATE_JSCPD: false From d34134821d65d561dbbfaf07c3a1e2780b2f962c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 12:52:50 +0100 Subject: [PATCH 02/13] test matrix and reusable workflow --- .github/workflows/Action-Test.yml | 170 +---------------------- .github/workflows/TestWorkflow.yml | 208 +++++++++++++++++++++++++++++ 2 files changed, 215 insertions(+), 163 deletions(-) create mode 100644 .github/workflows/TestWorkflow.yml diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 72445dd..77b6918 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -17,168 +17,12 @@ permissions: pull-requests: read jobs: - ActionTestBasic: - name: Action-Test - [Basic] - runs-on: ubuntu-latest - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Action-Test - uses: ./ - with: - Debug: true - Verbose: true - - ActionTestWithScript: - name: Action-Test - [WithScript] - runs-on: ubuntu-latest - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Action-Test - uses: ./ - with: - Debug: true - Verbose: true - Script: | - LogGroup 'Get-GitHubZen' { - Get-GitHubZen - } - - LogGroup 'Get-GitHubViewer' { - Get-GitHubViewer -Fields name, login, id, databaseID - } - - ActionTestCommands: - name: Action-Test - [Commands] - runs-on: ubuntu-latest - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Action-Test - uses: ./ - id: test - with: - Debug: true - Verbose: true - Prerelease: true - ShowOutput: true - Script: | - $cat = Get-GitHubOctocat - $zen = Get-GitHubZen - Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - Set-GitHubOutput -Name 'WISECAT' -Value $cat - Set-GitHubOutput -Name 'Zen' -Value $zen - - - name: Run-test - shell: pwsh - env: - result: ${{ steps.test.outputs.result }} - WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }} - run: | - $result = $env:result | ConvertFrom-Json - Set-GitHubStepSummary -Summary $env:WISECAT - Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' - - ActionTestWithoutToken: - name: Action-Test - [WithoutToken] - runs-on: ubuntu-latest - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Action-Test - uses: ./ - with: - Token: '' - Script: | - LogGroup 'My group' { - 'This is a group' - } - - ActionTestWithPAT: - name: Action-Test - [WithPAT] - runs-on: ubuntu-latest - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Action-Test - uses: ./ - with: - Token: ${{ secrets.TEST_USER_PAT }} - Script: | - LogGroup 'Get-GitHubUser' { - Get-GitHubUser | Format-Table -AutoSize - } - - ActionTestWithFGPAT: + ActionTest: + uses: ./.github/workflows/TestWorkflow.yml + secrets: inherit strategy: + fail-fast: false matrix: - include: - - name: Action-Test - [WithUserFGPAT] - Token: TEST_USER_USER_FG_PAT - - name: Action-Test - [WithOrgFGPAT] - Token: TEST_USER_ORG_FG_PAT - name: ${{ matrix.name }} - runs-on: ubuntu-latest - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Action-Test - uses: ./ - with: - Token: ${{ secrets[matrix.Token] }} - Script: | - LogGroup 'Get-GitHubUser' { - Get-GitHubUser | Format-Table -AutoSize - } - - ActionTestWithGitHubApp: - strategy: - matrix: - include: - - name: Action-Test - [GitHubAppEnt] - clientID: TEST_APP_ENT_CLIENT_ID - privateKey: TEST_APP_ENT_PRIVATE_KEY - - name: Action-Test - [GitHubAppOrg] - clientID: TEST_APP_ORG_CLIENT_ID - privateKey: TEST_APP_ORG_PRIVATE_KEY - name: ${{ matrix.name }} - runs-on: ubuntu-latest - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Action-Test - uses: ./ - with: - ClientID: ${{ secrets[matrix.clientID] }} - PrivateKey: ${{ secrets[matrix.privateKey] }} - Script: | - LogGroup 'Get-GitHubApp' { - Get-GitHubApp | Format-Table -AutoSize - } - - LogGroup 'Get-GitHubAppInstallation' { - Get-GitHubAppInstallation | Format-Table -AutoSize - } - - LogGroup 'Do something as an installation' { - Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { - Connect-GitHub -Token $_.token -Silent - Get-GitHubContext | Format-Table -AutoSize - Get-GitHubGitConfig | Format-Table -AutoSize - } - } + os: [ubuntu-latest, macos-latest, windows-latest] + with: + runs-on: ${{ matrix.os }} diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml new file mode 100644 index 0000000..ece5ecd --- /dev/null +++ b/.github/workflows/TestWorkflow.yml @@ -0,0 +1,208 @@ +name: Action-Test + +run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" + +on: + workflow_call: + inputs: + runs-on: + description: 'The operating system to run the tests on' + required: true + type: string + secrets: + TEST_USER_PAT: + description: 'Personal Access Token for the test user' + required: true + TEST_USER_USER_FG_PAT: + description: 'Personal Access Token for the test user with full gists scope' + required: true + TEST_USER_ORG_FG_PAT: + description: 'Personal Access Token for the test user with full gists scope' + required: true + TEST_APP_ENT_CLIENT_ID: + description: 'Client ID for the test GitHub App for the enterprise' + required: true + TEST_APP_ENT_PRIVATE_KEY: + description: 'Private Key for the test GitHub App for the enterprise' + required: true + TEST_APP_ORG_CLIENT_ID: + description: 'Client ID for the test GitHub App for the organization' + required: true + TEST_APP_ORG_PRIVATE_KEY: + description: 'Private Key for the test GitHub App for the organization' + required: true + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + pull-requests: read + +jobs: + ActionTestBasic: + name: Action-Test - [Basic] - [${{ inputs.runs-on }}] + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Debug: true + Verbose: true + + ActionTestWithScript: + name: Action-Test - [WithScript] - [${{ inputs.runs-on }}] + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Debug: true + Verbose: true + Script: | + LogGroup 'Get-GitHubZen' { + Get-GitHubZen + } + + LogGroup 'Get-GitHubViewer' { + Get-GitHubViewer -Fields name, login, id, databaseID + } + + ActionTestCommands: + name: Action-Test - [Commands] - [${{ inputs.runs-on }}] + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + id: test + with: + Debug: true + Verbose: true + Prerelease: true + ShowOutput: true + Script: | + $cat = Get-GitHubOctocat + $zen = Get-GitHubZen + Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + Set-GitHubOutput -Name 'WISECAT' -Value $cat + Set-GitHubOutput -Name 'Zen' -Value $zen + + - name: Run-test + shell: pwsh + env: + result: ${{ steps.test.outputs.result }} + WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }} + run: | + $result = $env:result | ConvertFrom-Json + Set-GitHubStepSummary -Summary $env:WISECAT + Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' + + ActionTestWithoutToken: + name: Action-Test - [WithoutToken] - [${{ inputs.runs-on }}] + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Token: '' + Script: | + LogGroup 'My group' { + 'This is a group' + } + + ActionTestWithPAT: + name: Action-Test - [WithPAT] - [${{ inputs.runs-on }}] + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Token: ${{ secrets.TEST_USER_PAT }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithFGPAT: + strategy: + matrix: + include: + - name: Action-Test - [WithUserFGPAT] - [${{ inputs.runs-on }}] + Token: TEST_USER_USER_FG_PAT + - name: Action-Test - [WithOrgFGPAT] - [${{ inputs.runs-on }}] + Token: TEST_USER_ORG_FG_PAT + name: ${{ matrix.name }} + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Token: ${{ secrets[matrix.Token] }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithGitHubApp: + strategy: + matrix: + include: + - name: Action-Test - [GitHubAppEnt] - [${{ inputs.runs-on }}] + clientID: TEST_APP_ENT_CLIENT_ID + privateKey: TEST_APP_ENT_PRIVATE_KEY + - name: Action-Test - [GitHubAppOrg] - [${{ inputs.runs-on }}] + clientID: TEST_APP_ORG_CLIENT_ID + privateKey: TEST_APP_ORG_PRIVATE_KEY + name: ${{ matrix.name }} + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + ClientID: ${{ secrets[matrix.clientID] }} + PrivateKey: ${{ secrets[matrix.privateKey] }} + Script: | + LogGroup 'Get-GitHubApp' { + Get-GitHubApp | Format-Table -AutoSize + } + + LogGroup 'Get-GitHubAppInstallation' { + Get-GitHubAppInstallation | Format-Table -AutoSize + } + + LogGroup 'Do something as an installation' { + Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { + Connect-GitHub -Token $_.token -Silent + Get-GitHubContext | Format-Table -AutoSize + Get-GitHubGitConfig | Format-Table -AutoSize + } + } From 2a43e3c9390a92fa1c5e902b1339a79f5590b2f2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 12:57:33 +0100 Subject: [PATCH 03/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20GitH?= =?UTF-8?q?ub=20Actions=20workflow=20to=20simplify=20token=20handling=20an?= =?UTF-8?q?d=20add=20GitHub=20App=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/TestWorkflow.yml | 77 +++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 23 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index ece5ecd..549568d 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -144,15 +144,8 @@ jobs: Get-GitHubUser | Format-Table -AutoSize } - ActionTestWithFGPAT: - strategy: - matrix: - include: - - name: Action-Test - [WithUserFGPAT] - [${{ inputs.runs-on }}] - Token: TEST_USER_USER_FG_PAT - - name: Action-Test - [WithOrgFGPAT] - [${{ inputs.runs-on }}] - Token: TEST_USER_ORG_FG_PAT - name: ${{ matrix.name }} + ActionTestWithUSERFGPAT: + name: Action-Test - [WithUserFGPAT] - [${{ inputs.runs-on }}] runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -162,23 +155,14 @@ jobs: - name: Action-Test uses: ./ with: - Token: ${{ secrets[matrix.Token] }} + Token: ${{ secrets.TEST_USER_USER_FG_PAT }} Script: | LogGroup 'Get-GitHubUser' { Get-GitHubUser | Format-Table -AutoSize } - ActionTestWithGitHubApp: - strategy: - matrix: - include: - - name: Action-Test - [GitHubAppEnt] - [${{ inputs.runs-on }}] - clientID: TEST_APP_ENT_CLIENT_ID - privateKey: TEST_APP_ENT_PRIVATE_KEY - - name: Action-Test - [GitHubAppOrg] - [${{ inputs.runs-on }}] - clientID: TEST_APP_ORG_CLIENT_ID - privateKey: TEST_APP_ORG_PRIVATE_KEY - name: ${{ matrix.name }} + ActionTestWithORGFGPAT: + name: Action-Test - [WithOrgFGPAT] - [${{ inputs.runs-on }}] runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -188,8 +172,55 @@ jobs: - name: Action-Test uses: ./ with: - ClientID: ${{ secrets[matrix.clientID] }} - PrivateKey: ${{ secrets[matrix.privateKey] }} + Token: ${{ secrets.TEST_USER_ORG_FG_PAT }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithGitHubAppEnt: + name: Action-Test - [GitHubAppEnt] - [${{ inputs.runs-on }}] + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + ClientID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} + PrivateKey: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} + Script: | + LogGroup 'Get-GitHubApp' { + Get-GitHubApp | Format-Table -AutoSize + } + + LogGroup 'Get-GitHubAppInstallation' { + Get-GitHubAppInstallation | Format-Table -AutoSize + } + + LogGroup 'Do something as an installation' { + Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { + Connect-GitHub -Token $_.token -Silent + Get-GitHubContext | Format-Table -AutoSize + Get-GitHubGitConfig | Format-Table -AutoSize + } + } + + ActionTestWithGitHubAppOrg: + name: Action-Test - [GitHubAppOrg] - [${{ inputs.runs-on }}] + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + ClientID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} + PrivateKey: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} Script: | LogGroup 'Get-GitHubApp' { Get-GitHubApp | Format-Table -AutoSize From 44c2fada428cab33dd71c1a327dcf46106c0d08e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 12:58:48 +0100 Subject: [PATCH 04/13] Cleanup --- .github/workflows/TestWorkflow.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index 549568d..3b26d2b 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -1,7 +1,5 @@ name: Action-Test -run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" - on: workflow_call: inputs: @@ -32,10 +30,6 @@ on: description: 'Private Key for the test GitHub App for the organization' required: true -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - permissions: contents: read pull-requests: read From 86e49873843b71c654198ecbc6f3861a5fdb5be4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 12:59:01 +0100 Subject: [PATCH 05/13] Cleanup --- .github/workflows/TestWorkflow.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index 3b26d2b..da5551c 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -1,5 +1,3 @@ -name: Action-Test - on: workflow_call: inputs: From 77da34d919027d0bf8babfd7fe61c27c8cc875a7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 13:01:26 +0100 Subject: [PATCH 06/13] Test --- .github/workflows/TestWorkflow.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index da5551c..7f8e6af 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -34,7 +34,7 @@ permissions: jobs: ActionTestBasic: - name: Action-Test - [Basic] - [${{ inputs.runs-on }}] + name: Basic runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -48,7 +48,7 @@ jobs: Verbose: true ActionTestWithScript: - name: Action-Test - [WithScript] - [${{ inputs.runs-on }}] + name: WithScript runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -70,7 +70,7 @@ jobs: } ActionTestCommands: - name: Action-Test - [Commands] - [${{ inputs.runs-on }}] + name: Commands runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -103,7 +103,7 @@ jobs: Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' ActionTestWithoutToken: - name: Action-Test - [WithoutToken] - [${{ inputs.runs-on }}] + name: WithoutToken runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -120,7 +120,7 @@ jobs: } ActionTestWithPAT: - name: Action-Test - [WithPAT] - [${{ inputs.runs-on }}] + name: WithPAT runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -137,7 +137,7 @@ jobs: } ActionTestWithUSERFGPAT: - name: Action-Test - [WithUserFGPAT] - [${{ inputs.runs-on }}] + name: WithUserFGPAT runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -154,7 +154,7 @@ jobs: } ActionTestWithORGFGPAT: - name: Action-Test - [WithOrgFGPAT] - [${{ inputs.runs-on }}] + name: WithOrgFGPAT runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -171,7 +171,7 @@ jobs: } ActionTestWithGitHubAppEnt: - name: Action-Test - [GitHubAppEnt] - [${{ inputs.runs-on }}] + name: GitHubAppEnt runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action @@ -201,7 +201,7 @@ jobs: } ActionTestWithGitHubAppOrg: - name: Action-Test - [GitHubAppOrg] - [${{ inputs.runs-on }}] + name: GitHubAppOrg runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action From ab044fb1a14c007451a62068e8af9bf622683252 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 13:04:10 +0100 Subject: [PATCH 07/13] Update ActionTestCommands name to include Outputs --- .github/workflows/TestWorkflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index 7f8e6af..f869b8f 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -70,7 +70,7 @@ jobs: } ActionTestCommands: - name: Commands + name: Commands + Outputs runs-on: ${{ inputs.runs-on }} steps: # Need to check out as part of the test, as its a local action From 8f7c7796fef2338291099b359c4800658754190e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 13:19:24 +0100 Subject: [PATCH 08/13] Group tests --- .github/workflows/TestWorkflow.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index f869b8f..32e6f53 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -89,8 +89,13 @@ jobs: $cat = Get-GitHubOctocat $zen = Get-GitHubZen Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - Set-GitHubOutput -Name 'WISECAT' -Value $cat - Set-GitHubOutput -Name 'Zen' -Value $zen + LogGroup 'Set outputs WISECAT' { + Set-GitHubOutput -Name 'WISECAT' -Value $cat + } + + LogGroup 'Set outputs Zen' { + Set-GitHubOutput -Name 'Zen' -Value $zen + } - name: Run-test shell: pwsh From da8d4d26afb5f8c59690b542ae57d0219fb62d7e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 13:22:59 +0100 Subject: [PATCH 09/13] Add more loggroups --- .github/workflows/TestWorkflow.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index 32e6f53..9823eb8 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -86,9 +86,12 @@ jobs: Prerelease: true ShowOutput: true Script: | - $cat = Get-GitHubOctocat - $zen = Get-GitHubZen - Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + LogGroup 'Get-GitHubZen' { + $cat = Get-GitHubOctocat + $zen = Get-GitHubZen + Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + } + LogGroup 'Set outputs WISECAT' { Set-GitHubOutput -Name 'WISECAT' -Value $cat } From 2c273af5e96d82f8382c0b077a1d2dbbee2f60cf Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 13:45:47 +0100 Subject: [PATCH 10/13] Adjust PowerShell window and buffer size settings in action.yml --- action.yml | 2 ++ scripts/main.ps1 | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index 5935e46..d6e5312 100644 --- a/action.yml +++ b/action.yml @@ -66,6 +66,8 @@ runs: GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script + $Host.UI.RawUI.WindowSize.Width = 500 + $Host.UI.RawUI.BufferSize.Width = 500 . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') ${{ inputs.Script }} . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 95b46bf..db873ff 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,9 +1,6 @@ [CmdletBinding()] param() -$Host.UI.RawUI.WindowSize.Width = 500 -$Host.UI.RawUI.BufferSize.Width = 500 - $env:PSMODULE_GITHUB_SCRIPT = $true Write-Host "┏━━━━━┫ GitHub-Script ┣━━━━━┓" Write-Host '::group:: - Setup GitHub PowerShell' From a411f942f02d5669bfe901459c9660a37caa8afb Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 13:48:14 +0100 Subject: [PATCH 11/13] Remove PowerShell window and buffer size settings from action.yml --- action.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/action.yml b/action.yml index d6e5312..5935e46 100644 --- a/action.yml +++ b/action.yml @@ -66,8 +66,6 @@ runs: GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script - $Host.UI.RawUI.WindowSize.Width = 500 - $Host.UI.RawUI.BufferSize.Width = 500 . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\main.ps1') ${{ inputs.Script }} . $(Join-Path -Path '${{ github.action_path }}' -ChildPath 'scripts\outputs.ps1') From e7f79922cd09f5304a2c6074cd815626ec594c77 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 17:57:38 +0100 Subject: [PATCH 12/13] Add retry mechanism to install the PS module --- scripts/main.ps1 | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index db873ff..4a077b4 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -2,7 +2,7 @@ param() $env:PSMODULE_GITHUB_SCRIPT = $true -Write-Host "┏━━━━━┫ GitHub-Script ┣━━━━━┓" +Write-Host '┏━━━━━┫ GitHub-Script ┣━━━━━┓' Write-Host '::group:: - Setup GitHub PowerShell' $Name = 'GitHub' @@ -30,7 +30,21 @@ if (-not $alreadyInstalled) { if ($Version) { $params['Version'] = $Version } - Install-PSResource @params + $Count = 5 + $Delay = 10 + for ($i = 0; $i -lt $Count; $i++) { + try { + Install-PSResource @params + break + } catch { + Write-Warning "Installing $name failed with error: $_" + if ($i -eq $Count - 1) { + throw + } + Write-Warning "Retrying in $Delay seconds..." + Start-Sleep -Seconds $Delay + } + } } $alreadyImported = Get-Module -Name $Name From 7da76c78a0b383bf2fa3d5db09375649a0891bce Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Jan 2025 18:00:14 +0100 Subject: [PATCH 13/13] remove noise --- scripts/main.ps1 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 4a077b4..815502a 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -37,11 +37,9 @@ if (-not $alreadyInstalled) { Install-PSResource @params break } catch { - Write-Warning "Installing $name failed with error: $_" if ($i -eq $Count - 1) { - throw + throw $_ } - Write-Warning "Retrying in $Delay seconds..." Start-Sleep -Seconds $Delay } }