Fix check-requirements

Fix check-requirements: The assumptions with remote branch are not valid
anymore with Zuul v3, the change is on the proposed branch, check against
HEAD^1 instead.

Use the command module instead of script to get stdout in the
job-output.txt.gz file. Zuul v3 currently will not record the output from script
module in that file, only when command is used.

Note that the script module copied the file to the remote system - the
system where the tests are run - while command does not do this. But
the command is already on the remote system, use correct path for it.

Co-Authored-By: James E. Blair <corvus@inaugust.com>
Change-Id: Ib44332b4daf63b9d3fca6eadf0b4825614ca4aeb
This commit is contained in:
Andreas Jaeger 2017-10-30 09:15:06 +01:00 committed by Tony Breeds
parent 0b56f589a8
commit 58cac05a76
2 changed files with 7 additions and 4 deletions

View File

@ -170,7 +170,6 @@ def main():
cwd = os.getcwd()
# build a list of requirements in the proposed change,
# and check them for style violations while doing so
head = run_command("git rev-parse HEAD")[0]
head_proj = project.read(cwd)
head_reqs = RequirementsList('HEAD', head_proj)
# Don't apply strict parsing rules to stable branches.
@ -187,11 +186,11 @@ def main():
if not args.local:
# build a list of requirements already in the target branch,
# so that we can create a diff and identify what's being changed
run_command("git checkout %s" % branch)
run_command("git checkout HEAD^1")
branch_proj = project.read(cwd)
# switch back to the proposed change now
run_command("git checkout %s" % head)
run_command("git checkout %s" % branch)
else:
branch_proj = {'root': cwd}
branch_reqs = RequirementsList(branch, branch_proj)

View File

@ -1,4 +1,8 @@
- hosts: all
tasks:
- name: Run requirements check script
script: "files/project-requirements-change.py {{ zuul.project.src_dir }} {{ zuul.branch }}"
# Use command module here instead of script since Zuul gets output
# with command into job-output.txt file.
# Command expects the file to be at the remote system - the system
# running the tests. Ask zuul variables for the path.
command: "{{ zuul._projects['git.openstack.org/openstack/requirements'].src_dir }}/playbooks/files/project-requirements-change.py {{ zuul.project.src_dir }} {{ zuul.branch }}"