Skip to content

Commit

Permalink
Added a yapf file and formated the scripts and pytest code (#2675)
Browse files Browse the repository at this point in the history
Summary:
Currently there was no formater in the scripts folder. I have added the yapf
configuration file and formated the python folders.

YAPF is a code formatter mainainted and developed at Google:
https://github.com/google/yapf
and I've set it up to use the codeformat they use there, but open to other options.

Test Plan:
```
yapf -i scripts/*.py
git status
```
  • Loading branch information
chefsale authored May 19, 2020
1 parent 10f3785 commit 4d0282d
Show file tree
Hide file tree
Showing 73 changed files with 2,250 additions and 1,095 deletions.
4 changes: 4 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[style]
based_on_style = google
indent_width = 4
column_limit = 80
20 changes: 13 additions & 7 deletions pytest/lib/branches.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

import os
import subprocess


def current_branch():
return os.environ.get('BUILDKITE_BRANCH') or subprocess.check_output([
"git", "rev-parse", "--symbolic-full-name", "--abbrev-ref", "HEAD"]).strip().decode()
"git", "rev-parse", "--symbolic-full-name", "--abbrev-ref", "HEAD"
]).strip().decode()


def compile_binary(branch):
Expand Down Expand Up @@ -46,19 +46,25 @@ def compile_current():

def download_binary(branch):
url = f'https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore/Linux/{branch}/near'
subprocess.check_output(['curl', '--proto', '=https', '--tlsv1.2',
'-sSfL', url, '-o', f'../target/debug/near-{branch}'])
subprocess.check_output([
'curl', '--proto', '=https', '--tlsv1.2', '-sSfL', url, '-o',
f'../target/debug/near-{branch}'
])
subprocess.check_output(['chmod', '+x', f'../target/debug/near-{branch}'])
url = f'https://s3-us-west-1.amazonaws.com/build.nearprotocol.com/nearcore/Linux/{branch}/state-viewer'
subprocess.check_output(['curl', '--proto', '=https', '--tlsv1.2',
'-sSfL', url, '-o', f'../target/debug/state-viewer-{branch}'])
subprocess.check_output([
'curl', '--proto', '=https', '--tlsv1.2', '-sSfL', url, '-o',
f'../target/debug/state-viewer-{branch}'
])
subprocess.check_output(
['chmod', '+x', f'../target/debug/state-viewer-{branch}'])


def prepare_ab_test(other_branch):
compile_current()
if os.environ.get('BUILDKITE') and other_branch in ['master', 'beta', 'stable']:
if os.environ.get('BUILDKITE') and other_branch in [
'master', 'beta', 'stable'
]:
download_binary(other_branch)
else:
compile_binary(other_branch)
Expand Down
Loading

0 comments on commit 4d0282d

Please sign in to comment.