Merge pull request #13037 from cli/kw/acceptance-test-git-config
Fix acceptance test failures: git identity, headRepository JSON, obsolete traversal test
This commit is contained in:
commit
39407e65e3
12 changed files with 25 additions and 81 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
|
@ -15,6 +16,7 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/internal/ghcmd"
|
||||
"github.com/cli/go-internal/testscript"
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
)
|
||||
|
||||
func ghMain() int {
|
||||
|
|
@ -224,6 +226,19 @@ func sharedSetup(tsEnv testScriptEnv) func(ts *testscript.Env) error {
|
|||
|
||||
ts.Setenv("RANDOM_STRING", randomString(10))
|
||||
|
||||
// The sandbox overrides HOME, so git cannot find the user's global
|
||||
// config. Write a minimal identity so commits inside the sandbox
|
||||
// don't fail with "Author identity unknown".
|
||||
gitCfg := filepath.Join(ts.Cd, ".gitconfig")
|
||||
gitCfgContent := heredoc.Doc(`
|
||||
[user]
|
||||
name = GitHub CLI Acceptance Test Runner
|
||||
email = cli-acceptance-test-runner@github.com
|
||||
`)
|
||||
if err := os.WriteFile(gitCfg, []byte(gitCfgContent), 0o644); err != nil {
|
||||
return fmt.Errorf("writing sandbox .gitconfig: %w", err)
|
||||
}
|
||||
|
||||
ts.Values[keyT] = ts.T()
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Check the PR is indeed created
|
||||
exec gh pr view ${USER}:feature/branch --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature/branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true}
|
||||
stdout {"baseRefName":"main","headRefName":"feature/branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}","nameWithOwner":"${USER}/${FORK}"},"isCrossRepository":true}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Check the PR is indeed created
|
||||
exec gh pr view ${USER}:feature-branch --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true}
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}","nameWithOwner":"${USER}/${FORK}"},"isCrossRepository":true}
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Assert that the PR was created with the correct head repository and refs
|
||||
exec gh pr view --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true}
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}","nameWithOwner":"${USER}/${FORK}"},"isCrossRepository":true}
|
||||
|
|
|
|||
|
|
@ -43,4 +43,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Assert that the PR was created with the correct head repository and refs
|
||||
exec gh pr view --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature/branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true}
|
||||
stdout {"baseRefName":"main","headRefName":"feature/branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}","nameWithOwner":"${USER}/${FORK}"},"isCrossRepository":true}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Assert that the PR was created with the correct head repository and refs
|
||||
exec gh pr view --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true}
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}","nameWithOwner":"${USER}/${FORK}"},"isCrossRepository":true}
|
||||
|
|
|
|||
|
|
@ -50,4 +50,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Assert that the PR was created with the correct head repository and refs
|
||||
exec gh pr view --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true}
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}","nameWithOwner":"${USER}/${FORK}"},"isCrossRepository":true}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Assert that the PR was created with the correct head repository and refs
|
||||
exec gh pr view --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true}
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}","nameWithOwner":"${USER}/${FORK}"},"isCrossRepository":true}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Assert that the PR was created with the correct head repository and refs
|
||||
exec gh pr view --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${REPO_ID}","name":"${REPO}"},"isCrossRepository":false}
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${REPO_ID}","name":"${REPO}","nameWithOwner":"${ORG}/${REPO}"},"isCrossRepository":false}
|
||||
|
|
|
|||
|
|
@ -44,4 +44,4 @@ stdout https://${GH_HOST}/${ORG}/${REPO}/pull/1
|
|||
|
||||
# Assert that the PR was created with the correct head repository and refs
|
||||
exec gh pr view ${USER}:feature-branch --json headRefName,headRepository,baseRefName,isCrossRepository
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}"},"isCrossRepository":true}
|
||||
stdout {"baseRefName":"main","headRefName":"feature-branch","headRepository":{"id":"${FORK_ID}","name":"${FORK}","nameWithOwner":"${USER}/${FORK}"},"isCrossRepository":true}
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
# Set up env
|
||||
env REPO=${SCRIPT_NAME}-${RANDOM_STRING}
|
||||
|
||||
# Use gh as a credential helper
|
||||
exec gh auth setup-git
|
||||
|
||||
# Create a repository with a file so it has a default branch
|
||||
exec gh repo create ${ORG}/${REPO} --add-readme --private
|
||||
|
||||
# Defer repo cleanup
|
||||
defer gh repo delete --yes ${ORG}/${REPO}
|
||||
|
||||
# Clone the repo
|
||||
exec gh repo clone ${ORG}/${REPO}
|
||||
|
||||
# commit the workflow file
|
||||
cd ${REPO}
|
||||
mkdir .github/workflows
|
||||
mv ../workflow.yml .github/workflows/workflow.yml
|
||||
exec git add .github/workflows/workflow.yml
|
||||
exec git commit -m 'Create workflow file'
|
||||
exec git push -u origin main
|
||||
|
||||
# Sleep because it takes a second for the workflow to register
|
||||
sleep 1
|
||||
|
||||
# Check the workflow is indeed created
|
||||
exec gh workflow list
|
||||
stdout 'Test Workflow Name'
|
||||
|
||||
# Run the workflow
|
||||
exec gh workflow run 'Test Workflow Name'
|
||||
|
||||
# It takes some time for a workflow run to register
|
||||
sleep 10
|
||||
|
||||
# Get the run ID we want to watch
|
||||
exec gh run list --json databaseId --jq '.[0].databaseId'
|
||||
stdout2env RUN_ID
|
||||
|
||||
# Wait for workflow to complete
|
||||
exec gh run watch ${RUN_ID} --exit-status
|
||||
|
||||
# Download the artifact and see there is an error
|
||||
! exec gh run download ${RUN_ID}
|
||||
stderr 'would result in path traversal'
|
||||
|
||||
-- workflow.yml --
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: Test Workflow Name
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
build:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
- run: echo hello > world.txt
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ..
|
||||
path: world.txt
|
||||
|
|
@ -387,7 +387,7 @@ func IssueGraphQL(fields []string) string {
|
|||
case "headRepositoryOwner":
|
||||
q = append(q, `headRepositoryOwner{id,login,...on User{name}}`)
|
||||
case "headRepository":
|
||||
q = append(q, `headRepository{id,name}`)
|
||||
q = append(q, `headRepository{id,name,nameWithOwner}`)
|
||||
case "assignees":
|
||||
q = append(q, `assignees(first:100){nodes{id,login,name,databaseId},totalCount}`)
|
||||
case "assignedActors":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue