This repository has been archived by the owner on Dec 8, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
go
executable file
·139 lines (110 loc) · 3.12 KB
/
go
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#! /usr/bin/env ruby
require 'English'
Dir.chdir File.dirname(__FILE__)
def try_command_and_restart(command)
exit $CHILD_STATUS.exitstatus unless system command
exec RbConfig.ruby, *[$PROGRAM_NAME].concat(ARGV)
end
begin
require 'bundler/setup' if File.exist? 'Gemfile'
rescue LoadError
try_command_and_restart 'gem install bundler'
rescue SystemExit
try_command_and_restart 'bundle install'
end
begin
require 'go_script'
rescue LoadError
try_command_and_restart 'gem install go_script'
end
extend GoScript
check_ruby_version '2.1.5'
command_group :dev, 'Development commands'
def_command :init, 'Initialize private submodules (18F members only)' do
exec_cmd 'git submodule update --init'
end
def_command :update_gems, 'Update Ruby gems' do |gems = []|
update_gems gems
end
def_command :update_js, 'Update JavaScript components' do
update_node_modules
exec_cmd 'gulp vendorize'
end
def_command :test, 'Execute automated tests' do |args = []|
exec_cmd "bundle exec rake test #{args.join ' '}"
end
JEKYLL_PUBLIC_CONFIG = %w(--config _config.yml,_config_public.yml)
def_command :serve, 'Serves the internal hub at localhost:4000' do |args|
serve_jekyll args
end
def_command(
:serve_public, 'Serves the public hub at localhost:4000/hub') do |args|
serve_jekyll args.concat(JEKYLL_PUBLIC_CONFIG)
end
PROOFER_OPTS = {
disable_external: true, # might want to re-enable this eventually
file_ignore: [
%r{/snippets/} # not worth fixing, for now
].freeze,
url_ignore: [
'/hub/oauth2/sign_in'
].freeze
}.freeze
def_command(
:validate_public,
'Validate no internal links are broken on the public build') do
require 'html/proofer'
opts = PROOFER_OPTS.dup
opts[:file_ignore] += [
'./_site_public/hub/api/index.html'
]
opts[:url_ignore] += [
%r{/private/}
]
HTML::Proofer.new('./_site_public', opts).run
end
def_command(
:validate_private,
'Validate no internal links are broken on the private build') do
require 'html/proofer'
HTML::Proofer.new('./_site', PROOFER_OPTS.dup).run
end
def_command :validate, 'Build, then validate no internal links are broken' do
build
validate_public
validate_private
end
def_command(
:build, 'Builds the internal and external versions of the Hub') do |args = []|
puts 'Building internal version...'
build_jekyll args
puts 'Building public version...'
build_jekyll args.concat(JEKYLL_PUBLIC_CONFIG)
end
def_command :ci_build, 'Runs tests and builds both Hub versions' do
test
build []
validate_public
end
command_group :deploy, 'Automated deployment commands used by deploy/fabfile.py'
def deploy(commands = [])
git_sync_and_deploy ['git submodule update --remote'].concat(commands)
end
def_command :deploy_submodules, 'Commits automated submodule updates' do
deploy([
'ruby _data/import-public.rb',
'git add .',
'git commit -m \'Private submodule update\'',
'git push',
])
end
def_command(
:deploy_internal, 'Deploys the internal and staging Hub instances') do
deploy
build
end
def_command :deploy_public, 'Deploys the public Hub instance' do
deploy
build_jekyll JEKYLL_PUBLIC_CONFIG
end
execute_command ARGV