Skip to content

Commit d25b215

Browse files
authored
[build] dependency changes should run CI tests for given binding (#17534)
* [build] dependency changes should run CI tests for given binding * [build] filter overridden targets from index results instead of files
1 parent 751ec74 commit d25b215

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

rake_tasks/bazel.rake

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,18 @@
33
require 'json'
44
require 'set'
55

6-
# Dirs that affect all bindings - changes here trigger "run all tests"
7-
HIGH_IMPACT_DIRS = %w[common rust/src javascript/atoms javascript/webdriver/atoms].freeze
8-
HIGH_IMPACT_PATTERN = %r{\A(?:#{HIGH_IMPACT_DIRS.map { |d| Regexp.escape(d) }.join('|')})(?:/|$)}
6+
# Paths that affect every binding - changes here trigger "run all tests"
7+
HIGH_IMPACT_PATHS = %w[common rust/src javascript/atoms javascript/webdriver/atoms MODULE.bazel].freeze
8+
HIGH_IMPACT_PATTERN = %r{\A(?:#{HIGH_IMPACT_PATHS.map { |p| Regexp.escape(p) }.join('|')})(?:/|$)}
9+
10+
# Binding overrides for files the index can't reach (workspace dep files, root configs)
11+
TARGET_OVERRIDES = {
12+
'dotnet/paket.lock' => 'dotnet',
13+
'java/maven_install.json' => 'java',
14+
'py/requirements_lock.txt' => 'py',
15+
'rb/Gemfile.lock' => 'rb',
16+
'javascript/selenium-webdriver/package.json' => 'javascript'
17+
}.freeze
918

1019
# ./go bazel:affected_targets --> HEAD^..HEAD with default index
1120
# ./go bazel:affected_targets abc123..def456 --> explicit range
@@ -34,7 +43,10 @@ task :affected_targets do |_task, args|
3443
targets = if changed_files.any? { |f| f.match?(HIGH_IMPACT_PATTERN) }
3544
BINDING_TARGETS.values
3645
elsif File.exist?(index_file)
37-
affected_targets_with_index(changed_files, index_file)
46+
override_targets = changed_files.filter_map { |f| BINDING_TARGETS[TARGET_OVERRIDES[f]] }
47+
covered_pattern = Regexp.union(override_targets.map { |t| %r{\A#{Regexp.escape(t.delete_suffix('/...'))}[:/]} })
48+
index_targets = affected_targets_with_index(changed_files, index_file).grep_v(covered_pattern)
49+
(override_targets + index_targets).uniq
3850
else
3951
puts 'No index found, using directory-based fallback'
4052
affected_targets_by_directory(changed_files)
@@ -98,8 +110,8 @@ def query_test_deps(test)
98110
deps = out.lines.map(&:strip).select { |l| l.start_with?('//') }
99111
end
100112
deps.reject do |d|
101-
# Skip high-impact dirs and root package targets (generated files, LICENSE, etc)
102-
HIGH_IMPACT_DIRS.any? { |dir| d.start_with?("//#{dir}") } || d.start_with?('//:')
113+
# Skip high-impact paths and root package targets (generated files, LICENSE, etc)
114+
HIGH_IMPACT_PATHS.any? { |path| d.start_with?("//#{path}") } || d.start_with?('//:')
103115
end
104116
rescue StandardError => e
105117
puts " Warning: Failed to query deps for #{test}: #{e.message}"

0 commit comments

Comments
 (0)