Introduce `transformChanges` to campaign spec (RFC 265)
Created by: mrnugget
This is the implementation of the suggested solution for Option B in RFC 265: Multiple changesets per repository to produce multiple changesets in a single repository.
It depends on https://github.com/sourcegraph/sourcegraph/pull/16235. It fixes https://github.com/sourcegraph/sourcegraph/issues/14970.
IMPORTANT: this only implements the first step in "Defintion of success". It does not yet implement addressing multiple changesets in the same repository separately (that's Part2 in the RFC).
What this does is to introduce the transformChanges
property to campaign specs (see https://github.com/sourcegraph/sourcegraph/pull/16235 for schema change on server).
Here is an example campaign spec using it:
name: multi-changesets
description: This is a testing campaign that should have multiple changesets in a single repository.
on:
- repositoriesMatchingQuery: repo:src-cli|automation-testing$
steps:
- run: echo ".swp" >> .gitignore
container: alpine:3
- run: if [[ -e gopkg/main.go ]]; then echo "func unused() int { return 99 }" >> gopkg/main.go; fi
container: alpine:3
- run: mkdir foobar && echo "Hey there" foobar/hello.txt
container: alpine:3
# Transform the changes produced in each repository.
transformChanges:
# Group the file diffs by directory and produce one additional changeset per group.
group:
- directory: gopkg
branch: thorsten/multi-changesets-backend # will replace the `branch` in the `changesetTemplate`
- directory: foobar
repository: github.com/sourcegraph/automation-testing # optional: only apply the rule in this repository
branch: thorsten/multi-changesets-foobar # will replace the `branch` in the `changesetTemplate`
changesetTemplate:
title: multi-changesets
body: multi-changesets
branch: thorsten/multi-changesets
commit:
message: multi-changesets
published: false
Changelog of this PR
- 02 Dec: Updated the code and the PR description to use the new
branch
property instead ofbranchSuffix
to incorporate feedback on RFC 265. - 02 Dec: Added the optional
repository
attribute to thegroup
. - 10 Dec: Added validation to make sure that multiple changesets cannot be created with the same branch in the same repository. Updated PR description.