-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Expand file tree
/
Copy pathrust.rake
More file actions
59 lines (50 loc) · 1.94 KB
/
rust.rake
File metadata and controls
59 lines (50 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true
def rust_version
File.foreach('rust/BUILD.bazel') do |line|
return line.split('=').last.strip.tr('",', '') if line.include?('version =')
end
end
desc 'Build Selenium Manager'
task :build do |_task, arguments|
args = arguments.to_a
Bazel.execute('build', args, '//rust:selenium-manager')
end
desc 'Update the rust lock files'
task :update do
puts 'pinning cargo versions'
ENV['CARGO_BAZEL_REPIN'] = 'true'
Bazel.execute('fetch', [], '@crates//:all')
end
desc 'Pin Rust dependencies'
task pin: :update
desc 'Run Rust linting'
task :lint do |_task, arguments|
args = arguments.to_a
puts ' Running rustfmt...'
Bazel.execute('run', args, '@rules_rust//:rustfmt')
end
desc 'Update Rust changelog'
task :changelogs do
header = "#{rust_version}\n======"
version = rust_version.split('.').tap(&:shift).join('.')
SeleniumRake.update_changelog(version, 'rust', 'rust/src', 'rust/CHANGELOG.md', header)
end
# Rust versioning is currently difficult compared to the others because we are using the 0.4.x pattern
# until Selenium Manager comes out of beta
desc 'Update Rust version'
task :version, [:version] do |_task, arguments|
old_version = rust_version.dup
equivalent_version = if old_version.include?('nightly')
"#{old_version.split(/\.|-/)[0...-1].tap(&:shift).join('.')}.0-nightly"
else
old_version.split('.').tap(&:shift).append('0').join('.')
end
updated = SeleniumRake.updated_version(equivalent_version, arguments[:version], '-nightly')
new_version = updated.split(/\.|-/).tap { |v| v.delete_at(2) }.unshift('0').join('.').gsub('.nightly', '-nightly')
puts "Updating Rust from #{old_version} to #{new_version}"
['rust/Cargo.toml', 'rust/BUILD.bazel'].each do |file|
text = File.read(file).gsub(old_version, new_version)
File.open(file, 'w') { |f| f.puts text }
end
Rake::Task['rust:update'].invoke
end