mirror of
https://github.com/actions/github-script.git
synced 2026-02-08 03:57:27 +00:00
Include GraphQL URL validations
This commit is contained in:
parent
98dabfb42f
commit
ec76ce579c
1 changed files with 74 additions and 11 deletions
85
.github/workflows/integration.yml
vendored
85
.github/workflows/integration.yml
vendored
|
|
@ -255,16 +255,27 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
|
|
||||||
- id: base-url-default
|
- id: base-url-default
|
||||||
name: Default base-url not set
|
name: API URL with base-url not set
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const endpoint = github.request.endpoint
|
const endpoint = github.request.endpoint
|
||||||
return endpoint({}).url
|
return endpoint({}).url
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
|
|
||||||
|
- id: base-url-default-graphql
|
||||||
|
name: GraphQL URL with base-url not set
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({url: "/graphql"}).url
|
||||||
|
result-encoding: string
|
||||||
|
|
||||||
- id: base-url-set
|
- id: base-url-set
|
||||||
name: base-url set
|
name: API URL with base-url set
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
base-url: https://my.github-enterprise-server.com/api/v3
|
base-url: https://my.github-enterprise-server.com/api/v3
|
||||||
|
|
@ -272,8 +283,19 @@ jobs:
|
||||||
const endpoint = github.request.endpoint
|
const endpoint = github.request.endpoint
|
||||||
return endpoint({}).url
|
return endpoint({}).url
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
|
|
||||||
|
- id: base-url-set-graphql
|
||||||
|
name: GraphQL URL with base-url set
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
base-url: https://my.github-enterprise-server.com/api/v3
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({url: "/graphql"}).url
|
||||||
|
result-encoding: string
|
||||||
|
|
||||||
- id: base-url-env
|
- id: base-url-env
|
||||||
name: base-url does not override GITHUB_API_URL when not set
|
name: base-url does not override API URL when not set
|
||||||
uses: ./
|
uses: ./
|
||||||
env:
|
env:
|
||||||
GITHUB_API_URL: https://my.github-enterprise-server.com/api/v3
|
GITHUB_API_URL: https://my.github-enterprise-server.com/api/v3
|
||||||
|
|
@ -282,22 +304,63 @@ jobs:
|
||||||
const endpoint = github.request.endpoint
|
const endpoint = github.request.endpoint
|
||||||
return endpoint({}).url
|
return endpoint({}).url
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
|
|
||||||
|
- id: base-url-env-graphql
|
||||||
|
name: base-url does not override GraphQL URL when not set
|
||||||
|
uses: ./
|
||||||
|
env:
|
||||||
|
GITHUB_API_URL: https://my.github-enterprise-server.com/api/v3
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const endpoint = github.request.endpoint
|
||||||
|
return endpoint({url: "/graphql"}).url
|
||||||
|
result-encoding: string
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
echo "- Validating base-url default"
|
echo "- Validating API URL default"
|
||||||
expected="https://api.github.com/"
|
expected="https://api.github.com/"
|
||||||
if [[ "${{steps.base-url-default.outputs.result}}" != "$expected" ]]; then
|
actual="${{steps.base-url-default.outputs.result}}"
|
||||||
echo $'::error::\u274C' "Expected base-url to equal '$expected', got ${{steps.base-url-default.outputs.result}}"
|
if [[ "$expected" != "$actual" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "- Validating GraphQL URL default"
|
||||||
|
expected="https://api.github.com/graphql"
|
||||||
|
actual="${{steps.base-url-default-graphql.outputs.result}}"
|
||||||
|
if [[ "$expected" != "$actual" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "- Validating base-url set to a value"
|
echo "- Validating base-url set to a value"
|
||||||
expected="https://my.github-enterprise-server.com/api/v3/"
|
expected="https://my.github-enterprise-server.com/api/v3/"
|
||||||
if [[ "${{steps.base-url-set.outputs.result}}" != "$expected" ]]; then
|
actual="${{steps.base-url-set.outputs.result}}"
|
||||||
echo $'::error::\u274C' "Expected base-url to equal '$expected', got ${{steps.base-url-set.outputs.result}}"
|
if [[ "$expected" != "$actual" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "- Validating base-url not set respects GITHUB_API_URL"
|
|
||||||
|
echo "- Validating GraphQL URL with base-url set to a value"
|
||||||
|
expected="https://my.github-enterprise-server.com/api/v3/graphql"
|
||||||
|
actual="${{steps.base-url-set-graphql.outputs.result}}"
|
||||||
|
if [[ "$expected" != "$actual" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "- Validating API URL with base-url not set respects GITHUB_API_URL"
|
||||||
expected="https://my.github-enterprise-server.com/api/v3/"
|
expected="https://my.github-enterprise-server.com/api/v3/"
|
||||||
if [[ "${{steps.base-url-env.outputs.result}}" != "$expected" ]]; then
|
actual="${{steps.base-url-env.outputs.result}}"
|
||||||
echo $'::error::\u274C' "Expected base-url to equal '$expected', got ${{steps.base-url-env.outputs.result}}"
|
if [[ "$expected" != "$actual" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "- Validating GraphQL URL with base-url not set respects GITHUB_API_URL"
|
||||||
|
expected="https://my.github-enterprise-server.com/api/v3/graphql"
|
||||||
|
actual="${{steps.base-url-env-graphql.outputs.result}}"
|
||||||
|
if [[ "$expected" != "$actual" ]]; then
|
||||||
|
echo $'::error::\u274C' "Expected base-url to equal '$expected', got $actual"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue