|
| 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