Skip to content

Instantly share code, notes, and snippets.

@jlisee
Created February 20, 2020 01:17
Show Gist options
  • Save jlisee/7e43a33c4e7a362d5852f20e148b9e27 to your computer and use it in GitHub Desktop.
Save jlisee/7e43a33c4e7a362d5852f20e148b9e27 to your computer and use it in GitHub Desktop.
build_both_flows.py
from atg.buildkite.cli import BuildkiteCli
from atg.buildkite.environment import is_buildkite_build
from atg.devex.ci import execution_environment
from atg.devex.ci.buildkite.log import print_separator
from atg.devex.ci.changedtargets import (
JSON_TARGET_FILENAME,
BAZEL_PROTOBUF_FILENAME,
changed_targets_report,
determine_changed_targets,
dump_all_targets,
)
def builditall():
pass
def main():
# Paths where to store things
# Determine where to run
print_separator("Determine git commit range")
commit_range = execution_environment.commit_range()
print(commit_range.description())
# Compute the targets
if builditall():
print_separator("#buildkitall detected - getting all targets")
dump_all_targets(target_output=JSON_TARGET_FILENAME,
bazel_protobuf=BAZEL_PROTOBUF_FILENAME)
else:
determine_changed_targets(target_output=JSON_TARGET_FILENAME,
bazel_protobuf=BAZEL_PROTOBUF_FILENAME)
# Print report on file
print_separator("All changed targets")
print(changed_targets_report(JSON_TARGET_FILENAME))
# Upload the result files
if is_buildkite_build():
print_separator("Uploading targets and data")
BuildkiteCli.upload_artifact(JSON_TARGET_FILENAME)
BuildkiteCli.upload_artifact(BAZEL_PROTOBUF_FILENAME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment