copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

Running CI on PRs/branches

Open Fodoj opened this issue 2 years ago • 4 comments

As of now, Copilot's pipeline is created for a single branch. I guess the reason is to enable continuous deployment, after running some tests, to the target environment.

Once I move running a test suite to be inside Build Spec, I would like to also run it on every branch and pull request. At the moment it seems I would have to use another CI tool for this?

To re-cap:

Any branch: run continuous integration (tests, lint, security checks). On main branch: run continuous integration and if its green, deploy.

Is it planned for Copilot? Or are there any best practices to implement it with the current versions? Or is the idea to use Copilot pipeline only to deploy, and a separate CI system for CI?

Fodoj avatar Jul 10 '22 09:07 Fodoj

Hello, @Fodoj!

Yes, because Copilot uses CodePipeline, each pipeline tracks a single repo branch. There isn't currently a Copilot-native way to manage multiple pipelines / do the CI without the CD, but let me dig into this a little bit and I'll see if we can come up with something for you!

huanjani avatar Jul 11 '22 16:07 huanjani

I'm still looking into what we might be able to do within Copilot, but in the meantime, would it work for you to create a pipeline for each of your branches, then add requires_approval: true to all pipelines' manifests except for that of the one following main?

huanjani avatar Jul 11 '22 23:07 huanjani

That would require some kind of automation for pipeline creation, because I want to run CI on any feature branch :) For now I will use GitHub Actions and wrap copilot cli with it, seems to be the cleanest solution

Fodoj avatar Jul 12 '22 08:07 Fodoj

Ah, gotcha. For what it's worth, I've seen, online, folks adding automated pipeline creation: https://aws.amazon.com/blogs/devops/multi-branch-codepipeline-strategy-with-event-driven-architecture/ and https://moduscreate.com/blog/track-git-branches-aws-codepipeline/.

huanjani avatar Jul 12 '22 16:07 huanjani

That would require some kind of automation for pipeline creation, because I want to run CI on any feature branch :) For now I will use GitHub Actions and wrap copilot cli with it, seems to be the cleanest solution

@Fodoj - would you mind sharing what you built with GitHub Actions to wrap copilot? I think this would be a really useful reference here until branch CI is supported directly.

@huanjani - It seems to me that copilot could do the same thing as @Fodoj is doing with GitHub Actions by having an option to deploy a meta-pipeline for branch CI. The meta-pipeline would be triggered for reference create & delete actions with reference filter patterns to select actionable references (eg. just branches & naming convention, etc). The meta-pipeline could then then run copilot to create pipelines from a template on reference create & delete the pipeline on reference delete.

mikereinhold avatar Jul 13 '23 16:07 mikereinhold

I have a regular GitHub Actions pipeline to build and test my app, nothing Copilot specific. Copilot is executed after the merge to the main branch, to do the deployment.

Fodoj avatar Jul 14 '23 05:07 Fodoj

hey @mikereinhold 👋🏼 Thanks for chiming in! Just curious, are you looking for the same thing as @Fodoj , i.e. have a pipeline that listens to all branches? Was that the motivation that behind the meta pipeline?

Lou1415926 avatar Jul 17 '23 20:07 Lou1415926