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

📏 Report binary size on PR #2

Merged
merged 7 commits into from
Jul 22, 2022
Merged

📏 Report binary size on PR #2

merged 7 commits into from
Jul 22, 2022

Conversation

bdeneux
Copy link
Contributor

@bdeneux bdeneux commented Jul 19, 2022

📝 Description

Given that the size of a smart contract is very important and that it has a very strong impact on transaction costs, it seemed to me necessary to add a small action allowing to report the evolution of the size of each smart contract binary wasm.

🛠 Tool

The tool used here is size-limit-action in addition to size-limit javascript tool. It's the only github action always maintained that allowing report file size evolution into a PR comment. Cargo-bloat also exist but is not compatible with wasm target.

A limitation can be set for each file and make the PR failed if the file size exceed the limit.

🐛 Issues

  • package.json 😭😭, since size-limit is a JS tool, to make this action work, I need to add a package.json file. So to avoid pollute rust with JS stuff, I've add the package.json file setting into the GitHub action.
  • Another issue is that size-limit needs a configuration file to set which file it should analyse. But for the first PR, the config file doesn't exist into the main branch, so the action failed (for comparaison with the main branch of course, size-limit need to build on it). A temporary solution is to add the configuration file into the package.json into the GitHub action, it's working but I prefer set the configuration into a specific file .size-limit. Since package.json size-limit configuration is priority, we need after this PR merged, remove the configuration from package.json.

@bdeneux bdeneux force-pushed the feat/binary-size branch 6 times, most recently from 63641bc to c64283c Compare July 19, 2022 14:56
@bdeneux
Copy link
Contributor Author

bdeneux commented Jul 19, 2022

Blocked by andresz1/size-limit-action#30 (comment)

@github-actions
Copy link

github-actions bot commented Jul 20, 2022

size-limit report 📦

Path Size
target/wasm32-unknown-unknown/release/cw_template.wasm 182.15 KB (-90.46% 🔽)

@bdeneux
Copy link
Contributor Author

bdeneux commented Jul 20, 2022

It's working ! Just by adding a RUSTFLAGS at the compilation time (like cosmwasm documentation said), the wasm binary decrease by 90% 😍.

@bdeneux bdeneux marked this pull request as ready for review July 20, 2022 12:54
@bdeneux bdeneux self-assigned this Jul 20, 2022
Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

Great initiative! ❤️

Some remarks we can discuss.

And just a point of detail about this commit: feat: add binary size action. It should be prefixed with "ci:" like you did for the others. 😛

.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
Makefile.toml Show resolved Hide resolved
@bdeneux
Copy link
Contributor Author

bdeneux commented Jul 20, 2022

@ccamel

And just a point of detail about this commit: feat: add binary size action. It should be prefixed with "ci:" like you did for the others. 😛

About this commit, I've removed it instead of rename since it was a try of another GitHub action ☺️

@bdeneux bdeneux force-pushed the feat/binary-size branch 3 times, most recently from fba5bde to e005a95 Compare July 21, 2022 08:33
Copy link
Member

@amimart amimart left a comment

Choose a reason for hiding this comment

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

That's a very relevant idea, thank you 👍 .

I'll have some little suggestions though

.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
.size-limit.json Show resolved Hide resolved
Copy link

@hleonardtek hleonardtek left a comment

Choose a reason for hiding this comment

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

👍

@ccamel
Copy link
Member

ccamel commented Jul 22, 2022

Thanks for the work! Let's merge it.

@ccamel ccamel merged commit 2ae16e9 into main Jul 22, 2022
@ccamel ccamel deleted the feat/binary-size branch July 22, 2022 09:06
@ccamel ccamel mentioned this pull request Jul 25, 2022
@bot-anik
Copy link
Member

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@bot-anik
Copy link
Member

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants