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

Reduce production gem size #345

Merged

Conversation

tagliala
Copy link
Contributor

@tagliala tagliala commented Sep 16, 2024

Hello,

please check if this makes sense and if the production gem should also include other files


Include only files that are needed for the production gem.

Also avoids to use git to allow to build the package in an environment
that does not have git (on purpose).

Before

173K

.dokaz
.github/PULL_REQUEST_TEMPLATE.md
.github/dependabot.yml
.github/workflows/dependency-review.yml
.github/workflows/main.yml
.gitignore
.rspec
.rubocop.yml
.ruby-version
.yardopts
CHANGELOG.md
CODE_OF_CONDUCT.md
Gemfile
Gemfile.lock
LICENSE.txt
README.md
Rakefile
benchmarks/Gemfile
benchmarks/benchmarks.rb
bin/console
bin/setup
lib/memo_wise.rb
lib/memo_wise/internal_api.rb
lib/memo_wise/version.rb
logo/logo.png
memo_wise.gemspec

After

19K

CHANGELOG.md
LICENSE.txt
README.md
lib/memo_wise.rb
lib/memo_wise/internal_api.rb
lib/memo_wise/version.rb

Before merging:

  • Copy the table printed at the end of the latest benchmark results into the README.md and update this PR
  • If this change merits an update to CHANGELOG.md, add an entry following Keep a Changelog guidelines with semantic versioning

@tagliala tagliala force-pushed the chore/reduce-production-gem-size branch from 2e0b5ae to fe42265 Compare September 16, 2024 15:12
end
spec.files = Dir.glob(
'{CHANGELOG.md,LICENSE.txt,README.md,lib/**/*.rb}',
File::FNM_DOTMATCH
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need FNM_DOTMATCH? Wouldn't it be the same without it since none of these files begin with .?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, it is not needed, it is also wrong for this use case. I've used it somewhere else to exclude directories (., ..) but this is not the case

@tagliala tagliala force-pushed the chore/reduce-production-gem-size branch 3 times, most recently from 018b18b to d4fece2 Compare September 17, 2024 14:50
@tagliala
Copy link
Contributor Author

tagliala commented Sep 17, 2024

Main / CI (3.3) action should be probably set to "required" in repo's ruleset settings

image

Copy link

codecov bot commented Sep 17, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ea62a71) to head (17beca6).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #345   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          190       190           
  Branches        90        90           
=========================================
  Hits           190       190           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

f.match(%r{^(test|spec|features)/})
end
end
spec.files = Dir.glob('{CHANGELOG.md,LICENSE.txt,README.md,lib/**/*.rb}')
Copy link
Member

@JacobEvelyn JacobEvelyn Sep 17, 2024

Choose a reason for hiding this comment

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

Looks like RuboCop wants these 's to be "s. Other than that and my other comment I think this is good!

CHANGELOG.md Outdated
@@ -9,6 +9,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

**Gem enhancements:**

- Reduced production gem size by 9 times [[#345](https://github.com/panorama-ed/memo_wise/pull/345)]
Copy link
Member

Choose a reason for hiding this comment

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

To be honest I always find statements like this confusing (would reduced size by 1x mean no reduction or a 100% reduction?). Would you be open to changing this to absolutes, e.g.:

Reduced unzipped gem size from 173KB to 19KB

or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much better, thanks

@tagliala tagliala force-pushed the chore/reduce-production-gem-size branch from d4fece2 to fe2deb1 Compare September 17, 2024 15:07
Include only files that are needed for the production gem.

Also avoids to use git to allow to build the package in an environment
that does not have git (on purpose).

### Before

173K

```
.dokaz
.github/PULL_REQUEST_TEMPLATE.md
.github/dependabot.yml
.github/workflows/dependency-review.yml
.github/workflows/main.yml
.gitignore
.rspec
.rubocop.yml
.ruby-version
.yardopts
CHANGELOG.md
CODE_OF_CONDUCT.md
Gemfile
Gemfile.lock
LICENSE.txt
README.md
Rakefile
benchmarks/Gemfile
benchmarks/benchmarks.rb
bin/console
bin/setup
lib/memo_wise.rb
lib/memo_wise/internal_api.rb
lib/memo_wise/version.rb
logo/logo.png
memo_wise.gemspec
```

### After

19K

```
CHANGELOG.md
LICENSE.txt
README.md
lib/memo_wise.rb
lib/memo_wise/internal_api.rb
lib/memo_wise/version.rb
```

Ref: https://docs.rubocop.org/rubocop-packaging/cops_packaging.html#packaginggemspecgit
@tagliala tagliala force-pushed the chore/reduce-production-gem-size branch from fe2deb1 to 17beca6 Compare September 17, 2024 15:08
@JacobEvelyn JacobEvelyn merged commit 6873b97 into panorama-ed:main Sep 17, 2024
12 checks passed
@tagliala tagliala deleted the chore/reduce-production-gem-size branch September 17, 2024 15:21
@JacobEvelyn
Copy link
Member

JacobEvelyn commented Sep 17, 2024

@tagliala I actually have a question for you about this: #346 (comment)

EDIT: Whoops, never mind I'd missed your response!

@JacobEvelyn
Copy link
Member

@tagliala I forgot to mention this yesterday, but this improvement has been published to RubyGems as v1.10.0. Thanks!

@tagliala
Copy link
Contributor Author

I've seen that, downloaded, and tested, thanks!

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

Successfully merging this pull request may close these issues.

3 participants