forked from up1/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
94 lines (82 loc) · 2.43 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
require 'fileutils'
require 'html-proofer'
IMAGE_NAME = 'codeship/documentation'
desc "Build the #{IMAGE_NAME} image"
task :build do
sh "docker build --tag #{IMAGE_NAME} ."
end
desc 'Run the development server'
task :serve do
sh "docker run -it --rm -p 4000:4000 -v $(pwd):/docs #{IMAGE_NAME}"
end
namespace :serve do
desc "Serve a local site (from the ./tmp/site/ directory, which is populated by `jet steps`) via nginx"
task :local do
sh "docker run -it --rm -p 4000:80 -v $(pwd)/tmp/site:/usr/share/nginx/html:ro nginx:alpine"
end
end
desc 'Run tests'
task :test do
sh "jet steps"
end
desc 'Run arbitrary commands in the Docker container'
task :run, [:command ] do |t, args|
sh "docker run -it --rm -p 4000:4000 -v $(pwd):/docs #{IMAGE_NAME} #{args.command}"
end
desc 'Update Ruby and NodeJS based dependencies'
task update: %w[update:image build update:rubygems update:yarn]
namespace :update do
desc 'Update the base image'
task :image do
File.foreach('Dockerfile'){ |line|
next unless line.start_with? 'FROM'
image = line.split(' ')[1]
sh "docker pull #{image}"
}
end
desc 'Update Ruby based dependencies'
task :rubygems do
sh "docker run -it --rm -v $(pwd):/docs #{IMAGE_NAME} bundle lock --update"
end
desc 'Update NodeJS based dependencies'
task :yarn do
sh "docker run -it --rm -v $(pwd):/docs #{IMAGE_NAME} yarn upgrade"
end
end
desc "Run Linters"
task lint: %w[lint:scss lint:json lint:jekyll]
namespace :lint do
desc 'Run SCSS linter'
task :scss do
sh "docker run -it --rm -v $(pwd):/docs #{IMAGE_NAME} bundle exec scss-lint"
end
desc 'Run JSON linter'
task :json do
sh "docker run -it --rm -v $(pwd):/docs #{IMAGE_NAME} gulp lint"
end
desc 'Run Jekyll configuration linter'
task :jekyll do
sh "docker run -it --rm -v $(pwd):/docs #{IMAGE_NAME} bundle exec jekyll doctor"
end
end
desc 'Run HTMLProofer'
task :htmlproofer do
options = {
:assume_extension => true,
:check_html => true,
:check_favicon => true,
:allow_hash_href => true,
:empty_alt_ignore => true,
:typhoeus => {
:ssl_verifypeer => false,
},
:http_status_ignore => [999],
:file_ignore => [/google1a85968316265362.html/],
:url_ignore => [/guide.blazemeter.com/, /lftp.yar.ru/, /nip.io/, /twitter.com/, /xip.io/],
:url_swap => {
'https://documentation.codeship.com' => '',
}
}
HTMLProofer.check_directory("/site/htmlproofer", options).run
FileUtils.rm_rf("/site/htmlproofer")
end