| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
35 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,8 @@ jobs: | |||
| 42 | 42 | result-encoding: string | |
| 43 | 43 | - run: | | |
| 44 | 44 | echo "- Validating relative require output" | |
| 45 | - if [[ "${{steps.relative-require.outputs.result}}" != "@actions/github-script" ]]; then | ||
| 45 | + expected="@actions/github-script" | ||
| 46 | + if [[ "${{steps.relative-require.outputs.result}}" != "$expected" ]]; then | ||
| 46 | 47 | echo $'::error::\u274C' "Expected '$expected', got ${{steps.relative-require.outputs.result}}" | |
| 47 | 48 | exit 1 | |
| 48 | 49 | fi | |
@@ -154,22 +155,54 @@ jobs: | |||
| 154 | 155 | return endpoint({}).headers['user-agent'] | |
| 155 | 156 | result-encoding: string | |
| 156 | 157 | - run: | | |
| 158 | + # User-agent format: <prefix> [actions_orchestration_id/<id>] octokit-core.js/<version> ... | ||
| 159 | + # When ACTIONS_ORCHESTRATION_ID is set, the orchestration ID is inserted after the prefix | ||
| 157 | 160 | echo "- Validating user-agent default" | |
| 158 | 161 | ua="${{steps.user-agent-default.outputs.result}}" | |
| 159 | - if [[ "$ua" != "actions/github-script octokit-core.js/"* ]] && [[ "$ua" != "actions/github-script actions_orchestration_id/"* ]]; then | ||
| 160 | - echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script', got $ua" | ||
| 162 | + if [[ "$ua" != "actions/github-script"* ]] || [[ "$ua" != *"octokit-core.js/"* ]]; then | ||
| 163 | + echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script' and contain 'octokit-core.js/', got $ua" | ||
| 161 | 164 | exit 1 | |
| 162 | 165 | fi | |
| 163 | 166 | echo "- Validating user-agent set to a value" | |
| 164 | 167 | ua="${{steps.user-agent-set.outputs.result}}" | |
| 165 | - if [[ "$ua" != "foobar octokit-core.js/"* ]] && [[ "$ua" != "foobar actions_orchestration_id/"* ]]; then | ||
| 166 | - echo $'::error::\u274C' "Expected user-agent to start with 'foobar', got $ua" | ||
| 168 | + if [[ "$ua" != "foobar"* ]] || [[ "$ua" != *"octokit-core.js/"* ]]; then | ||
| 169 | + echo $'::error::\u274C' "Expected user-agent to start with 'foobar' and contain 'octokit-core.js/', got $ua" | ||
| 167 | 170 | exit 1 | |
| 168 | 171 | fi | |
| 169 | 172 | echo "- Validating user-agent set to an empty string" | |
| 170 | 173 | ua="${{steps.user-agent-empty.outputs.result}}" | |
| 171 | - if [[ "$ua" != "actions/github-script octokit-core.js/"* ]] && [[ "$ua" != "actions/github-script actions_orchestration_id/"* ]]; then | ||
| 172 | - echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script', got $ua" | ||
| 174 | + if [[ "$ua" != "actions/github-script"* ]] || [[ "$ua" != *"octokit-core.js/"* ]]; then | ||
| 175 | + echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script' and contain 'octokit-core.js/', got $ua" | ||
| 176 | + exit 1 | ||
| 177 | + fi | ||
| 178 | + echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY | ||
| 179 | + | ||
| 180 | + test-get-octokit: | ||
| 181 | + name: 'Integration test: getOctokit with token' | ||
| 182 | + runs-on: ubuntu-latest | ||
| 183 | + steps: | ||
| 184 | + - uses: actions/checkout@v4 | ||
| 185 | + - uses: ./.github/actions/install-dependencies | ||
| 186 | + - id: secondary-client | ||
| 187 | + name: Create a second client with getOctokit | ||
| 188 | + uses: ./ | ||
| 189 | + env: | ||
| 190 | + APP_TOKEN: ${{ github.token }} | ||
| 191 | + with: | ||
| 192 | + script: | | ||
| 193 | + const appOctokit = getOctokit(process.env.APP_TOKEN) | ||
| 194 | + const {data} = await appOctokit.rest.repos.get({ | ||
| 195 | + owner: context.repo.owner, | ||
| 196 | + repo: context.repo.repo | ||
| 197 | + }) | ||
| 198 | + | ||
| 199 | + return `${appOctokit !== github}:${data.full_name}` | ||
| 200 | + result-encoding: string | ||
| 201 | + - run: | | ||
| 202 | + echo "- Validating secondary client output" | ||
| 203 | + expected="true:${{ github.repository }}" | ||
| 204 | + if [[ "${{steps.secondary-client.outputs.result}}" != "$expected" ]]; then | ||
| 205 | + echo $'::error::\u274C' "Expected '$expected', got ${{steps.secondary-client.outputs.result}}" | ||
| 173 | 206 | exit 1 | |
| 174 | 207 | fi | |
| 175 | 208 | echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY | |
| Back | FazBrowse Home | New Git URL |
0 commit comments