Skip to content

feat: add support for custom context to task-context#971

Draft
bhearsum wants to merge 1 commit into
taskcluster:mainfrom
bhearsum:feat-add-support-for-custom-co
Draft

feat: add support for custom context to task-context#971
bhearsum wants to merge 1 commit into
taskcluster:mainfrom
bhearsum:feat-add-support-for-custom-co

Conversation

@bhearsum
Copy link
Copy Markdown
Contributor

@bhearsum bhearsum commented Jun 3, 2026

This is somewhat of a continuation to #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. Its value is derived from parameters and some constants. 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

@bhearsum bhearsum force-pushed the feat-add-support-for-custom-co branch from c8775ec to 7053a0c Compare June 3, 2026 13:00
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&regexp=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
```
@bhearsum bhearsum force-pushed the feat-add-support-for-custom-co branch from 7053a0c to 49c1e8e Compare June 3, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant