-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup Kinobi (2/2) #11
Conversation
I think splitting formatting and linting is okay in the scripts but is it necessary in CI? I'm just trying to see if that's what we'd want to do in the |
It doesn't have to be split in CI, it can be "Format and Lint", doesn't really matter. |
I will say that, although it looks a bit neater to split them in CI, one compelling reason is the fact that, in Rust, formatting does not require building the crate, however clippy does. In other words the formatting job can be faster and doesn't need caching, while clippy will have a bit more overhead and utilize a cargo cache. |
Yes but if you have the formatting step occurs before the linting step on the same job, we have a very similar behaviour as, if the formatting step fails, the job will stop and other jobs in the same group will be cancelled. In a way, it's more performant because it's less sequential — i.e. we don't need to wait until all formatting steps are done before moving on to the linting phase. |
I think it's just a matter of preference, really. You're right it might be faster if they're grouped together. I typically lean towards "one job should do one specific thing", but maybe we don't want to impose that on the template. Somebody break the tie @febo ! |
I think we just have a slightly different view of the granularity of the "one thing" that each CI job does. For me, formatting and linting is part of the same "one thing" which is "check the code style is alright". But I can also see your point of view that formatting can be its own thing — i.e. "check the code style statically" — and linting its own other thing — i.e. "check the code style is alright in a more clever way which, in Rust, means actually building the code". I still leaning towards the former but selecting the latter is also fine by me. |
I am inclined to "merge" formatting and linting into the same step, where both are related to checking code style. It is also faster by reducing the sequential steps and less jobs being started, which trigger loading an image, cache, etc. |
I would also group the "Check IDL generation" and "Check client generation" together with "Build programs" since you probably don't want to test the client if any of them fail. As it is, the client testing will continue even when they fail. |
Nice! I think this is probably good enough for this specific program but if we're gonna move this into
Whilst I agree there is technically a flow of first generating the IDL and then generating the clients, the checks can be run in parallel here because we are failing if the working directory is dirty at each step. The issue with running them sequentially is that the "Check IDL" job is much slower as Anchor or Shank will end-up building the program (which is why in the Additionally, I think the "Test programs" job has no need to wait for the "Build programs" job as they use two different sets of cache (one built for prod and one built for dev). Having them sequentially will significantly increase the duration of the pipeline. To summarise, my recommendation is to:
|
I'm not sure about Anchor, but Shank does not build the program. It builds the Shank crate(s) and then reads the files in your crate. It uses the derive macro annotations to key on, but they only expand at compile-time to give you things like helpers.
Yep I'm okay with this. I liked having them separate for the same reasons you listed.
For Shank they don't need the program's cached build, so do they still need to depend on "Build programs"? It seems like the 3rd job from my original pipeline is good.
Sounds good! |
Ah okay then it seems it'd only be an optimisation for Anchor programs. Therefore maybe it's good enough to leave it in parallel with the build program job. 👍 P.S.: Once we have Kinobi macros, we won't even need this "Check IDL generation" step since it'll be created on program build. |
Ok @lorisleiva I've updated with your feedback. The only question I have is, do the other tests need the program build step? I would assume so, right? So even though ![]() |
Yeah, clients need to be tested after the "Build programs" job because they start a local validator using the .so files created by the build job. Technically only the JS client currently uses a local validator since the Rust client doesn't need to but since any other future client will end up needing a validator I think it's best to have them all together after the build job. Wdyt? |
The Rust client tests needs to run after "Build programs" as well since it uses the .so file from the program. |
Okay, agreed with both of you! I'll move them after. Let me know if there's any other feedback on this overall setup, as it pertains to |
@buffalojoec I've got lots of smaller notes — e.g. is a matrix really necessary if we're going through each variant to select the script anyway — but these are nits that would only apply to porting these changes to Otherwise I'm also happy to make a PR to |
Sounds good to me! No worries on blocking this PR, this whole intention of this PR itself was to bikeshed what goes into Yeah a chat sounds good to me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright I've thrown lot's of rough notes I have about these changes as they are meant to be applied to create-solana-program
. Let us discuss. 😄
I think I've addressed everything! I added our discussed changes one commit at a time, then the last commit drops all customization and aims to demonstrate what the template might put out. FYI the "Test Programs" job is going to fail until we stick the configs back in (ie.
|
Merging on red so I can submit a PR to update the template, which should just... fix everything. 😁 |
This is PR 2/2 for setting up Kinobi and the rest of the goodies from the
create-solana-program
template.First I laid down the boilerplate that comes from
create-solana-program
,then added
shank
to the program to generate an IDL, then generated aclient.
After that, I split formatting and linting into separate scripts. In Rust, that's
rustfmt
andclippy
, and in JavaScript, that'sprettier
andeslint
,respectively.
Finally I bootstrapped a CI pipeline according to @febo's new workflow design: