Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/support/steep_check.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
require "fileutils"
22
require "open3"
23
24
# Find the rb directory - try multiple strategies for different Bazel contexts
25
root = if ENV['BUILD_WORKSPACE_DIRECTORY']
26
# bazel run sets this to the workspace root
27
File.join(ENV['BUILD_WORKSPACE_DIRECTORY'], 'rb')
28
elsif ENV['BUILD_WORKING_DIRECTORY']
29
# Alternative for some bazel run scenarios
30
rb_path = File.join(ENV['BUILD_WORKING_DIRECTORY'], 'rb')
31
File.exist?(rb_path) ? rb_path : File.expand_path("../..", __dir__)
32
else
33
# Direct execution or other scenarios - find rb relative to script
34
script_dir = File.expand_path(__dir__)
35
if script_dir.include?('runfiles')
36
# In bazel test, try to find the actual workspace
37
# Look for the workspace by finding where Gemfile exists
38
workspace = script_dir.split('runfiles').first.sub(%r{/bazel-out/.*}, '')
39
File.join(workspace, 'rb')
40
else
41
File.expand_path("../..", __dir__)
42
end
43
end
44
45
Dir.chdir(root)
46
47
ruby = RbConfig.ruby
48
49
# Clear GIT_DIR to prevent it from interfering with RBS collection git operations
50
# (e.g., when running via git pre-push hook which sets GIT_DIR)
51
ENV.delete('GIT_DIR')
52
53
# Install RBS collection from lockfile (--frozen skips Gemfile.lock validation)
54
system(ruby, "-S", "rbs", "collection", "install", "--frozen") || exit(1)
55
56
# Run steep check, discarding stderr (internal Steep logs, not type errors)
57
cmd = [ruby, "-S", "steep", "check", "--severity-level=error", *ARGV]
58
stdout, status = Open3.capture2(*cmd, err: File::NULL)
59
60
print stdout
61
exit status.exitstatus
62
63