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

[Backport 7.x] (PUP-12031) Consolidate gem depenendencies & metadata into puppet.gemspec #9337

Merged
merged 2 commits into from
May 9, 2024

Conversation

AriaXLi
Copy link
Contributor

@AriaXLi AriaXLi commented May 7, 2024

Backport of #9325 to 7.x

@AriaXLi
Copy link
Contributor Author

AriaXLi commented May 7, 2024

There are some discrepancies between the runtime dependencies versions in .gemspec and ext/project_data.yaml:

.gemspec:

  s.add_runtime_dependency(%q<facter>, [">= 2.4.0", "< 5"])
  s.add_runtime_dependency(%q<multi_json>, "~> 1.13")

project_data.yaml:

   facter: ['> 2.0.1', '< 5']
   multi_json: '~> 1.10'

Maybe the .gemspec wasn't updated as ext/project_data.yaml was updated or vice versa?. Either way, I followed whatever runtime dependency versions were specified in project_data.yaml since that's what's used on https://rubygems.org/gems/puppet/versions/7.30.0

@AriaXLi
Copy link
Contributor Author

AriaXLi commented May 7, 2024

Well this is not expected 🤔

❯ gem build puppet.gemspec --platform universal-darwin
gem build puppet.gemspec --platform universal-darwin
ERROR:  While executing gem ... (OptionParser::InvalidOption)
    invalid option: --platform

@AriaXLi
Copy link
Contributor Author

AriaXLi commented May 8, 2024

Ah actually, I think the --platform flag just isn't supported in Ruby 2.7:

puppet on  backport_PUP-12031 [$!?] via 💎 v2.7.3 on ☁️  [email protected]
❯ gem help build

Usage: gem build GEMSPEC_FILE [options]

  Options:
        --force                      skip validation of the spec
        --strict                     consider warnings as errors when validating the spec
    -o, --output FILE                output gem with the given filename
    -C PATH
                                     Run as if gem build was started in <PATH> instead of the current working directory.

@AriaXLi AriaXLi changed the title [Backport 7.x] (PUP-12031) Consolidate gem depenendencies & metadata into puppet.gemspec (PUP-12031) Consolidate gem depenendencies & metadata into puppet.gemspec May 8, 2024
@AriaXLi AriaXLi force-pushed the backport_PUP-12031 branch 6 times, most recently from 95cc3aa to 217ef72 Compare May 8, 2024 23:48
…spec

This commit moves the puppet gem metadata from ext/project_yaml.data and
.gemspec into puppet.gemspec. This change allows the puppet gem to be built
using `gem build puppet.gemspec`. Additionally, for platform specific gems
(e.g. puppet-universal-darwin.gem and puppet-x64-mingw32.gem), there is
conditional logic in puppet.gemspec so platform specific dependecies such as
ffi are appended when building those platform-specific gems.

(cherry picked from commit 867ce9c)
This commit adds a Rake task, gem:build, that will build all puppet
gems which includes the three platform specific puppet gems:
x86-mingw32, x64-mingw32, and universal-darwin

(cherry picked from commit e58bc11)
@AriaXLi AriaXLi changed the title (PUP-12031) Consolidate gem depenendencies & metadata into puppet.gemspec [Backport 7.x] (PUP-12031) Consolidate gem depenendencies & metadata into puppet.gemspec May 8, 2024
@AriaXLi
Copy link
Contributor Author

AriaXLi commented May 8, 2024

Successfully built gem using 'gem build puppet.gemspec':

❯ gem build puppet.gemspec
gem build puppet.gemspec
  Successfully built RubyGem
  Name: puppet
  Version: 7.31.0
  File: puppet-7.31.0.gem
❯ gem build puppet.gemspec --platform universal-darwin
gem build puppet.gemspec --platform universal-darwin
  Successfully built RubyGem
  Name: puppet
  Version: 7.31.0
  File: puppet-7.31.0-universal-darwin.gem
❯ gem build puppet.gemspec --platform x64-mingw32
gem build puppet.gemspec --platform x64-mingw32
  Successfully built RubyGem
  Name: puppet
  Version: 7.31.0
  File: puppet-7.31.0-x64-mingw32.gem
❯ gem build puppet.gemspec --platform x86-mingw32
gem build puppet.gemspec --platform x86-mingw32
  Successfully built RubyGem
  Name: puppet
  Version: 7.31.0
  File: puppet-7.31.0-x86-mingw32.gem

@AriaXLi
Copy link
Contributor Author

AriaXLi commented May 9, 2024

Diffs to verify that the gems are being built correctly:

❯ diff <(gem specification puppet-7.30.0.gem) <(gem specification puppet-7.31.0.gem)
4c4
<   version: 7.30.0
---
>   version: 7.31.0
11c11
< date: 2024-04-09 00:00:00.000000000 Z
---
> date: 2012-08-17 00:00:00.000000000 Z
171c171,173
< description: Puppet, an automated configuration management tool
---
> description: |
>   Puppet, an automated administrative engine for your Linux, Unix, and Windows systems, performs administrative tasks
>   (such as adding users, installing packages, and updating server configurations) based on a centralized specification.
❯ diff <(gem specification puppet-7.30.0-universal-darwin.gem) <(gem specification puppet-7.31.0-universal-darwin.gem)
4c4
<   version: 7.30.0
---
>   version: 7.31.0
11c11
< date: 2024-04-09 00:00:00.000000000 Z
---
> date: 2012-08-17 00:00:00.000000000 Z
185c185,187
< description: Puppet, an automated configuration management tool
---
> description: |
>   Puppet, an automated administrative engine for your Linux, Unix, and Windows systems, performs administrative tasks
>   (such as adding users, installing packages, and updating server configurations) based on a centralized specification.
❯ diff <(gem specification puppet-7.30.0-x64-mingw32.gem) <(gem specification puppet-7.31.0-x64-mingw32.gem)
4c4
<   version: 7.30.0
---
>   version: 7.31.0
11c11
< date: 2024-04-09 00:00:00.000000000 Z
---
> date: 2012-08-17 00:00:00.000000000 Z
199c199,201
< description: Puppet, an automated configuration management tool
---
> description: |
>   Puppet, an automated administrative engine for your Linux, Unix, and Windows systems, performs administrative tasks
>   (such as adding users, installing packages, and updating server configurations) based on a centralized specification.
❯ diff <(gem specification puppet-7.30.0-x86-mingw32.gem) <(gem specification puppet-7.31.0-x86-mingw32.gem)
4c4
<   version: 7.30.0
---
>   version: 7.31.0
11c11
< date: 2024-04-09 00:00:00.000000000 Z
---
> date: 2012-08-17 00:00:00.000000000 Z
199c199,201
< description: Puppet, an automated configuration management tool
---
> description: |
>   Puppet, an automated administrative engine for your Linux, Unix, and Windows systems, performs administrative tasks
>   (such as adding users, installing packages, and updating server configurations) based on a centralized specification.

@AriaXLi
Copy link
Contributor Author

AriaXLi commented May 9, 2024

Rake task works too!

❯ bundle exec rake pl_ci:gem_build

  Successfully built RubyGem
  Name: puppet
  Version: 7.31.0
  File: puppet-7.31.0-x86-mingw32.gem
  Successfully built RubyGem
  Name: puppet
  Version: 7.31.0
  File: puppet-7.31.0-x64-mingw32.gem
  Successfully built RubyGem
  Name: puppet
  Version: 7.31.0
  File: puppet-7.31.0-universal-darwin.gem
  Successfully built RubyGem
  Name: puppet
  Version: 7.31.0
  File: puppet-7.31.0.gem

@AriaXLi AriaXLi marked this pull request as ready for review May 9, 2024 00:05
@AriaXLi AriaXLi requested a review from a team as a code owner May 9, 2024 00:05
@AriaXLi AriaXLi added the enhancement New feature or request label May 9, 2024
@joshcooper joshcooper merged commit 401c7a3 into puppetlabs:7.x May 9, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants