Repository navigation
chore: generate CI config & use context dir - #8241
Conversation
1255e1f to
9efc3b0
Compare
0baecf2 to
7f8aa15
Compare
jedevc
left a comment
There was a problem hiding this comment.
My only major complaint with this PR is that I didn't get to do it 😆 Seriously, it's such a neat approach, I'm a fan 🪭
This isn't a real review, just was reading through and left some thoughts about some future features/fixes - none of them are really blockers. The only more major point is the one around the fact that I think this increases our CI cost by spinning up more workers (but I left a suggestion as to what we might do about that).
I think we should try and get this in... relatively soon? Maybe sometime next week works? I think starting with just the docs and sdk steps is good, since those are "simpler", but also, means that if we turn out to not like the approach (very doubtful in my mind), we can more easily backtrack.
There was a problem hiding this comment.
Would it possible to group multiple dagger commands into a single file? e.g. I think it would be really nice to have all the elixir checks in one single pipeline, but potentially all different jobs, or maybe even steps in a single job?
Not 100% sure, I don't think we need to be optimizing to have a pretty view in github. But mainly, I think it would help avoid spinning up too many new CI workers (which can be pricey).
There was a problem hiding this comment.
It's possible but requires some extra implementation work, to "collapse" pipelines that can be collapsed. Either automatically or with a "hint" from the caller. I would love a PR on the gha module with that feature :)
There was a problem hiding this comment.
@jedevc thinking about this more:
I think it would be really nice to have all the elixir checks in one single pipeline, but potentially all different jobs
This is possible (with some implementation work) BUT it will NOT change the number of machines started, because each job gets its own machine, regardless of workflow grouping.
or maybe even steps in a single job?
There is no benefit to this. It should be done at the Dagger level.
There was a problem hiding this comment.
This is possible (with some implementation work) BUT it will NOT change the number of machines started, because each job gets its own machine, regardless of workflow grouping.
Yeah, fair enough - I guess it's more just for sorting at the github level. I don't currently have the time to PR this in (reviews + flakes + prep for v0.13 are most of my attention this week) - but can try and find a moment after that's landed if no one else can pick it up.
There is no benefit to this. It should be done at the Dagger level.
Fair. I think I agree - this does mean that if we want lots of tasks done, you need to use your language primitives for it. This is good.
But, I think if we're doing this more, the performance of the traces view in dagger cloud might need some help - when you have a lot of spans together, the performance can really suffer, and the page takes way more time to load than the basic github actions logs view. But hopefully we can feel the pain of this and do something here.
There was a problem hiding this comment.
But, I think if we're doing this more, the performance of the traces view in dagger cloud might need some help - when you have a lot of spans together, the performance can really suffer, and the page takes way more time to load than the basic github actions logs view. But hopefully we can feel the pain of this and do something here.
I believe @vito has been focusing specifically on Traces UI performance :)
| func (gh *Github) withSimplePipeline(name, command string, opts ...dagger.GhaWithPipelineOpts) *Github { | ||
| opts = append(opts, dagger.GhaWithPipelineOpts{ | ||
| OnPushBranches: []string{"main"}, | ||
| OnPullRequestOpened: true, |
There was a problem hiding this comment.
Potential interface idea - instead of needing to have a bunch of booleans here, we could maybe have a custom enum of event types in the gha module? Then we just pass a list of Events []GhaEvent in (which also lets you more easily programmatically control these).
There was a problem hiding this comment.
Yes that's a great idea. My only concern is: what do we do about the onXYZ arguments that are not boolean? Like onPullRequestBranch etc. How do we avoid making the split feel weird to callers?
There was a problem hiding this comment.
So what I can tell - the event block here is made up of two things - the thing that can happen to the branch, and the branch target.
So actually it's a bit trickier than an enum - it's almost like we want an event to be:
type GithubEvent struct {
PullRequest *GithubPullRequestEvent
Issue *IssueEvent
... // more events
}
type GithubPullRequestEvent struct {
Branches []string
Triggers []GithubPullRequestTrigger
}
type GithubPullRequestTrigger string
const (
GithubPullRequestOpened = "opened"
// ...
)Then, you just pass in a list of GithubEvent to your WithPipeline - maybe constructing them something like:
event := dag.OnPullRequest().WithBranch("main").OnOpen().OnClose()
How does something like that sound? Feels very literate-style, but then each event is it's own dagger object to manipulate (which would be really cool, now you could build little functions to encapsulate the logic for your project).
There was a problem hiding this comment.
@jedevc this is what I initially want to do, it most closely models the reality of the underlying data structure. But, it wouldn't be usable from the CLI. I am setting a constraint for myself to make the API great in both code and the CLI.
There was a problem hiding this comment.
tangent: is this then an argument to make the CLI more powerful, so it can handle construction of more complex objects, i.e. ones that take other objects as parameters?
If we want all modules to be easily usable from code and the CLI, then I think the CLI just needs to be more powerful to be able to handle this - otherwise, we end up in this scenario of making an API worse-for-code, so it works-at-all for the CLI.
cc @helderco
There was a problem hiding this comment.
tangent: is this then an argument to make the CLI more powerful, so it can handle construction of more complex objects, i.e. ones that take other objects as parameters?
Yes :)
| // Generate Github Actions pipelines to call our Dagger pipelines | ||
| func (gh *Github) Generate() *dagger.Directory { | ||
| return gh.CI.Config().Directory(".github") | ||
| } |
There was a problem hiding this comment.
A little ask - could we also use the dirdiff module to implement a lint action here as well (and maybe have a pre-defined workflow to make sure this in sync?).
I wish there was a way to avoid needing to have these generated files in the repo at all, I might have some fun ideas for that (hackathon project?), but they involve way too much hackery at the github actions level for now.
There was a problem hiding this comment.
I actually implemented this already 😁 kudos to @kpenfound for helping figure it out. Unfortunately it's not that great, the best gha can do is generate the files and commit/push them for you. Unlike other CIs it doesn't support continuation.
There was a problem hiding this comment.
Ahhhh, yeah that's a neat approach. That's annoying it's not great, I think we can just stick with manual invocation for now 😢 (definitely not worth blocking on)
There was a problem hiding this comment.
I think this gap is a possible insertion point for bridging to pocketCI :) But I don't know exactly how. cc @kpenfound @matipan
There was a problem hiding this comment.
@jedevc I added a Check() function that uses dirdiff. But I wasn't sure where to integrate it in the main module, so I didn't wire it in. I could use your guidance on that.
There was a problem hiding this comment.
Hm, I'd add a new github workflow for right now for this - something like github lint? I suppose wiring it into the main module makes sense, but we could also just have a single workflow that directly calls the github module, I'm not hugely biased towards either.
7a139f6 to
83133d7
Compare
gerhard
left a comment
There was a problem hiding this comment.
I like the idea of using Dagger to generate GitHub Actions YAML. I am not excited about removing 180 lines of YAML, and adding 11k lines of generated YAML.
Some of the new scripting is significantly more complex than what we had before. While action.yml would not win any scripting competitions, it was simpler.
The only real blocker that I see to merging this is losing the timeout setting. Restricting GITHUB_TOKEN permissions would be nice to keep, but less of a blocker.
Overall, I am curious to see how well this works in practice. Specifically:
- When a job fails, is it easier to understand which step failed & why?
- How well does the workflow dispatch work after the test & lint split?
- What impact does this split have on scheduling jobs? We will need 2x as many runners.
- What's it like to live with 2 modules,
.daggerand.github?
One thing which I know will hurt is when we hit GitHub's 100 checks limit. After this change, we are at 91. GitHub's UI makes it impossible to make sense of more than 100 checks. I don't think the number goes higher than 100 (this limitation goes back to 2021), and the small scrolling area makes it very difficult to find anything. Also, the Checks tab is getting more difficult to use:
I am going to approve this optimistically so that we can merge this (after resolving the conflicts) and try living with this change for a few weeks. YOLO!
579f90a to
46bd74b
Compare
|
Thanks Gerhard! A few notes below.
A more fair comparison is that I replaced 180 lines of YAML with 196 lines of Go, which can collapse to a ci.Gha = dag.Gha(dagger.GhaOpts{
DaggerVersion: daggerVersion,
PublicToken: "dag_dagger_sBIv6DsjNerWvTqt2bSFeigBUqWxp9bhh3ONSSgeFnw",
Runner: ci.BronzeRunner(false),
})
return ci.
WithPipeline("Docs", "docs lint", "", false).
WithSdkPipelines("python").
WithSdkPipelines("typescript").
WithSdkPipelines("go").
WithSdkPipelines("java").
WithSdkPipelines("elixir").
WithSdkPipelines("rust").
WithSdkPipelines("php")I expect the ratio will only get better as switch more pipelines to be generated. This would be nicer if Github Actions supported continuations - then the generation step could be hidden better. We'll start with proper
It was not actually simpler. The perceived increase in complexity comes from several things:
Some of the above ☝️ are not specific to generating the YAML. For example, I could generate a workflow that references a shared static
Thanks for catching that. I'm on it.
So far it seems the be either the same or better, depending on the situation.
Not sure what you mean by that.
I don't think so. My understanding is that machines are allocated at the job level, not the workflow level. This is one reason I went for one pipeline per workflow file. It didn't seem to impact the runtime behavior that much.
I am not attached to 2 modules particularly, but it seems most aligned with the current consensus on how to tackle code generation pipelines with Dagger. That is totally something we can change.
I actually think we can bring the number of checks down easily. I didn't mind the increased number of checks (if anything I started to look at the Dagger Cloud checks less, because I get the same granularity from GHA checks now). But I can prioritize bringing the number the checks down. The easiest way to do this, is to collapse pipelines in Dagger. Lint, test and test-publish for each SDK can be collapsed into a single dagger call. Splitting that across 3 VMs per SDK is overkill anyway. Separately, we should talk about what this model means for Dagger Cloud checks. Do we still need that granularity in a world where generated CI config is the norm, giving you the granularity for free? Maybe we can switch to a single Dagger Cloud check that links to the entire trace group? cc @vito @aluzzardi @kpenfound @crjm
Thank you, I appreciate the detailed review! |
2a1a8d0 to
cd8ff2d
Compare
|
@jedevc From what I can tell. The test failed on mounted cache test. And from this failure, it looks like cache volume is stored from the previous run somehow cause it gets double result. I open a PR to fix this at #8317 by using LOCKED mode but I'm also not sure if it's the right fix. |
Is it possible that my PR caused the issue? Maybe a subtle change in the YAML config? |
910e1c2 to
869f9b7
Compare
41f3684 to
af2b5e0
Compare
|
@gerhard in an effort to make you happy, we are now down to 3k lines of YAML instead of 11k :) |
|
Force-pushing a small change to re-run all failed workflows... |
|
FYI I am combining #8284 into this, it's too much work to maintain both in parallel. |
10c8596 to
bb1f236
Compare
This uses the new "context directory" feature in Dagger 0.12.6 Signed-off-by: Solomon Hykes <[email protected]>
This is a small first step towards eventually generating 100% of our Github Actions config. - Docs lint - SDK lint and test (on stable and dev engine) Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
We added a bunch of new workflows that we have not been tracing. This fixes it. Follow-up to: - #8407 - #8241 Signed-off-by: Gerhard Lazu <[email protected]>
This is a small first step towards eventually generating 100% of our Github Actions config.