File tree Expand file tree Collapse file tree 4 files changed +53
-6
lines changed Expand file tree Collapse file tree 4 files changed +53
-6
lines changed Original file line number Diff line number Diff line change 1212 with :
1313 # This line enables shellcheck to be run on this repository
1414 run_shellcheck : true
15+ ruby_version : ' 3.1'
1516 secrets : " inherit"
Original file line number Diff line number Diff line change @@ -52,13 +52,20 @@ facter_version = ENV['FACTER_GEM_VERSION']
5252hiera_version = ENV [ 'HIERA_GEM_VERSION' ]
5353
5454gems = { }
55+ puppet_version = ENV . fetch ( 'PUPPET_GEM_VERSION' , nil )
56+ facter_version = ENV . fetch ( 'FACTER_GEM_VERSION' , nil )
57+ hiera_version = ENV . fetch ( 'HIERA_GEM_VERSION' , nil )
5558
56- gems [ 'puppet' ] = location_for ( puppet_version )
57-
58- # If facter or hiera versions have been specified via the environment
59- # variables
59+ # If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet
60+ # Otherwise, do as before and use location_for to fetch gems from the default source
61+ if !ENV [ 'PUPPET_FORGE_TOKEN' ] . to_s . empty?
62+ gems [ 'puppet' ] = [ '~> 8.11' , { require : false , source : 'https://rubygems-puppetcore.puppet.com' } ]
63+ gems [ 'facter' ] = [ '~> 4.11' , { require : false , source : 'https://rubygems-puppetcore.puppet.com' } ]
64+ else
65+ gems [ 'puppet' ] = location_for ( puppet_version )
66+ gems [ 'facter' ] = location_for ( facter_version ) if facter_version
67+ end
6068
61- gems [ 'facter' ] = location_for ( facter_version ) if facter_version
6269gems [ 'hiera' ] = location_for ( hiera_version ) if hiera_version
6370
6471gems . each do |gem_name , gem_params |
Original file line number Diff line number Diff line change 6767 "requirements" : [
6868 {
6969 "name" : " puppet" ,
70- "version_requirement" : " >= 7 .0.0 < 9.0.0"
70+ "version_requirement" : " >= 8 .0.0 < 9.0.0"
7171 }
7272 ],
7373 "pdk-version" : " 3.0.1" ,
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require 'spec_helper'
4+ require 'bundler'
5+
6+ RSpec . describe 'Gemfile.lock verification' do
7+ let ( :parser ) { Bundler ::LockfileParser . new ( Bundler . read_file ( Bundler . default_lockfile ) ) }
8+ let ( :private_source ) { 'https://rubygems-puppetcore.puppet.com/' }
9+
10+ # Helper method to get source remotes for a specific gem
11+ def get_gem_source_remotes ( gem_name )
12+ spec = parser . specs . find { |s | s . name == gem_name }
13+ return [ ] unless spec
14+
15+ source = spec . source
16+ return [ ] unless source . is_a? ( Bundler ::Source ::Rubygems )
17+
18+ source . remotes . map ( &:to_s )
19+ end
20+
21+ context 'when the environment is configured with a valid PUPPET_FORGE_TOKEN' do
22+ it 'returns puppet from puppetcore' do
23+ remotes = get_gem_source_remotes ( 'puppet' )
24+ expect ( remotes ) . to eq ( [ private_source ] ) ,
25+ "Expected puppet to come from puppetcore, got: #{ remotes . join ( ', ' ) } "
26+ end
27+
28+ it 'returns facter from puppetcore' do
29+ remotes = get_gem_source_remotes ( 'facter' )
30+ expect ( remotes ) . to eq ( [ private_source ] ) ,
31+ "Expected facter to come from puppetcore, got: #{ remotes . join ( ', ' ) } "
32+ end
33+
34+ it 'has PUPPET_FORGE_TOKEN set' do
35+ expect ( ENV . fetch ( 'PUPPET_FORGE_TOKEN' , nil ) ) . not_to be_nil ,
36+ 'Expected PUPPET_FORGE_TOKEN to be set'
37+ end
38+ end
39+ end
You can’t perform that action at this time.
0 commit comments