Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/support/rbs_collection_update.rb
4004 views
1
# frozen_string_literal: true
2
3
# Licensed to the Software Freedom Conservancy (SFC) under one
4
# or more contributor license agreements. See the NOTICE file
5
# distributed with this work for additional information
6
# regarding copyright ownership. The SFC licenses this file
7
# to you under the Apache License, Version 2.0 (the
8
# "License"); you may not use this file except in compliance
9
# with the License. You may obtain a copy of the License at
10
#
11
# http://www.apache.org/licenses/LICENSE-2.0
12
#
13
# Unless required by applicable law or agreed to in writing,
14
# software distributed under the License is distributed on an
15
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
# KIND, either express or implied. See the License for the
17
# specific language governing permissions and limitations
18
# under the License.
19
20
require "rbconfig"
21
22
# Find the rb directory - try multiple strategies for different Bazel contexts
23
root = if ENV['BUILD_WORKSPACE_DIRECTORY']
24
# bazel run sets this to the workspace root
25
File.join(ENV['BUILD_WORKSPACE_DIRECTORY'], 'rb')
26
elsif ENV['BUILD_WORKING_DIRECTORY']
27
# Alternative for some bazel run scenarios
28
rb_path = File.join(ENV['BUILD_WORKING_DIRECTORY'], 'rb')
29
File.exist?(rb_path) ? rb_path : File.expand_path("../..", __dir__)
30
else
31
# Direct execution or other scenarios - find rb relative to script
32
script_dir = File.expand_path(__dir__)
33
if script_dir.include?('runfiles')
34
# In bazel test, try to find the actual workspace
35
# Look for the workspace by finding where Gemfile exists
36
workspace = script_dir.split('runfiles').first.sub(%r{/bazel-out/.*}, '')
37
File.join(workspace, 'rb')
38
else
39
File.expand_path("../..", __dir__)
40
end
41
end
42
43
Dir.chdir(root)
44
45
ruby = RbConfig.ruby
46
47
# Run rbs collection update
48
system(ruby, "-S", "rbs", "collection", "update", *ARGV) || exit(1)
49
50
# Fix the gemfile_lock_path to be relative (rbs writes absolute paths when run via bazel)
51
lockfile = File.join(root, "rbs_collection.lock.yaml")
52
content = File.read(lockfile)
53
content.gsub!(/^gemfile_lock_path:.*$/, 'gemfile_lock_path: Gemfile.lock')
54
File.write(lockfile, content)
55
56
puts "Updated rbs_collection.lock.yaml with fixed gemfile_lock_path"
57
58