-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
73 lines (55 loc) · 1.59 KB
/
Rakefile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# frozen_string_literal: true
require 'open-uri'
require 'shellwords'
require 'bundler/audit/task'
require 'rubocop/rake_task'
task default: %i[format lint]
desc 'Lint sources'
task lint: %i[lint:rubocop:autocorrect]
namespace :lint do
RuboCop::RakeTask.new(:rubocop)
end
desc 'Format sources'
task format: %i[format:text]
namespace :format do
desc 'Format text, YAML, and Markdown sources with prettier'
task :text do
sh 'npm run fmt'
end
end
desc 'Format sources'
task fmt: %i[fmt:text]
namespace :fmt do
desc 'Format text, YAML, and Markdown sources with prettier'
task :text do
sh 'npm run fmt'
end
end
Bundler::Audit::Task.new
RUST_VERSION = '1.83.0'
namespace :toolchain do
desc 'Sync Rust toolchain to all sources'
task sync: %i[sync:dockerfiles]
namespace :sync do
desc 'Sync the Rust toolchain to all Dockerfiles'
task :dockerfiles do
regexp = /^ARG RUST_VERSION=(.+)$/
next_rust_version = "ARG RUST_VERSION=#{RUST_VERSION}"
dockerfiles = FileList.new('**/Dockerfile')
failures = dockerfiles.map do |file|
contents = File.read(file)
if (existing_version = contents.match(regexp))
File.write(file, contents.gsub(regexp, next_rust_version)) if existing_version != RUST_VERSION
next
end
puts "Failed to update #{file}, ensure there is a RUST_VERSION arg specified" if Rake.verbose
file
end.compact
raise 'Failed to update some RUST_VERSION args' if failures.any?
end
end
desc 'Output the current toolchain version'
task :version do
puts RUST_VERSION
end
end