Repository navigation
feat(plugin): wire before_build and after_build hooks - #59
Merged
Merged
Conversation
- Add HookBeforeBuild and HookAfterBuild constants in protocol.go. - Define BuildPayload and BuildImage structs matching build.ImageSpec data. - Update TestHelperProcess and add TestManager_BuildHooksDelivered test.
- Load lifecycle plugins via plugin.Load using cfg.Plugins. - Dispatch before_build prior to build.Apply with ImageSpec details. - Dispatch after_build with outcome failed on build, scan, or push failure. - Dispatch after_build with outcome success on completion. - Add buildHookPayload helper and unit tests in cmd/build_plugin_test.go.
- Mark before_build and after_build hooks as shipped in docs/spec/plugins.md. - Document Build payload schema with JSON example. - Update examples/sample-event/plugins/logger.sh to subscribe and log build hooks. - Update docs/BACKLOG.md tracking.
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.
Summary
Closes #39.
Follow-up to the plugin system foundation (PR #38). Extends the lifecycle plugin architecture to
mctf buildby dispatchingbefore_buildandafter_buildhooks.What changed
Protocol & Payloads (
internal/plugin/):HookBeforeBuild = "before_build"andHookAfterBuild = "after_build".BuildPayload(event, phase, sha, no_cache, push, dry_run, images, outcome, error) andBuildImage(challenge, category, slug, tags, labels).TestHelperProcessininternal/plugin/plugin_test.goto subscribe to build hooks.TestManager_BuildHooksDeliveredunit test verifying end-to-end delivery of build hooks over JSON-RPC.CLI Wiring (
cmd/build.go):plugin.Loadusingcfg.Plugins.pm.Close()for clean subprocess shutdown.before_buildprior to image builds (build.Apply).after_buildwith outcome"failed"upon build error, scan leak failure, or push failure.after_buildwith outcome"success"upon successful completion.mctf build.cmd/build_plugin_test.go.Documentation & Reference Plugin:
docs/spec/plugins.mdhook roster markingbefore_buildandafter_buildas shipped.examples/sample-event/plugins/logger.shto subscribe to and log build hooks.docs/BACKLOG.mdtracking.Verification
make lint(golangci-lint run ./...+go vet ./...) ✅ (0 issues)go test -race ./...✅ (100% tests pass)make build✅./mctf -C examples/sample-event validate✅./mctf -C examples/sample-event generate --check✅python3 scripts/validate-examples.py✅python3 scripts/validate-generated.py✅