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

for_lane, for_platform blocks in configurations #7859

Merged
merged 4 commits into from
Jan 15, 2017

Conversation

mfurtak
Copy link
Contributor

@mfurtak mfurtak commented Jan 14, 2017

A continuation of work on #6549

This reconciles the new configuration blocks (for_lane, for_platform) and their desire to be able to override configuration values, with the existing rules about "first assignment wins" for configurations.

It does this by having the new configuration blocks create a fresh configuration context every time you enter one. This way, each block gets a fresh application of the "first assignment wins" rule. As each block exits, any values set during the block are merged with any configuration context that was present at the time the block started. Thus, we can override values in these blocks, but only once, and still build a single comprehensive configuration!

This is supported with new push_values! and pop_values! methods on Configuration

If we like the solution, we can always add documentation as a follow-up.

/cc @maschall

@mfurtak mfurtak requested a review from KrauseFx January 14, 2017 18:12
@mfurtak mfurtak changed the title For lane configuration push for_lane, for_platform blocks in configurations Jan 14, 2017
Copy link
Contributor

@asfalcone asfalcone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but definitely think @KrauseFx should review as well

# Setting this variable to be true allows a one-time overwrite of a particular
# configuration value. This is used by the override block methods to allow
# giving a more specific config value for a particular circumstance
@allow_overwite = false
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, this should be removed. Is leftover from my first try/approach 😦

# lane_name - Symbol representing a lane name.
# block - Block to execute to override configuration values.
#
# Discussion If received lane name does not match the lane name available as environment variable, no changes will
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the Discussion block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this was from the original PR. I can make the comments look more like our usual documentation. 👍

# configuration for applying values, so that values can be overridden
# (once) again. Those values are then merged into the surrounding
# configuration as the block completes
def with_a_clean_config_merged_when_complete
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great

@@ -119,6 +119,60 @@
end
end)
end

describe "for_lane and for_platform support" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, just new tests, without modifying any of the existing ones 👍

Copy link
Member

@KrauseFx KrauseFx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great @mfurtak 👍 I don't know for sure where we want to add this to the documentation, besides Advanced.md. Do you have a better idea?

@mfurtak mfurtak merged commit 3da9835 into master Jan 15, 2017
@mfurtak mfurtak deleted the for-lane-configuration-push branch January 15, 2017 20:39
@mfurtak
Copy link
Contributor Author

mfurtak commented Jan 16, 2017

@KrauseFx fastlane/docs#256

@asfalcone asfalcone mentioned this pull request Jan 17, 2017
@fastlane fastlane locked and limited conversation to collaborators Apr 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants