Skip to content

Instantly share code, notes, and snippets.

@chrisgilbert
Last active March 19, 2019 17:57
Show Gist options
  • Save chrisgilbert/5cc990bdd715cf9e52faaa17118ac810 to your computer and use it in GitHub Desktop.
Save chrisgilbert/5cc990bdd715cf9e52faaa17118ac810 to your computer and use it in GitHub Desktop.
Ideas for CI/CD implementation
// The basic ideas are:
// 1. We could use the cake Setup method thing to configure what the build does.
// 2. We can use implementation of interfaces to signal what needs to happen for each build step.
// 3. Custom steps would involve using a generic class, or creating your own and implementing required interfaces.
// 4. Each step would have to store state, e.g. a lock file to show it has been run.
// 5. The delivery step would use the strong typing to know which artefacts _should_ be there and what it should do with them.
// 6. You can pass a single parameter to the cake script and run it multiple times in parallel (maybe). You can also just run the "build-all" task to do it sequentially.
// Probably in some library
interface DockerStep
{
string StepName;
string DockerFile;
}
interface OutputArtifact
{
string CacheKey;
string Location;
}
interface StaticAssets
{
string PublishLocation;
}
class FrontendBuild : DockerStep, OutputArtifact, StaticAssets
{
string StepName = "frontend-build";
string CacheKey = "created by magic";
string Location = "src/client-app";
string DockerFile = "src/client-app/Dockerfile";
string PublishLocation = "s3:/bla/bla";
}
class WebappBuild : DockerStep, OutputArtifact
{
string StepName = "backend";
string CacheKey = "created by magic";
string Location = "src/Hudl.";
string DockerFile = "client-app/Dockerfile";
}
class CustomDockerBuild : DockerStep, OutputArtifact
{
}
// In Cake:
Setup(context =>
{
AddBackendBuild();
AddFrontendBuild();
// My custom build that doesn't fit into a normal use case. Just tell the pipeline what to run and where to put stuff
AddCustomDockerBuild(StepName="my-go-app", CacheKey="something", Location="src/golang-project", Dockerfile="src/golang-project/Dockerfile");
}
Task("build-all")
.DoesForEach(GetAllThingsWithReflectionMagic(), (thing) =>
{
DockerBuild(thing);
}
var buildStep = Argument("build-step", "frontend");
Task("build-each")
.Does(() =>
{
DockerBuild(buildStep);
CreateLockFile(buildStep);
}
Task("deliver")
.Does(() =>
{
GetAllTheArtifacts();
PublishAllTheThings();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment