Skip to content

Commit 7cc36ca

Browse files
authored
Fix user-agent integration test for orchestration ID
1 parent cc685dc commit 7cc36ca

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

.github/workflows/integration.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,22 +154,28 @@ jobs:
154154
return endpoint({}).headers['user-agent']
155155
result-encoding: string
156156
- run: |
157+
matches_user_agent() {
158+
local actual="$1"
159+
local prefix="$2"
160+
[[ "$actual" =~ ^${prefix}(\ actions_orchestration_id/[^[:space:]]+)?\ octokit-core\.js/ ]]
161+
}
162+
157163
echo "- Validating user-agent default"
158-
expected="actions/github-script octokit-core.js/"
159-
if [[ "${{steps.user-agent-default.outputs.result}}" != "$expected"* ]]; then
160-
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-default.outputs.result}}"
164+
expected="actions/github-script"
165+
if ! matches_user_agent "${{steps.user-agent-default.outputs.result}}" "$expected"; then
166+
echo $'::error::\u274C' "Expected user-agent to start with '$expected' and include 'octokit-core.js/', got ${{steps.user-agent-default.outputs.result}}"
161167
exit 1
162168
fi
163169
echo "- Validating user-agent set to a value"
164-
expected="foobar octokit-core.js/"
165-
if [[ "${{steps.user-agent-set.outputs.result}}" != "$expected"* ]]; then
166-
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-set.outputs.result}}"
170+
expected="foobar"
171+
if ! matches_user_agent "${{steps.user-agent-set.outputs.result}}" "$expected"; then
172+
echo $'::error::\u274C' "Expected user-agent to start with '$expected' and include 'octokit-core.js/', got ${{steps.user-agent-set.outputs.result}}"
167173
exit 1
168174
fi
169175
echo "- Validating user-agent set to an empty string"
170-
expected="actions/github-script octokit-core.js/"
171-
if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
172-
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
176+
expected="actions/github-script"
177+
if ! matches_user_agent "${{steps.user-agent-empty.outputs.result}}" "$expected"; then
178+
echo $'::error::\u274C' "Expected user-agent to start with '$expected' and include 'octokit-core.js/', got ${{steps.user-agent-empty.outputs.result}}"
173179
exit 1
174180
fi
175181
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)