Skip to content

Add per-changeset hook registration to fluent API#796

Merged
bytesizedroll merged 3 commits intomainfrom
CLD-1266/hook-fluent-api
Feb 26, 2026
Merged

Add per-changeset hook registration to fluent API#796
bytesizedroll merged 3 commits intomainfrom
CLD-1266/hook-fluent-api

Conversation

@bytesizedroll
Copy link
Contributor

Summary

  • Adds WithPreHooks(...PreHook) and WithPostHooks(...PostHook) to ConfiguredChangeSet and PostProcessingChangeSet interfaces
  • Hooks are stored on ChangeSetImpl and PostProcessingChangeSetImpl, propagated through ThenWith, and extracted into registryEntry via an internal hookCarrier interface when Add() is called
  • Multiple calls are additive (append, not replace)
  • Fully backward compatible — existing Add() call sites and tests are unchanged

Test plan

Copilot AI review requested due to automatic review settings February 26, 2026 20:06
@bytesizedroll bytesizedroll requested a review from a team as a code owner February 26, 2026 20:06
@changeset-bot
Copy link

changeset-bot bot commented Feb 26, 2026

🦋 Changeset detected

Latest commit: d433e75

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
chainlink-deployments-framework Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link

👋 bytesizedroll, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds per-changeset hook registration to the fluent changeset configuration API, and persists those hooks into the registry layer so they can be executed later as part of the changeset lifecycle.

Changes:

  • Add WithPreHooks(...PreHook) / WithPostHooks(...PostHook) to ConfiguredChangeSet and PostProcessingChangeSet.
  • Store hook slices on ChangeSetImpl / PostProcessingChangeSetImpl and propagate them through ThenWith.
  • Extract hooks into registryEntry during Add() via an internal hookCarrier interface.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
engine/cld/changeset/common.go Adds hook registration methods + stores hooks on ChangeSetImpl and forwards them via ThenWith.
engine/cld/changeset/postprocess.go Converts PostProcessingChangeSet to an interface and adds hook registration + storage on post-processing changesets.
engine/cld/changeset/registry.go Extends registryEntry to include hook slices and extracts them during newRegistryEntry() on Add().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

WithPreHooks, WithPostHooks, and ThenWith so each chained value
gets an independent copy, prevents aliasing
@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
26.3% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 88 to +96
func newRegistryEntry(c ChangeSet, opts ChangesetConfig) registryEntry {
return registryEntry{changeset: c, options: opts}
entry := registryEntry{changeset: c, options: opts}

if hc, ok := c.(hookCarrier); ok {
entry.preHooks = hc.getPreHooks()
entry.postHooks = hc.getPostHooks()
}

return entry
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

registryEntry now captures preHooks/postHooks via hookCarrier, but those fields are never read anywhere in this package (including ChangesetsRegistry.Apply). As a result, the new WithPreHooks/WithPostHooks fluent API has no observable effect at runtime. Consider either (a) executing these hooks as part of ChangesetsRegistry.Apply (or the underlying changeset Apply) or (b) providing an exported accessor that downstream code can use to retrieve hooks for execution.

Copilot uses AI. Check for mistakes.
type PostProcessor func(e fdeployment.Environment, config fdeployment.ChangesetOutput) (fdeployment.ChangesetOutput, error)

type PostProcessingChangeSet internalChangeSet
type PostProcessingChangeSet interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: thinking about the name of the interface, maybe there's something we could add to also imply the interface handles pre processing too? maybe HookableChangeSet or LifecycleChangeSet.

@bytesizedroll bytesizedroll added this pull request to the merge queue Feb 26, 2026
Merged via the queue into main with commit ed1a889 Feb 26, 2026
24 of 25 checks passed
@bytesizedroll bytesizedroll deleted the CLD-1266/hook-fluent-api branch February 26, 2026 20:53
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.

3 participants