Enable dynamic changesetTemplates by adding templating & steps outputs#424
Conversation
42f3045 to
569e37d
Compare
|
This is so cool! I'm thrilled to see this coming together! |
|
This is ready for review. I'll add the docs in a PR to sourcegraph/sourcegraph tomorrow, @sourcegraph/campaigns. |
LawnGnome
left a comment
There was a problem hiding this comment.
I have a question around forward compatibility of cached changeset specs (which I think was probably already present, but is more obvious now), but otherwise this looks good! 👍
|
@LawnGnome @eseliger After Adam spotted in bug in this comment I reworked the
I went a bit overboard with the tests, maybe, but they were a joy to write, so... reason enough to up the test coverage :) Since we do have a branch cut later today, it would be great if @eseliger can review this and we merge this before then. @LawnGnome you can then also take another look and if there are issues we can follow up, but I want to cut a 3.24 release with this in it and bump the |
|
@LawnGnome We just reviewed this together, Erik and I. And Erik, of course, found something: the conversion from old caches to new caches is not lossless, since we don't recreate the |
I don't see anything problematic from where I sit, besides the cache lossiness issue Erik saw (which I'd be amazed if anyone ever hit). 👍 |
#424) * Add templating to changesetTemplate and steps.outputs * Fix parsing of outputs * Remove leftovers in campaign spec schema * Remove debug output * Rename test function * Add a test for renderChangesetTemplateField * Update docs/examples in campaign spec schema * Get dynamic changeset templates working with cache * Simplify ExecutionCache by using ExecutionResult * Change interface of runSteps to return ExecutionResult * Add 'steps' to changesetTemplate template variables * Support templating in changesetTemplate.author fields * Fix doc comment * Only use yaml.v3 in internal/campaigns * Add tests for ExecutionCacheTest * Add proper backwards-compatibility to ExecutionDiskCache * Remove unneeded code * Add changelog entry * Add comment about lossiness of cache conversion
What?
This PR enables dynamic
changesetTemplatesin campaign specs by doing two things:title,body,branchandcommit.messagefields inchangesetTemplate.outputstosteps, which are values that are set after the step has been executed and that have access to template variables, including the current step's output.This solves the problem of not being able to customize the
changesetTemplateper repository (onlypublishedcould be configured per repository).Show me
With this PR, the following campaign spec works:
It created this pull request:
Meta
PR in
sourcegraph/sourcegraphthat adds the schema: https://github.com/sourcegraph/sourcegraph/pull/17243What's missing?
Documentation. I want to add docs for this in https://github.com/sourcegraph/sourcegraph/pull/17243 and also better document templating support, since we now lean on it more heavily.PR is here: https://github.com/sourcegraph/sourcegraph/pull/17286Possible follow-ups
transformChanges.group.branchoptional by makingtransform_changes.groupavailable as a template variable inchangesetTemplate.branch.