Skip to content

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

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

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 2 times, most recently from 7053a0c to 49c1e8e Compare June 3, 2026 13:01
@bhearsum bhearsum marked this pull request as ready for review June 4, 2026 15:03
@bhearsum bhearsum requested a review from a team as a code owner June 4, 2026 15:03
@bhearsum bhearsum requested a review from abhishekmadan30 June 4, 2026 15:03
Copy link
Copy Markdown
Contributor

@jcristau jcristau left a comment

Choose a reason for hiding this comment

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

Consider adding to task_context transform docs?

@bhearsum
Copy link
Copy Markdown
Contributor Author

bhearsum commented Jun 4, 2026

Consider adding to task_context transform docs?

er, yes! I meant to do that before moving it out of draft.

@bhearsum bhearsum force-pushed the feat-add-support-for-custom-co branch from 49c1e8e to c9e0ad3 Compare June 4, 2026 16:56
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 c9e0ad3 to d580540 Compare June 4, 2026 16:56
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.

2 participants