Explore ways to run campaign spec steps in "workspaces" of a single repository
View options
- Truncate descriptions
Created by: mrnugget
One outcome of our mob programming session on better monorepo & dynamic changesetTemplate
support was the following sketch:
on:
- repositoriesMatchingQuery: foobar && foobar.barfoo && foobar.barfoo.foo lang:typescript
# IDEA: "transform search results" to split up repositories into multiple workspaces
transformSearchResults:
# Run Sourcegraph search, intersect location with the files found in `on:`
- runStepsAtLocationOfFile: file:package.json
repository: github.com/* # Optional: only run for repository matching this globbing
# Or maybe this name is better?
- groupAtNearest: file:package.json
repository: github.com/*
# Run an arbitrary script that gets the on: results in some sort of structured
# format, does whatever makes sense, and returns the list of repo/directory
# contexts within which to run steps and create changesets.
- transformMatches: ./run-my-script.py
container: alpine:3
# ... the steps will be executed for each directory₁ independently...
steps:
# ... and the "repository.search_result_paths" only contain results in the *directory*
- run: echo Hello World | tee -a ${{ join repository.search_result_paths " " }}
container: alpine:3
changesetTemplate:
# [...]
# Since we now have, potentially, multiple changesets per directory, we need to give them
# different branches.
# The easiest way would be to use templating. Like this:
branch: campaigns/hello-world-${{ steps.workspace }}
# That's the directory in which the steps were run, relative to the root of the directory.
This ticket represents a spike to see whether this part here (ignore the names) is feasible:
# IDEA: "transform search results" to split up repositories into multiple workspaces
transformSearchResults:
# Run Sourcegraph search, intersect location with the files found in `on:`
- runStepsAtLocationOfFile: file:package.json
repository: github.com/* # Optional: only run for repository matching this globbing
After talking about this multiple times with the rest of the campaigns team and Keegan on the search team, we all seem to agree that it makes sense to introduce something that allows the user to say: "Run this search query to discover workspaces in this repository" It seems really powerful.