feat: add support for custom context to task-context#971
Draft
bhearsum wants to merge 1 commit into
Draft
Conversation
c8775ec to
7053a0c
Compare
This is somewhat of a continuation to taskcluster#968 in that it would allow for more `resolve_keyed_by` calls to be replaced by `task-context`. As a concrete example, we use [`by-release-level` in many places in gecko](https://searchfox.org/firefox-main/search?q=by-release-level&path=&case=false®exp=false). Its value is [derived from parameters and some constants](https://searchfox.org/firefox-main/source/taskcluster/gecko_taskgraph/util/attributes.py#157). With this patch, we could register it as custom context and replace a whole bunch of `resolve_keyed_by` calls in transforms, eg: In some python code that's called at taskgraph registration: ``` @custom_context("release-level") def release_level_context(config, task): """Provide ``release-level`` ("production" or "staging"), derived from parameters, so ``by-release-level`` fields can be resolved declaratively.""" return {"release-level": release_level(config.params)} ``` And in various kinds we'd end up with things like: ``` transforms: - taskgraph.transforms.task_context task-defaults: task-context: from-custom: - release-level substitution-fields: - scopes scopes: by-release-level: production: - project:releng:ship-it:server:production - project:releng:ship-it:action:create-new-release staging: - project:releng:ship-it:server:staging - project:releng:ship-it:action:create-new-release ```
7053a0c to
49c1e8e
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is somewhat of a continuation to #968 in that it would allow for more
resolve_keyed_bycalls to be replaced bytask-context. As a concrete example, we useby-release-levelin many places in gecko. Its value is derived from parameters and some constants. With this patch, we could register it as custom context and replace a whole bunch ofresolve_keyed_bycalls in transforms, eg:In some python code that's called at taskgraph registration:
And in various kinds we'd end up with things like: