Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix presubmit jobs and periodic jobs #60

Merged
merged 2 commits into from
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion images/tf_operator/build_and_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
def GetGitHash():
# The image tag is based on the githash.
git_hash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
git_hash=git_hash.strip()
git_hash = git_hash.strip()
modified_files = subprocess.check_output(["git", "ls-files", "--modified"])
untracked_files = subprocess.check_output(
["git", "ls-files", "--others", "--exclude-standard"])
Expand Down
33 changes: 27 additions & 6 deletions test-infra/image/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
def run(command, cwd=None):
"""Run the command as a subprocess"""
logging.info("Running: %s", " ".join(command))
subprocess.check_call(command, cwd=cwd)
return subprocess.check_output(command, cwd=cwd).decode("utf-8")


def clone_repo():
Expand Down Expand Up @@ -70,15 +70,27 @@ def clone_repo():

# If this is a presubmit PULL_PULL_SHA will be set see:
# https://github.com/kubernetes/test-infra/tree/master/prow#job-evironment-variables
sha = os.getenv('PULL_PULL_SHA')

if not sha:
# For postsubmits PULL_BASE_SHA will be set.
sha = os.getenv('PULL_BASE_SHA')
sha = ""
pull_number = os.getenv("PULL_NUMBER", "")

if pull_number:
sha = os.getenv("PULL_PULL_SHA", "")
# Its a presubmit job sob since we are testing a Pull request.
run(["git", "fetch", "origin",
"pull/{0}/head:pr".format(pull_number)],
cwd=dest)
else:
# For postsubmits PULL_BASE_SHA will be set
sha = os.getenv("PULL_BASE_SHA", "")

if sha:
run(["git", "checkout", sha], cwd=dest)

# Get the actual git hash.
# This ensures even for periodic jobs which don't set the sha we know
# the version of the code tested.
sha = run(["git", "rev-parse", "HEAD"], cwd=dest)

# Install dependencies
run(["glide", "install"], cwd=dest)

Expand All @@ -101,6 +113,15 @@ def main():
else:
logging.warn("Could not find file: %s", version_file)

# Print environment variables.
# This is useful for debugging and understanding the information set by prow.
names = os.environ.keys()
names.sort()
logging.info("Environment Variables")
for n in names:
logging.info("%s=%s", n, os.environ[n])
logging.info("End Environment Variables")

src_dir, sha = clone_repo()

# Execute the runner.
Expand Down
11 changes: 1 addition & 10 deletions test-infra/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def upload_outputs(gcs_client, output_dir, test_dir):

if __name__ == "__main__":
logging.getLogger().setLevel(logging.INFO)

logging.info("Starting runner.py")
parser = argparse.ArgumentParser(
description="Run E2E tests for the TfJob CRD.")

Expand Down Expand Up @@ -406,15 +406,6 @@ def upload_outputs(gcs_client, output_dir, test_dir):
src_dir = args.src_dir
sha = args.sha

# Print environment variables.
# This is useful for debugging and understanding the information set by prow.
names = os.environ.keys()
names.sort()
logging.info("Environment Variables")
for n in names:
logging.info("%s=%s", n, os.environ[n])
logging.info("End Environment Variables")

test_dir = tempfile.mkdtemp(prefix="tmpTfCrdTest")
logging.info("test_dir: %s", test_dir)

Expand Down