forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use S3 Sync for CI deploys to avoid recopying files (pantsbuild#7895)
We currently copy all of `dist/deploy` into S3, even if the file is an exact copy of something already in S3. This poses a real cost, both monetary and time. Instead, here we use `aws s3 sync` to only transfer files that are different from what is currently in the bucket. Will close pantsbuild#7258.
- Loading branch information
1 parent
5405ebf
commit fee10f2
Showing
6 changed files
with
81 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2019 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
import os | ||
import shutil | ||
import subprocess | ||
|
||
from common import die | ||
|
||
|
||
def main() -> None: | ||
if shutil.which("aws") is None: | ||
install_aws_cli() | ||
check_authentication_setup() | ||
deploy() | ||
|
||
|
||
def install_aws_cli() -> None: | ||
subprocess.run(["./build-support/bin/install_aws_cli_for_ci.sh"], check=True) | ||
|
||
|
||
def check_authentication_setup() -> None: | ||
access_key_id = "AWS_ACCESS_KEY_ID" | ||
secret_access_key = "AWS_SECRET_ACCESS_KEY" | ||
if access_key_id not in os.environ or secret_access_key not in os.environ: | ||
die(f"Caller of the script must set both {access_key_id} and {secret_access_key}.") | ||
|
||
|
||
def deploy() -> None: | ||
# NB: we use the sync command to avoid transferring files that have not changed. See | ||
# https://github.com/pantsbuild/pants/issues/7258. | ||
subprocess.run([ | ||
"aws", | ||
"s3", | ||
"sync", | ||
# This instructs the sync command to ignore timestamps, which we must do to allow distinct | ||
# shards—which may finish building their wheels at different times—to not overwrite | ||
# otherwise-identical wheels. | ||
"--size-only", | ||
"--acl", | ||
"public-read", | ||
"dist/deploy", | ||
"s3://binaries.pantsbuild.org" | ||
], check=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters