forked from alphagov/govuk-developer-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
99 lines (84 loc) · 2.89 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require "govuk_tech_docs"
require "rspec/core/rake_task"
require_relative "./app/requires"
RSpec::Core::RakeTask.new(:spec)
desc "Run RuboCop"
task :lint, :environment do
sh "bundle exec rubocop"
end
desc "Run Markdownlint"
task :lint_markdown, :environment do
sh "bundle exec mdl --ignore-front-matter --show-aliases source"
end
namespace :cache do
desc "Clear the cache of external content"
task :clear do
CACHE.clear
end
end
namespace :assets do
desc "Build the static site"
task :precompile do
sh "rm -rf /tmp/govuk-content-schemas; git clone https://github.com/alphagov/govuk-content-schemas.git /tmp/govuk-content-schemas --depth=1 && NO_CONTRACTS=true GOVUK_CONTENT_SCHEMAS_PATH=/tmp/govuk-content-schemas middleman build"
end
end
desc "Find deployable applications that are not in this repo"
task :verify_deployable_apps do
common_yaml = suppress_output do
HTTP.get_yaml("https://raw.githubusercontent.com/alphagov/govuk-puppet/master/hieradata/common.yaml")
end
deployable_applications = common_yaml["deployable_applications"].map { |k, v| v["repository"] || k }
our_applications = Applications.all.map(&:github_repo_name)
intentionally_missing =
%w[
backdrop
spotlight
stagecraft
performanceplatform-admin
performanceplatform-big-screen-view
EFG
govuk-cdn-logs-monitor
govuk-content-schemas
govuk_crawler_worker
smokey
kibana-gds
sidekiq-monitoring
]
missing_apps = (deployable_applications - (our_applications + intentionally_missing)).uniq
if missing_apps.count.zero?
puts "No deployable apps missing from applications.yml ✅"
else
errors = missing_apps.map { |missing_app| "\n\t #{missing_app}" }
abort("The following deployable apps are missing from applications.yml: #{errors.join('')}")
end
end
desc "Check all puppet names are valid, will error when not"
task :check_puppet_names do
puts "Checking Puppet manifests..."
invalid_puppet_names = []
Applications.active.each do |app|
suppress_output { HTTP.get(app.puppet_url) unless app.puppet_url.nil? }
rescue Octokit::NotFound
invalid_puppet_names << app.puppet_url
end
if invalid_puppet_names.count.zero?
puts "All AWS/Carrenza apps have a valid puppet manifest ✅"
else
errors = invalid_puppet_names.map { |url| "\n\t #{url}" }
abort("Expected the following puppet manifests to exist: #{errors.join('')}")
end
end
desc "Clear out and rebuild the build/ folder"
task build: %i[cache:clear assets:precompile]
task default: %i[verify_deployable_apps lint lint_markdown spec check_puppet_names build]
# https://gist.github.com/moertel/11091573
def suppress_output
original_stderr = $stderr.clone
original_stdout = $stdout.clone
$stderr.reopen(File.new("/dev/null", "w"))
$stdout.reopen(File.new("/dev/null", "w"))
yield
ensure
$stdout.reopen(original_stdout)
$stderr.reopen(original_stderr)
end