Skip to content
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

Optimize CI caching and path filtering #2340

Merged
merged 27 commits into from
Jan 18, 2022

Conversation

Madoshakalaka
Copy link
Contributor

@Madoshakalaka Madoshakalaka commented Jan 7, 2022

Per-job Caching

each job now has its own cache keys.
Previously all jobs have the same cache. This is mad inefficient.
Cache from the nightly toolchain doesn't help at all in the same job with the stable toolchain for example.

Also added missing npm caching for website-related workflows.

stale cache invalidation

cargo caches aggressively and leaves a lot of outdated dependencies in the cache.
cargo-sweep is introduced to detect and clean unvisited cache during each job.
Also added a manually-dispatchable weekly cron job to build the cargo-sweep binary and commit to the ci/ directory.

Path Filtering Workflows

Touching website/** now won't trigger irrelevant workspace tests.

The same goes the other way around, touching other stuff won't trigger website workflows.

edit: touching other stuff should trigger website tests because the snippets depend on them.

Combined Website building and publishing

Previously two workflows were set up sequentially to do the building and publishing. The artifact download and upload can take a minute and a huge chunch of complex steps are dedicated to
setting variables and communicating between the two workflows. They are now combined with a job:needs key to preserve the sequential nature.

Remove check-examples job in the pull-request workflow

It is covered by a previous clippy --all-targets job and only increases build time

Extract cargo fmt job as workflow

It doesn't need any caching and can be completed concurrently as fast as possible instead of blocking the pull-request workflow.

Renaming

pull-request.yml is renamed to main-checks.yml

un-exclude tool/website-test

I can't figure out the reasoning for excluding the package in the workspace. It would complicate caching setup so I included it and the tests pass smoothly locally. I'll see how it goes in the CI.

Fixes #0000 complaints about slow CI speed

CI is tricky to get right, I expect this PR to go through some painful followup edits :D

Comment on lines -92 to +93
writeln!(dst, "#[doc = include_str!(\"{}\")]", file.display())?;

writeln!(dst, "#[doc = include_str!(r\"{}\")]", file.display())?;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this previously prevented these tests to be run on windows

Comment on lines 253 to 256
:::note Extra Braces Required
`sidebar = {{html_nested!{...}}}` appears to require one extra set of braces.
This is unintuitive, and we will fix the behavior in a later release.
:::
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add notes on the website for #2267

This help check the correctness of the combined website workflow too

@voidpumpkin voidpumpkin added documentation meta Repository chores and tasks labels Jan 7, 2022
@Madoshakalaka
Copy link
Contributor Author

@voidpumpkin Why did the benchmark start for my PR anyways, when the PR doesn't have the label "performance", does this fail to filter?
https://github.com/yewstack/yew/actions/runs/1666840597/workflow#L3-L7

@Madoshakalaka
Copy link
Contributor Author

I think everything works as expected, except the weird benchmark workflow behavior which @voidpumpkin is going to redo anyways. I'll sleep on this PR and see if anything needs to be changed tomorrow 🛏️

@voidpumpkin voidpumpkin requested a review from siku2 January 7, 2022 09:19
Copy link
Member

@siku2 siku2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very annoying to review like this so let's just run it and fix issues as they pop up.

@siku2
Copy link
Member

siku2 commented Jan 7, 2022

Oh I absolutely hate the idea of keeping the cargo-sweep binary in the repository. There has to be a way around that?

Copy link
Member

@voidpumpkin voidpumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks goof for me but I will wait for @siku2 to review as he know more whats up with our ci.

website/docs/concepts/components/children.mdx Outdated Show resolved Hide resolved
@Madoshakalaka
Copy link
Contributor Author

Madoshakalaka commented Jan 7, 2022

Oh I absolutely hate the idea of keeping the cargo-sweep binary in the repository. There has to be a way around that?

cargo-sweep doesn't release binaries, the release build is only 5Mb. hmm an alternative is to publish our own releases of ci-tools I guess? If that pollutes the repository too much I guess then we can have a separate ci-tools repository under yewstack

Copy link
Member

@siku2 siku2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually noticed some bigger problems, so let's not merge this just yet :)

Generally very happy with the changes though!

.github/workflows/build-and-publish-website.yml Outdated Show resolved Hide resolved
.github/workflows/build-cargo-sweep.yml Outdated Show resolved Hide resolved
@voidpumpkin
Copy link
Member

@voidpumpkin Why did the benchmark start for my PR anyways, when the PR doesn't have the label "performance", does this fail to filter? https://github.com/yewstack/yew/actions/runs/1666840597/workflow#L3-L7

Yes it fails to filter.
But it's not a problem because merging is not blocked even if its still running.

@siku2
Copy link
Member

siku2 commented Jan 7, 2022

cargo-sweep doesn't release binaries, the release build is only 5Mb. hmm an alternative is to have publish our own releases of ci-tools I guess? If that pollutes the repository too much I guess then we can have a separate ci-tools repository under yewstack

How about using the cache for this too? Makes it slightly more complicated to perform automatic updates but it's much less of a hassle than to set up a separate repository for it.

@Madoshakalaka Madoshakalaka marked this pull request as ready for review January 10, 2022 03:35
@Madoshakalaka
Copy link
Contributor Author

Should be ready now

@ranile
Copy link
Member

ranile commented Jan 10, 2022

Is cargo check for examples on PRs removed?
Also, we can we publish examples preview like we do for website?

@Madoshakalaka
Copy link
Contributor Author

Is cargo check for examples on PRs removed?

Yes, there is a cargo clippy --all-targets at the workspace root and doesn't that cover what cargo check does?

Also, we can we publish examples preview like we do for website?

Good point, separate PR?

@voidpumpkin
Copy link
Member

Is cargo check for examples on PRs removed?

Yes, there is a cargo clippy --all-targets at the workspace root and doesn't that cover what cargo check does?

Also, we can we publish examples preview like we do for website?

Good point, separate PR?

I agree it should be separate PR

Copy link
Member

@voidpumpkin voidpumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would approve, but @Madoshakalaka could you rebase?

on:
pull_request:
paths:
- "**/*.rs"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this.
It inspired me to make actions that add labels that i have been adding manually. (They are needed for changelog generation)

…es and there can be

#[doc(include("../some.md"))] in the code
# Conflicts:
#	Cargo.toml
#	website/docs/getting-started/build-a-sample-app.mdx
voidpumpkin
voidpumpkin previously approved these changes Jan 12, 2022
@voidpumpkin voidpumpkin requested review from ranile and removed request for voidpumpkin January 12, 2022 08:25
@ranile
Copy link
Member

ranile commented Jan 12, 2022

Please resolve the conflicts

# Conflicts:
#	.github/workflows/build-website.yml
Copy link
Member

@voidpumpkin voidpumpkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wait why suspense extension became mdx in this pr?
(keeping in mind #2353 )

@Madoshakalaka
Copy link
Contributor Author

oh wait why suspense extension became mdx in this pr? (keeping in mind #2353 )

kinda wanted to avoid contamination of PRs, I am well aware conflicts will need to be resolved for #2353 after this is merged and I have no problem with that :)

@voidpumpkin
Copy link
Member

@hamza1311 i think we could merge this in

Copy link
Member

@ranile ranile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything goes wrong, it can be fixed later

@ranile
Copy link
Member

ranile commented Jan 18, 2022

Can't merge because of @siku2's review...

@siku2 siku2 merged commit 6669d18 into yewstack:master Jan 18, 2022
@Madoshakalaka Madoshakalaka deleted the ci-optimization branch January 26, 2022 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation meta Repository chores and tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants