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

Convert Windows builders to use DynamicServoFactory #426

Merged
merged 3 commits into from Jul 6, 2016

Conversation

@UK992
Copy link
Contributor

UK992 commented Jul 5, 2016

I'm not sure if this is the right approaches, but i try.

For process kill i used powershell kill, which works from bash and cmd, but needs admin privileges like any other process kill command.


This change is Reviewable

@aneeshusa
Copy link
Member

aneeshusa commented Jul 5, 2016

Thanks for tackling this!

@@ -31,6 +31,7 @@ def __add__(self, other):

build_windows = build_common + Environment({
'CARGO_HOME': '/home/Administrator/.cargo',
'HOME': r'C:\buildbot\slave\windows\build',

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

This seems like an odd choice of $HOME. Why do we need to set it, and why this value?

This comment has been minimized.

@UK992

UK992 Jul 5, 2016

Author Contributor

this set home directory before bash login, so it not needed to add cd command before every command.

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

That's a reasonable hack, but please leave a comment with that explanation for future reference.

@@ -76,3 +76,12 @@ arm64:
- ./mach build --rel --target=aarch64-unknown-linux-gnu
- bash ./etc/ci/lockfile_changed.sh
- bash ./etc/ci/manifest_changed.sh

windows:
- ./mach build -d -v

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

Let's do ./mach build --dev for consistency. Also, please rename to windows-dev as well.

This comment has been minimized.

@UK992

UK992 Jul 5, 2016

Author Contributor

done

step_kwargs['command'] = command

# Add bash -l before every command on Windows builders
bash_args = ["bash", "-l"] if is_windows() else []

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

We had ["bash", "-l", "-c"] earlier - missed the "-c".

This comment has been minimized.

@UK992

UK992 Jul 5, 2016

Author Contributor

i leave -c, to avoid quoting every command, i've tested with appveyor and it work that way too.

@@ -216,6 +235,10 @@ def __init__(self, builder_name, environment):
])


def is_windows():
return platform.system() == "Windows"

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

This doesn't work because this code runs on the Buildbot master (Linux). We need to somehow interrogate the builder properties and use that throughout the build. I don't know exactly how to do that.

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

FYI, this is the hard part.

This comment has been minimized.

@UK992

UK992 Jul 5, 2016

Author Contributor

with new approaches not detect windows builder based on builder name

if is_windows():
pkill_command = ["powershell", "kill", "-n", "servo"]
else:
pkill_command = ["pkill", "-x", "servo"]

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

Would be nice to factor this out into a little helper function:

def make_pkill_command(target):
   ...

make_pkill_command("servo")

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

Another option is a script in etc/ci, which neatly steps around the "how to detect Windows" problem.

if is_windows():
step_env = copy.deepcopy(envs.upload_nightly_windows)
else:
step_env = copy.deepcopy(envs.upload_nightly)

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

We should just do step_env += envs.upload_nightly and get rid of envs.upload_nightly_windows - would have mentioned this on the earlier PR if it wasn't right before release :)

@@ -1,6 +1,7 @@
import copy
import os.path
import re
import platform

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

No longer needed.

This comment has been minimized.

@UK992

UK992 Jul 5, 2016

Author Contributor

removed.

@@ -58,31 +59,37 @@ class DynamicServoFactory(ServoFactory):

def __init__(self, builder_name, environment):
self.environment = environment
is_windows = True if re.match('windows(.*)', builder_name) else False

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

I think this would make sense as a field on self.

This comment has been minimized.

@UK992

UK992 Jul 5, 2016

Author Contributor

done!

@@ -215,6 +228,12 @@ def __init__(self, builder_name, environment):
"etc/ci/buildbot_steps.yml")
])

def make_pkill_command(target, is_windows):

This comment has been minimized.

@aneeshusa

aneeshusa Jul 5, 2016

Member

Similarly, I think this makes sense as a class method - please mind the duplication for now :)

This comment has been minimized.

@UK992

UK992 Jul 5, 2016

Author Contributor

i don't quite understand, should i add this function to classes DynamicServoYAMLFactory and DynamicServoFactory?

EDIT: i added function to both classes, but i think this is not what you mean. I can restore back to previous state, if needed.

@aneeshusa
Copy link
Member

aneeshusa commented Jul 5, 2016

I will finish reviewing this either later today or tomorrow.

@UK992 UK992 force-pushed the UK992:win-builders branch 4 times, most recently from c553573 to c2080f9 Jul 5, 2016
@@ -58,31 +58,38 @@ class DynamicServoFactory(ServoFactory):

def __init__(self, builder_name, environment):
self.environment = environment
self.is_windows = True if re.match('windows(.*)',

This comment has been minimized.

@aneeshusa

aneeshusa Jul 6, 2016

Member

We can do self.is_windows = re.match(...) is not None directly instead. Also, no need for the parentheses around the .*.

This comment has been minimized.

@UK992

UK992 Jul 6, 2016

Author Contributor

done


# util.BuildFactory is an old-style class so we cannot use super()
# but must hardcode the superclass here
ServoFactory.__init__(self, pkill_step + dynamic_steps)

def make_step(self, command):
def make_step(self, command, is_windows):

This comment has been minimized.

@aneeshusa

aneeshusa Jul 6, 2016

Member

We can just read from self.is_windows instead of using an extra argument.

This comment has been minimized.

@UK992

UK992 Jul 6, 2016

Author Contributor

done


step_kwargs['env'] = step_env
return step_class(**step_kwargs)

def make_pkill_command(self, target, is_windows):

This comment has been minimized.

@aneeshusa

aneeshusa Jul 6, 2016

Member

Use self.is_windows here too.

This comment has been minimized.

@UK992

UK992 Jul 6, 2016

Author Contributor

done

try:
config_dir = os.path.dirname(os.path.realpath(__file__))
yaml_path = os.path.join(config_dir, 'steps.yml')
with open(yaml_path) as steps_file:
builder_steps = yaml.safe_load(steps_file)
commands = builder_steps[builder_name]
dynamic_steps = [self.make_step(command) for command in commands]
dynamic_steps = [self.make_step(command, self.is_windows)

This comment has been minimized.

@aneeshusa

aneeshusa Jul 6, 2016

Member

No need to pass self.is_windows to make_step().

This comment has been minimized.

@UK992

UK992 Jul 6, 2016

Author Contributor

done!

decodeRC={0: SUCCESS, 1: SUCCESS})]
pkill_step = [steps.ShellCommand(
command=self.make_pkill_command("servo"),
decodeRC={0: SUCCESS, 1: SUCCESS}

This comment has been minimized.

@aneeshusa

aneeshusa Jul 6, 2016

Member

Does this decodeRC apply for the powershell command as well? I think it would be better if the make_pkill_command function returned a steps.ShellCommand directly instead of just the command array.

This comment has been minimized.

@UK992

UK992 Jul 6, 2016

Author Contributor

yes it does, if powershell kill doesnt find process, exit with code 1

This comment has been minimized.

@UK992

UK992 Jul 6, 2016

Author Contributor

also done

try:
config_dir = os.path.dirname(os.path.realpath(__file__))
yaml_path = os.path.join(config_dir, 'steps.yml')
with open(yaml_path) as steps_file:
builder_steps = yaml.safe_load(steps_file)
commands = builder_steps[builder_name]
dynamic_steps = [self.make_step(command) for command in commands]
dynamic_steps = [self.make_step(command)
for command in commands]

This comment has been minimized.

@aneeshusa

aneeshusa Jul 6, 2016

Member

Put this back on one line as it was before.

This comment has been minimized.

@UK992

UK992 Jul 6, 2016

Author Contributor

done


step_kwargs['env'] = step_env
return step_class(**step_kwargs)

def make_pkill_command(self, target):

This comment has been minimized.

@aneeshusa

aneeshusa Jul 6, 2016

Member

Let's rename to make_pkill_step since it returns a Step.

This comment has been minimized.

@UK992

UK992 Jul 6, 2016

Author Contributor

done

@aneeshusa
Copy link
Member

aneeshusa commented Jul 6, 2016

LGTM to me after squash. Nice thinking with using a regex on the builder name to determine is_windows - I thought we were going to have to use complicated Buildbot properties or something.

@UK992 UK992 force-pushed the UK992:win-builders branch from 038c382 to af95e4e Jul 6, 2016
@UK992
Copy link
Contributor Author

UK992 commented Jul 6, 2016

Squashed!

@aneeshusa
Copy link
Member

aneeshusa commented Jul 6, 2016

@bors-servo r+
Thanks for handling not one but two TODOs!

@bors-servo
Copy link
Contributor

bors-servo commented Jul 6, 2016

📌 Commit af95e4e has been approved by aneeshusa

@bors-servo
Copy link
Contributor

bors-servo commented Jul 6, 2016

Testing commit af95e4e with merge d13f42f...

bors-servo added a commit that referenced this pull request Jul 6, 2016
Convert Windows builders to use DynamicServoFactory

I'm not sure if this is the right approaches, but i try.

For process kill i used ```powershell kill```, which works from bash and cmd, but needs admin privileges like any other process kill command.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/saltfs/426)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Jul 6, 2016

☀️ Test successful - travis

@bors-servo bors-servo merged commit af95e4e into servo:master Jul 6, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.