@invarn/cibuild 2.8.7 → 2.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -55,6 +55,9 @@ const run = async (opts) => {
55
55
  if (opts.lock !== undefined)
56
56
  writeFileSync(join(project, 'Gemfile.lock'), opts.lock);
57
57
  writeFileSync(join(project, 'Gemfile'), opts.gemfile ?? "gem 'cocoapods'\n");
58
+ if (opts.rubyVersionFile !== undefined) {
59
+ writeFileSync(join(project, '.ruby-version'), opts.rubyVersionFile);
60
+ }
58
61
  const installed = (opts.installed ?? []).join(' ');
59
62
  executable(join(bin, 'gem'), `echo "gem $*" >> '${log}'
60
63
  if [ "$1" = "list" ]; then
@@ -134,12 +137,71 @@ describe('cocoapods-install runs the bundler Gemfile.lock names', () => {
134
137
  expect(output).toContain('BUNDLED WITH');
135
138
  expect(output).toMatch(/EXIT [1-9]/);
136
139
  });
137
- // Homebrew's ruby is keg-only, so a guest whose CocoaPods and fastlane came
138
- // from Homebrew has it installed and still resolves `ruby` to the system 2.6.
139
- test('prefers an installed Homebrew Ruby over system Ruby', async () => {
140
- const { calls } = await run({ lock: LOCK_WITH_BUNDLER, brewRuby: true });
141
- expect(calls.some((c) => c.startsWith('brew-ruby'))).toBe(true);
142
- expect(calls.some((c) => c.startsWith('ruby '))).toBe(false);
140
+ });
141
+ // Issue 08 preferred Homebrew's Ruby whenever it was installed. On the mac
142
+ // image that is Ruby 4, and an old lockfile's gems do not load there: rake
143
+ // 13.0.6 requires `ostruct`, which stopped being a default gem in Ruby 4.0,
144
+ // so a native-extension build died inside rake. The lockfile decides instead:
145
+ // its `RUBY VERSION`, then `.ruby-version`, and system Ruby when neither names
146
+ // one. Homebrew's Ruby only when the named Ruby is 3 or newer.
147
+ describe('cocoapods-install runs the Ruby the project names', () => {
148
+ const usedBrew = (calls) => calls.some((c) => c.startsWith('brew-ruby'));
149
+ const usedSystem = (calls) => calls.some((c) => c.startsWith('ruby '));
150
+ const lockWithRuby = (v) => LOCK_WITH_BUNDLER.replace('BUNDLED WITH', `RUBY VERSION\n ruby ${v}\n\nBUNDLED WITH`);
151
+ test('a lock that names no Ruby runs system Ruby, with the locked bundler', async () => {
152
+ const { calls, output, gemHome } = await run({ lock: LOCK_WITH_BUNDLER, brewRuby: true });
153
+ expect(usedSystem(calls)).toBe(true);
154
+ expect(usedBrew(calls)).toBe(false);
155
+ expect(calls).toContain('gem install bundler -v 2.3.21 --no-document');
156
+ expect(calls.find((c) => c.startsWith('bundle _2.3.21_ install'))).toContain(`GEM_HOME=${gemHome}`);
157
+ expect(output).toMatch(/^Ruby: .*\(2\.6\.10\), GEM_HOME: .* — system: lockfile names no Ruby$/m);
158
+ });
159
+ test('a lock whose RUBY VERSION is 3 or newer runs Homebrew Ruby', async () => {
160
+ const { calls, output } = await run({ lock: lockWithRuby('3.3.4p94'), brewRuby: true });
161
+ expect(usedBrew(calls)).toBe(true);
162
+ expect(usedSystem(calls)).toBe(false);
163
+ expect(output).toMatch(/^Ruby: .*homebrew-ruby\/bin\/ruby \(3\.4\.1\), .* — from Gemfile\.lock RUBY VERSION 3\.3\.4$/m);
164
+ });
165
+ test('a lock whose RUBY VERSION is 2.x runs system Ruby', async () => {
166
+ const { calls, output } = await run({ lock: lockWithRuby('2.7.2p137'), brewRuby: true });
167
+ expect(usedBrew(calls)).toBe(false);
168
+ expect(output).toContain('— from Gemfile.lock RUBY VERSION 2.7.2');
169
+ });
170
+ test('the lock outranks .ruby-version', async () => {
171
+ const { calls, output } = await run({
172
+ lock: lockWithRuby('3.3.4p94'),
173
+ rubyVersionFile: '2.7.6\n',
174
+ brewRuby: true,
175
+ });
176
+ expect(usedBrew(calls)).toBe(true);
177
+ expect(output).toContain('— from Gemfile.lock RUBY VERSION 3.3.4');
178
+ });
179
+ test('.ruby-version of 3 or newer runs Homebrew Ruby when the lock names none', async () => {
180
+ const { calls, output } = await run({ lock: LOCK_WITH_BUNDLER, rubyVersionFile: 'ruby-3.2.2\n', brewRuby: true });
181
+ expect(usedBrew(calls)).toBe(true);
182
+ expect(output).toContain('— from .ruby-version 3.2.2');
183
+ });
184
+ test('.ruby-version of 2.7 runs system Ruby, and says so', async () => {
185
+ const { calls, output } = await run({ lock: LOCK_WITH_BUNDLER, rubyVersionFile: '2.7.6\n', brewRuby: true });
186
+ expect(usedBrew(calls)).toBe(false);
187
+ expect(usedSystem(calls)).toBe(true);
188
+ expect(output).toContain('— from .ruby-version 2.7.6');
189
+ });
190
+ test('a .ruby-version that names no version is ignored', async () => {
191
+ const { calls, output } = await run({ lock: LOCK_WITH_BUNDLER, rubyVersionFile: 'system\n', brewRuby: true });
192
+ expect(usedBrew(calls)).toBe(false);
193
+ expect(output).toContain('— system: lockfile names no Ruby');
194
+ });
195
+ test('Ruby 3 named, no Homebrew Ruby installed: system Ruby, and says so', async () => {
196
+ const { calls, output } = await run({ lock: lockWithRuby('3.3.4p94') });
197
+ expect(usedSystem(calls)).toBe(true);
198
+ expect(output).toContain('— from Gemfile.lock RUBY VERSION 3.3.4, but no Homebrew Ruby is installed');
199
+ });
200
+ test('a project without cocoapods in its Gemfile never picks a Ruby', async () => {
201
+ const { calls } = await run({ gemfile: "gem 'fastlane'\n", rubyVersionFile: '3.3.0\n', brewRuby: true });
202
+ expect(calls).toContain('pod install');
203
+ expect(usedBrew(calls)).toBe(false);
204
+ expect(usedSystem(calls)).toBe(false);
143
205
  });
144
206
  });
145
207
  //# sourceMappingURL=cocoapods-locked-bundler.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios-deps.d.ts","sourceRoot":"","sources":["../../../../src/yaml/steps/ios-deps.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,qBAAqB,EAAc,MAAM,wBAAwB,CAAC;AAMhF,MAAM,W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mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6BAA6B;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,gBAAgB;IACxD,yBAAyB,CACvB,OAAO,EAAE,cAAc,EACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,OAAO,EAAE,QAAQ,GAChB,qBAAqB,EAAE;IAUpB,OAAO,CACX,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,OAAO,EAAE,QAAQ,GAChB,OAAO,CAAC,OAAO,CAAC;CAyDpB"}
@@ -83,9 +83,14 @@ export class CocoapodsInstallStepExecutor extends BaseStepExecutor {
83
83
  //
84
84
  // Three moves, each conditional, so a machine missing a piece keeps the
85
85
  // old behaviour rather than failing on it:
86
- // - prefer an installed Homebrew Ruby. It is keg-only, so it is not on
87
- // PATH even where it is installed (Homebrew's cocoapods and fastlane
88
- // formulae depend on it), and the system 2.6 wins by default;
86
+ // - run the Ruby the project names: Gemfile.lock's `RUBY VERSION`, then
87
+ // `.ruby-version`. Only a named Ruby 3 or newer moves to Homebrew's
88
+ // Ruby, which is keg-only, so not on PATH even where it is installed
89
+ // (Homebrew's cocoapods and fastlane formulae depend on it). Anything
90
+ // else, including a project that names none, stays on system Ruby 2.6.
91
+ // Homebrew's is Ruby 4 on the mac image, and an old lockfile's gems do
92
+ // not load there — rake 13.0.6 requires `ostruct`, no longer a default
93
+ // gem — so "newest installed" is the wrong default;
89
94
  // - point GEM_HOME at a writable directory outside the checkout, so both
90
95
  // `gem install bundler` and `bundle install` can write without sudo,
91
96
  // and put its bin directory first;
@@ -93,10 +98,34 @@ export class CocoapodsInstallStepExecutor extends BaseStepExecutor {
93
98
  // `bundle _<version>_`, which is the form RubyGems accepts.
94
99
  commands.push('BUNDLE_CMD="bundle"');
95
100
  commands.push('if [ "$USE_BUNDLE_EXEC" = "true" ]; then');
96
- commands.push(' if command -v brew &>/dev/null; then');
97
- commands.push(' BREW_RUBY="$(brew --prefix --installed ruby 2>/dev/null || true)"');
98
- commands.push(' if [ -n "$BREW_RUBY" ] && [ -x "$BREW_RUBY/bin/ruby" ]; then');
99
- commands.push(' export PATH="$BREW_RUBY/bin:$PATH"');
101
+ commands.push(' WANTED_RUBY=""');
102
+ commands.push(' WANTED_FROM=""');
103
+ commands.push(' if [ -f "Gemfile.lock" ]; then');
104
+ commands.push(' WANTED_RUBY="$(awk \'/^RUBY VERSION/ { getline; sub(/^[[:space:]]*ruby[[:space:]]+/, ""); sub(/p[0-9]+.*$/, ""); gsub(/[[:space:]]/, ""); print; exit }\' Gemfile.lock)"');
105
+ commands.push(' [ -n "$WANTED_RUBY" ] && WANTED_FROM="Gemfile.lock RUBY VERSION"');
106
+ commands.push(' fi');
107
+ commands.push(' if [ -z "$WANTED_RUBY" ] && [ -f ".ruby-version" ]; then');
108
+ commands.push(' WANTED_RUBY="$(head -n 1 .ruby-version | tr -d \'[:space:]\')"');
109
+ commands.push(' WANTED_RUBY="${WANTED_RUBY#ruby-}"');
110
+ commands.push(' WANTED_FROM=".ruby-version"');
111
+ commands.push(' fi');
112
+ commands.push(' case "${WANTED_RUBY%%.*}" in');
113
+ commands.push(' \'\'|*[!0-9]*) WANTED_RUBY="" ;;');
114
+ commands.push(' esac');
115
+ commands.push(' if [ -z "$WANTED_RUBY" ]; then');
116
+ commands.push(' RUBY_REASON="system: lockfile names no Ruby"');
117
+ commands.push(' else');
118
+ commands.push(' RUBY_REASON="from $WANTED_FROM $WANTED_RUBY"');
119
+ commands.push(' if [ "${WANTED_RUBY%%.*}" -ge 3 ]; then');
120
+ commands.push(' BREW_RUBY=""');
121
+ commands.push(' if command -v brew &>/dev/null; then');
122
+ commands.push(' BREW_RUBY="$(brew --prefix --installed ruby 2>/dev/null || true)"');
123
+ commands.push(' fi');
124
+ commands.push(' if [ -n "$BREW_RUBY" ] && [ -x "$BREW_RUBY/bin/ruby" ]; then');
125
+ commands.push(' export PATH="$BREW_RUBY/bin:$PATH"');
126
+ commands.push(' else');
127
+ commands.push(' RUBY_REASON="$RUBY_REASON, but no Homebrew Ruby is installed"');
128
+ commands.push(' fi');
100
129
  commands.push(' fi');
101
130
  commands.push(' fi');
102
131
  commands.push(' if ! command -v bundle &>/dev/null && ! command -v gem &>/dev/null; then');
@@ -109,7 +138,7 @@ export class CocoapodsInstallStepExecutor extends BaseStepExecutor {
109
138
  commands.push(' mkdir -p "$GEM_HOME"');
110
139
  commands.push(' export PATH="$GEM_HOME/bin:$PATH"');
111
140
  commands.push(' RUBY_VERSION_USED="$(ruby -e \'print RUBY_VERSION\' 2>/dev/null || echo unknown)"');
112
- commands.push(' echo "Ruby: $(command -v ruby || echo none) ($RUBY_VERSION_USED), GEM_HOME: $GEM_HOME"');
141
+ commands.push(' echo "Ruby: $(command -v ruby || echo none) ($RUBY_VERSION_USED), GEM_HOME: $GEM_HOME — $RUBY_REASON"');
113
142
  commands.push(' LOCKED_BUNDLER=""');
114
143
  commands.push(' if [ -f "Gemfile.lock" ]; then');
115
144
  commands.push(' LOCKED_BUNDLER="$(awk \'/^BUNDLED WITH/ { getline; gsub(/[[:space:]]/, ""); print; exit }\' Gemfile.lock)"');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@invarn/cibuild",
3
- "version": "2.8.7",
3
+ "version": "2.8.8",
4
4
  "description": "CI Build CLI — local pipeline orchestration and validation",
5
5
  "type": "module",
6
6
  "main": "dist/cli.cjs",