Synchronize test-prepare-workspace-git to prepare-workspace-git
Change-Id: I9763ac89097f8580fa2abf14e759fe088cc9a609
This commit is contained in:
parent
d6ae964f47
commit
7dfb7d0eeb
@ -33,19 +33,20 @@ except ImportError:
|
|||||||
|
|
||||||
def prep_one_project(args, project, output):
|
def prep_one_project(args, project, output):
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
dest = f"{args['zuul_workspace_root']}/{project['src_dir']}"
|
dest = "%s/%s" % (args['zuul_workspace_root'], project['src_dir'])
|
||||||
output['dest'] = dest
|
output['dest'] = dest
|
||||||
if not os.path.isdir(dest):
|
if not os.path.isdir(dest):
|
||||||
cache = f"{args['cached_repos_root']}/{project['canonical_name']}"
|
cache = "%s/%s" % (args['cached_repos_root'],
|
||||||
|
project['canonical_name'])
|
||||||
if os.path.isdir(cache):
|
if os.path.isdir(cache):
|
||||||
# We do a bare clone here first so that we skip creating a working
|
# We do a bare clone here first so that we skip creating a working
|
||||||
# copy that will be overwritten later anyway.
|
# copy that will be overwritten later anyway.
|
||||||
output['initial_state'] = 'cloned-from-cache'
|
output['initial_state'] = 'cloned-from-cache'
|
||||||
out = run(f"git clone --bare {cache} {dest}/.git")
|
out = run("git clone --bare %s %s/.git" % (cache, dest))
|
||||||
output['clone'] = out.stdout.decode('utf8').strip()
|
output['clone'] = out.stdout.decode('utf8').strip()
|
||||||
else:
|
else:
|
||||||
output['initial_state'] = 'git-init'
|
output['initial_state'] = 'git-init'
|
||||||
out = run(f"git init {dest}")
|
out = run("git init %s" % (dest,))
|
||||||
output['init'] = out.stdout.decode('utf8').strip()
|
output['init'] = out.stdout.decode('utf8').strip()
|
||||||
else:
|
else:
|
||||||
output['initial_state'] = 'pre-existing'
|
output['initial_state'] = 'pre-existing'
|
||||||
|
@ -33,27 +33,28 @@ except ImportError:
|
|||||||
|
|
||||||
def get_ssh_dest(args, dest):
|
def get_ssh_dest(args, dest):
|
||||||
return (
|
return (
|
||||||
f"git+ssh://{args['ansible_user']}"
|
"git+ssh://%s@%s:%s/%s" % (
|
||||||
f"@{args['ansible_host']}"
|
args['ansible_user'],
|
||||||
f":{args['ansible_port']}"
|
args['ansible_host'],
|
||||||
f"/{dest}"
|
args['ansible_port'],
|
||||||
|
dest)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_k8s_dest(args, dest):
|
def get_k8s_dest(args, dest):
|
||||||
resources = args['zuul_resources'][args['inventory_hostname']]
|
resources = args['zuul_resources'][args['inventory_hostname']]
|
||||||
return (
|
return (
|
||||||
f"\"ext::kubectl "
|
"\"ext::kubectl --context %s -n %s exec -i %s -- %%S %s\"" % (
|
||||||
f"--context {resources['context']} "
|
resources['context'],
|
||||||
f"-n {resources['namespace']} "
|
resources['namespace'],
|
||||||
f"exec -i {resources['pod']} "
|
resources['pod'],
|
||||||
f"-- %S {dest}\""
|
dest)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def sync_one_project(args, project, output):
|
def sync_one_project(args, project, output):
|
||||||
cwd = f"{args['executor_work_root']}/{project['src_dir']}"
|
cwd = "%s/%s" % (args['executor_work_root'], project['src_dir'])
|
||||||
dest = f"{args['zuul_workspace_root']}/{project['src_dir']}"
|
dest = "%s/%s" % (args['zuul_workspace_root'], project['src_dir'])
|
||||||
output['src'] = cwd
|
output['src'] = cwd
|
||||||
output['dest'] = dest
|
output['dest'] = dest
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
@ -70,7 +71,7 @@ def sync_one_project(args, project, output):
|
|||||||
git_dest = get_k8s_dest(args, dest)
|
git_dest = get_k8s_dest(args, dest)
|
||||||
else:
|
else:
|
||||||
git_dest = get_ssh_dest(args, dest)
|
git_dest = get_ssh_dest(args, dest)
|
||||||
out = run(f"git push --quiet --mirror {git_dest}",
|
out = run("git push --quiet --mirror %s" % (git_dest,),
|
||||||
cwd=cwd, env=env)
|
cwd=cwd, env=env)
|
||||||
output['push'] = out.stdout.decode('utf8').strip()
|
output['push'] = out.stdout.decode('utf8').strip()
|
||||||
break
|
break
|
||||||
|
@ -31,7 +31,7 @@ except ImportError:
|
|||||||
|
|
||||||
|
|
||||||
def update_one_project(args, project, output):
|
def update_one_project(args, project, output):
|
||||||
cwd = f"{args['zuul_workspace_root']}/{project['src_dir']}"
|
cwd = "%s/%s" % (args['zuul_workspace_root'], project['src_dir'])
|
||||||
output['dest'] = cwd
|
output['dest'] = cwd
|
||||||
|
|
||||||
start = time.monotonic()
|
start = time.monotonic()
|
||||||
@ -43,7 +43,7 @@ def update_one_project(args, project, output):
|
|||||||
run("git config --local --unset receive.denyCurrentBranch", cwd=cwd)
|
run("git config --local --unset receive.denyCurrentBranch", cwd=cwd)
|
||||||
run("git config --local --unset receive.denyDeleteCurrent", cwd=cwd)
|
run("git config --local --unset receive.denyDeleteCurrent", cwd=cwd)
|
||||||
# checkout the branch matching the branch set up by the executor
|
# checkout the branch matching the branch set up by the executor
|
||||||
out = run(f"git checkout --quiet {project['checkout']}", cwd=cwd)
|
out = run("git checkout --quiet %s" % (project['checkout'],), cwd=cwd)
|
||||||
output['checkout'] = out.stdout.decode('utf8').strip()
|
output['checkout'] = out.stdout.decode('utf8').strip()
|
||||||
# put out a status line with the current HEAD
|
# put out a status line with the current HEAD
|
||||||
out = run("git log --pretty=oneline -1", cwd=cwd)
|
out = run("git log --pretty=oneline -1", cwd=cwd)
|
||||||
|
@ -44,7 +44,7 @@ class TestPrepareWorkspace(testtools.TestCase):
|
|||||||
run("git commit -a -m init", cwd=project_root)
|
run("git commit -a -m init", cwd=project_root)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if hasattr(e, 'output'):
|
if hasattr(e, 'output'):
|
||||||
msg = f'{str(e)} : {e.output}'
|
msg = '%s : %s' % (str(e), e.output)
|
||||||
else:
|
else:
|
||||||
msg = str(e)
|
msg = str(e)
|
||||||
print(msg)
|
print(msg)
|
||||||
@ -139,7 +139,7 @@ class TestPrepareWorkspace(testtools.TestCase):
|
|||||||
self.assertEqual(dest, project_output['dest'])
|
self.assertEqual(dest, project_output['dest'])
|
||||||
head = run("git rev-parse HEAD", cwd=dest,
|
head = run("git rev-parse HEAD", cwd=dest,
|
||||||
).stdout.decode('utf8').strip()
|
).stdout.decode('utf8').strip()
|
||||||
self.assertEqual(f'{head} init', project_output['HEAD'])
|
self.assertEqual('%s init' % (head,), project_output['HEAD'])
|
||||||
self.assertTrue(project_output['elapsed'] > 0)
|
self.assertTrue(project_output['elapsed'] > 0)
|
||||||
|
|
||||||
def test_prepare_workspace_ssh_new(self):
|
def test_prepare_workspace_ssh_new(self):
|
||||||
|
@ -45,7 +45,7 @@ def for_each_project(func, args, output):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = str(e)
|
msg = str(e)
|
||||||
if hasattr(e, 'output'):
|
if hasattr(e, 'output'):
|
||||||
msg = f'{str(e)} : {e.output}'
|
msg = '%s : %s' % (str(e), e.output)
|
||||||
else:
|
else:
|
||||||
msg = str(e)
|
msg = str(e)
|
||||||
project_out['error'] = msg
|
project_out['error'] = msg
|
||||||
|
@ -193,6 +193,19 @@
|
|||||||
- name: ubuntu-noble
|
- name: ubuntu-noble
|
||||||
label: ubuntu-noble
|
label: ubuntu-noble
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: zuul-jobs-test-base-roles-ubuntu-xenial
|
||||||
|
description: Tests roles in the 'base' job on ubuntu-xenial
|
||||||
|
parent: zuul-jobs-test-base-roles
|
||||||
|
# Note this is manually curated since xenial is not really
|
||||||
|
# supported on opendev, but we want the job to run until the last
|
||||||
|
# possible moment.
|
||||||
|
ansible-version: '8'
|
||||||
|
nodeset:
|
||||||
|
nodes:
|
||||||
|
- name: ubuntu-xenial
|
||||||
|
label: ubuntu-xenial
|
||||||
|
|
||||||
- job:
|
- job:
|
||||||
name: zuul-jobs-test-base-test-roles
|
name: zuul-jobs-test-base-test-roles
|
||||||
description: |
|
description: |
|
||||||
@ -846,6 +859,7 @@
|
|||||||
- zuul-jobs-test-base-roles-ubuntu-focal
|
- zuul-jobs-test-base-roles-ubuntu-focal
|
||||||
- zuul-jobs-test-base-roles-ubuntu-jammy
|
- zuul-jobs-test-base-roles-ubuntu-jammy
|
||||||
- zuul-jobs-test-base-roles-ubuntu-noble
|
- zuul-jobs-test-base-roles-ubuntu-noble
|
||||||
|
- zuul-jobs-test-base-roles-ubuntu-xenial
|
||||||
- zuul-jobs-test-base-test-roles-centos-9-stream
|
- zuul-jobs-test-base-test-roles-centos-9-stream
|
||||||
- zuul-jobs-test-base-test-roles-debian-bookworm
|
- zuul-jobs-test-base-test-roles-debian-bookworm
|
||||||
- zuul-jobs-test-base-test-roles-debian-bullseye
|
- zuul-jobs-test-base-test-roles-debian-bullseye
|
||||||
|
Loading…
x
Reference in New Issue
Block a user