Replies: 1 comment 1 reply
-
my 2 questions here:
Thanks |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Please tries to provide first class support for third party build rule authors. There's very little difference between the built in rules vs. rules written externally, however there's still some shortcomings. Most of this is around configuration. In this issue, I outline some of these shortcomings and suggest a formalised approach to third party rule repos called
plugins
. The long term plan for Please is to move all the bundled languages out of Please and into these plugins.Terminology
Host repo - The repo that is including the plugin
Subrepo - Please has the ability in embed another repo inside the host repo. This can be done through the
subrepo()
builtin. The other repo is usually a Please repo, however it can also be a non-Please repo in which case we provide some build rules to interact with it. In either case, the repo is added to the host repo's build graph and can be access through a special type of build label with the@subrepo_name//some:target
or///subrepo_name//some:target
syntax.Plugin repo - A type of subrepo that is intended to extend Please with some additional functionality e.g. to support another language. These typically more advanced than other subrepos as they often need to define configuration to be set from the host repo.
Plugin configuration
As it stands, rule authors are expected to set default values for their configuration in the build definitions:
These values can then be overridden in the host repo's
.plzconfig
:This approach is rather primitive and has some shortcomings when compared to the built in rules:
FOOC_TOOL
toFoocTool
which isn't possible with this approach.[BuildConfig]
for everything could potentially result in config key collisions between plugins but mostly just feels second class.I propose adding new config sections to define plugin's configuration. On the plugin side, plugins will be able to define a namespace for their configuration in their
.plzconfig
:We can then add fields that this plugin requires through a repeatable "PluginConfig" section:
The host repo can then specify values to these config values in their
.plzconfig
through a newPlugin
section:The host repo is then expected to include the plugin as a subrepo e.g. though the
github_repo()
rule:This plugin can then be used via
subinclude("@plugins/foo//build_defs:foo")
or similar.Validation
Typically, if extra config values are provided in a
.plzconfig
, Please will log warnings for these. This is because we need to parse older config files when querying changes between branches. This isn't the case for plugins as plugins can be updated in lock step with their.plzconfig
files. I propose that problems in config for plugins should be fatal i.e. we should log errors, and stop the build in the case of unrecognised or missing plugin config.The build rules can then perform additional validation to make sure the values for these config fields make sense. They can use
fail()
andwarning()
to report any problems to the user.Referring to the current subrepo
Another difficulty in subrepos is it can be hard to set default config values that work both from inside the plugin repo, and from the host repo. For example, say we have some sort of language auto-formatter
//tools:foo_fmt
defined inside out plugin repo. We might want to set this as a default value to avoid every consumer having to set this manually. To do this we need to know the subrepo name that the host repo has included us as. To solve this, I propose we implement@self
as a way to refer to the current subrepo name, or nothing in the case that we aren't inside a subrepo:Plugin and host repo config
Currently configuration values set in the plugin repo's
.plzconfig
are not respected when included from the host repo. This can be desirable, however it's usually not. For example, it doesn't make sense for the plugin to use the same go import path as the host repo, however we would want to use the same caching configuration.I propose that we should start off with the host repos configuration as a base as we do now. We should then parse the subrepo's
.plzconfig
, allowing it to override values like the go import path in their.plzconfig
. This will allow the plugin repo to override config values like the go import path while still using the other config from the host.Plugins might also have version requirements on Please. We should parse the plugins .plzconfig to check the
Please.Version
field. A miss matched Please version might work. For this reason, if the versions don't match up, we should log a warning but still try our best to complete the build.Test configuration
The last piece of the puzzle is when the plugin repo wants to set configuration values that are only useful when testing the plugin repo. These values shouldn't take effect when it's included as a subrepo. For example, a plugin may want to set up some SDK or toolchain so that it can run its tests without having to install the SDK on the CI server. We don't want to download this SDK again if the host repo already has one configured, so we should use the host repo's configuration over the plugins for the SDK.
Developers could work around this issue by having a
.plzconfig.ci
profile or similar. They could put the SDK or toolchain configuration in there, allowing them to separate this config from the main.plzconfig
. This isn't very user friendly as working in the plugin repo would require passing--proflie ci
to everyplz
invocation. To mediate this, we can codify this pattern in a.plzconfig_private
file. This file will essentially be the config that is private to the subrepo, as such, it will only be loaded byplz
when we're working directly in the plugin repo.A language agnostic build system
Going forward, I plan to move the languages in the Please repo out into plugins. If the plugin API is truly first class, then this is a good way to prove it. It will also allow us to make breaking changes to the rule definitions without waiting for a major release of Please. At this point, we can say that Please is a truly language agnostic build system.
Some consideration into a testing plan should be made to make sure that changes to Please don't break plugins (as is the case with pleasings quite often). I think most of the e2e tests should stay in the Please repo, to make sure that Please integrates with the tips of these plugins.
Beta Was this translation helpful? Give feedback.
All reactions