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

gemspec: Remove test files, Gemfile from package #437

Merged
merged 2 commits into from
Jul 15, 2024

Conversation

f440
Copy link
Contributor

@f440 f440 commented Jul 14, 2024

This pull request updates the *.gemspec file to optimize the gem package size and structure. The changes include:

  • Modified files to exclude test files, Gemfile , and CHANGELOG from the package.
  • Removed the deprecated test_files specification as it is no longer recommended.

These changes reduce the extracted package size from 324 KB to 140 KB 160 KB.

Benefits:

  • Shorter download times for users
  • Reduced container sizes when the gem is included

References:

@brendon
Copy link
Owner

brendon commented Jul 15, 2024

Thanks for this. Thanks @f440. I used bundler to create my other gem (I think!) and it has the following for files:

  spec.files = Dir.chdir(File.expand_path(__dir__)) do
    `git ls-files -z`.split("\x0").reject do |f|
      (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
    end
  end

Not including the CHANGELOG seems weird to me so I think I want to keep that in the package. That'd feel similar to not packaging docs. I also don't see them skipping Gemfile (and this is bundler generated).

Actually I just tried using bundler 2.5.15 (what I had installed) to generate a test gem and it came up with this:

spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
    ls.readlines("\x0", chomp: true).reject do |f|
      (f == gemspec) ||
        f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
    end
  end

Perhaps we should just run with that?

@f440
Copy link
Contributor Author

f440 commented Jul 15, 2024

Thank you for checking!

Package users typically don't check the documentation in the expanded directory. When they want to know about changes, they're more likely to look at the Changelog: https://... displayed by bundle info acts_as_list. However, I want to respect your decision.

I've incorporated your suggested content as is, with some adjustments to prevent errors.

@f440 f440 changed the title gemspec: Remove test files, Gemfile, and ChangeLog from package gemspec: Remove test files, Gemfile from package Jul 15, 2024
@brendon
Copy link
Owner

brendon commented Jul 15, 2024

Thanks @f440, definitely that'd usually be the case. Could be handy if someone finds themself offline with only the gem installation to work from but that would be rare :D I'll merge this now. Do you want a release straight away or are you happy to wait?

@brendon brendon merged commit 3eb9345 into brendon:master Jul 15, 2024
27 checks passed
@f440
Copy link
Contributor Author

f440 commented Jul 15, 2024

Thanks for merging this! I'm ready for a release whenever you feel it's appropriate. Thank you for creating such a useful library!

@f440 f440 deleted the remove-unused-files-from-package branch July 15, 2024 10:15
@brendon
Copy link
Owner

brendon commented Jul 15, 2024

You're most welcome :D I can't take all the credit. There have been many talented authors before me on this one :)

If you ever get the chance, check out my new positioning gem: https://github.com/brendon/positioning

I've released this as 1.2.2.

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.

2 participants