mirror of
https://github.com/actions/github-script.git
synced 2026-03-28 08:55:03 +00:00
Fix user-agent integration test for orchestration ID
This commit is contained in:
24
.github/workflows/integration.yml
vendored
24
.github/workflows/integration.yml
vendored
@@ -154,22 +154,28 @@ jobs:
|
|||||||
return endpoint({}).headers['user-agent']
|
return endpoint({}).headers['user-agent']
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
- run: |
|
- run: |
|
||||||
|
matches_user_agent() {
|
||||||
|
local actual="$1"
|
||||||
|
local prefix="$2"
|
||||||
|
[[ "$actual" =~ ^${prefix}(\ actions_orchestration_id/[^[:space:]]+)?\ octokit-core\.js/ ]]
|
||||||
|
}
|
||||||
|
|
||||||
echo "- Validating user-agent default"
|
echo "- Validating user-agent default"
|
||||||
expected="actions/github-script octokit-core.js/"
|
expected="actions/github-script"
|
||||||
if [[ "${{steps.user-agent-default.outputs.result}}" != "$expected"* ]]; then
|
if ! matches_user_agent "${{steps.user-agent-default.outputs.result}}" "$expected"; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-default.outputs.result}}"
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected' and include 'octokit-core.js/', got ${{steps.user-agent-default.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "- Validating user-agent set to a value"
|
echo "- Validating user-agent set to a value"
|
||||||
expected="foobar octokit-core.js/"
|
expected="foobar"
|
||||||
if [[ "${{steps.user-agent-set.outputs.result}}" != "$expected"* ]]; then
|
if ! matches_user_agent "${{steps.user-agent-set.outputs.result}}" "$expected"; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-set.outputs.result}}"
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected' and include 'octokit-core.js/', got ${{steps.user-agent-set.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "- Validating user-agent set to an empty string"
|
echo "- Validating user-agent set to an empty string"
|
||||||
expected="actions/github-script octokit-core.js/"
|
expected="actions/github-script"
|
||||||
if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
|
if ! matches_user_agent "${{steps.user-agent-empty.outputs.result}}" "$expected"; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected' and include 'octokit-core.js/', got ${{steps.user-agent-empty.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
Reference in New Issue
Block a user