From 3caf72902e0d64f03ed1638b85159e31fca516eb Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 24 Dec 2024 12:10:59 +0100 Subject: [PATCH 1/3] Update GitHub Action tests to use user-specific tokens and add new test cases --- .github/workflows/Action-Test.yml | 63 +++++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index ea4866d..222c9b4 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -112,14 +112,14 @@ jobs: - name: Action-Test uses: ./ with: - Token: ${{ secrets.TEST_PAT }} + Token: ${{ secrets.TEST_USER_PAT }} Script: | LogGroup 'Get-GitHubUser' { Get-GitHubUser | Format-Table -AutoSize } - ActionTestWithFGPAT: - name: Action-Test - [WithFGPAT] + ActionTestWithUserFGPAT: + name: Action-Test - [WithUserFGPAT] runs-on: ubuntu-latest steps: # Need to check out as part of the test, as its a local action @@ -129,14 +129,14 @@ jobs: - name: Action-Test uses: ./ with: - Token: ${{ secrets.TEST_FG_PAT }} + Token: ${{ secrets.TEST_USER_USER_FG_PAT }} Script: | LogGroup 'Get-GitHubUser' { Get-GitHubUser | Format-Table -AutoSize } - ActionTestWithGitHubApp: - name: Action-Test - [GitHubApp] + ActionTestWithOrgFGPAT: + name: Action-Test - [WithOrgFGPAT] runs-on: ubuntu-latest steps: # Need to check out as part of the test, as its a local action @@ -146,8 +146,55 @@ jobs: - name: Action-Test uses: ./ with: - ClientID: ${{ secrets.TEST_APP_CLIENT_ID }} - PrivateKey: ${{ secrets.TEST_APP_PRIVATE_KEY }} + Token: ${{ secrets.TEST_USER_ORG_FG_PAT }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithGitHubAppEnt: + name: Action-Test - [GitHubAppEnt] + 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.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] + 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.TEST_APP_ORG_CLIENT_ID }} + PrivateKey: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} Script: | LogGroup 'Get-GitHubApp' { Get-GitHubApp | Format-Table -AutoSize From 180bf22a2daf4b0d1e8c6b85c626a3d9177374be Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 24 Dec 2024 12:25:25 +0100 Subject: [PATCH 2/3] Refactor GitHub Action tests to use matrix strategy for user and GitHub App tokens --- .github/workflows/Action-Test.yml | 77 +++++++++---------------------- 1 file changed, 23 insertions(+), 54 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 222c9b4..59dd4f0 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -118,8 +118,15 @@ jobs: Get-GitHubUser | Format-Table -AutoSize } - ActionTestWithUserFGPAT: - name: Action-Test - [WithUserFGPAT] + ActionTestWithFGPAT: + strategy: + matrix: + include: + - name: Action-Test - [WithUserFGPAT] + Token: ${{ secrets.TEST_USER_USER_FG_PAT }} + - name: Action-Test - [WithOrgFGPAT] + Token: ${{ secrets.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 @@ -129,14 +136,23 @@ jobs: - name: Action-Test uses: ./ with: - Token: ${{ secrets.TEST_USER_USER_FG_PAT }} + Token: ${{ matrix.Token }} Script: | LogGroup 'Get-GitHubUser' { Get-GitHubUser | Format-Table -AutoSize } - ActionTestWithOrgFGPAT: - name: Action-Test - [WithOrgFGPAT] + ActionTestWithGitHubApp: + strategy: + matrix: + include: + - name: Action-Test - [GitHubAppEnt] + clientID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} + privateKey: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} + - name: Action-Test - [GitHubAppOrg] + clientID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} + privateKey: ${{ secrets.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 @@ -146,55 +162,8 @@ jobs: - name: Action-Test uses: ./ with: - Token: ${{ secrets.TEST_USER_ORG_FG_PAT }} - Script: | - LogGroup 'Get-GitHubUser' { - Get-GitHubUser | Format-Table -AutoSize - } - - ActionTestWithGitHubAppEnt: - name: Action-Test - [GitHubAppEnt] - 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.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] - 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.TEST_APP_ORG_CLIENT_ID }} - PrivateKey: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} + ClientID: ${{ matrix.clientID }} + PrivateKey: ${{ matrix.privateKey }} Script: | LogGroup 'Get-GitHubApp' { Get-GitHubApp | Format-Table -AutoSize From 6f2fdf0aab4d9760c585cddacebfae7991d1533b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 24 Dec 2024 12:35:01 +0100 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20GitHub?= =?UTF-8?q?=20Action=20workflow=20to=20use=20secrets=20for=20tokens=20and?= =?UTF-8?q?=20credentials?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 59dd4f0..d60f839 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -123,9 +123,9 @@ jobs: matrix: include: - name: Action-Test - [WithUserFGPAT] - Token: ${{ secrets.TEST_USER_USER_FG_PAT }} + Token: TEST_USER_USER_FG_PAT - name: Action-Test - [WithOrgFGPAT] - Token: ${{ secrets.TEST_USER_ORG_FG_PAT }} + Token: TEST_USER_ORG_FG_PAT name: ${{ matrix.name }} runs-on: ubuntu-latest steps: @@ -136,7 +136,7 @@ jobs: - name: Action-Test uses: ./ with: - Token: ${{ matrix.Token }} + Token: ${{ secrets[matrix.Token] }} Script: | LogGroup 'Get-GitHubUser' { Get-GitHubUser | Format-Table -AutoSize @@ -147,11 +147,11 @@ jobs: matrix: include: - name: Action-Test - [GitHubAppEnt] - clientID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} - privateKey: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} + clientID: TEST_APP_ENT_CLIENT_ID + privateKey: TEST_APP_ENT_PRIVATE_KEY - name: Action-Test - [GitHubAppOrg] - clientID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} - privateKey: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} + clientID: TEST_APP_ORG_CLIENT_ID + privateKey: TEST_APP_ORG_PRIVATE_KEY name: ${{ matrix.name }} runs-on: ubuntu-latest steps: @@ -162,8 +162,8 @@ jobs: - name: Action-Test uses: ./ with: - ClientID: ${{ matrix.clientID }} - PrivateKey: ${{ matrix.privateKey }} + ClientID: ${{ secrets[matrix.clientID] }} + PrivateKey: ${{ secrets[matrix.privateKey] }} Script: | LogGroup 'Get-GitHubApp' { Get-GitHubApp | Format-Table -AutoSize