This repository has been archived by the owner on Mar 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRakefile
87 lines (71 loc) · 1.81 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
require 'date'
require 'digest/md5'
require 'fileutils'
require 'json'
basedir = "."
build = "#{basedir}/build"
source = "#{basedir}/src/ImboClientCli"
logs = "#{build}/logs"
desc "Task used by Jenkins-CI"
task :jenkins => [:prepare, :lint, :cs_ci, :test]
desc "Default task"
task :default => [:prepare, :lint, :cs, :test, :readthedocs]
desc "Clean up and create artifact directories"
task :prepare do
FileUtils.rm_rf build
FileUtils.mkdir build
["coverage", "logs", "docs"].each do |d|
FileUtils.mkdir "#{build}/#{d}"
end
end
desc "Spell check and generate end user docs"
task :readthedocs do
wd = Dir.getwd
Dir.chdir("docs")
begin
sh %{make spelling}
rescue Exception
puts "Spelling error in the docs, aborting"
exit 1
end
puts "No spelling errors. Generate docs"
sh %{make html}
Dir.chdir(wd)
end
desc "Check syntax on all php files in the project"
task :lint do
lintCache = "#{basedir}/.lintcache"
begin
sums = JSON.parse(IO.read(lintCache))
rescue Exception => foo
sums = {}
end
`git ls-files "*.php"`.split("\n").each do |f|
f = File.absolute_path(f)
md5 = Digest::MD5.hexdigest(File.read(f))
next if sums[f] == md5
sums[f] = md5
begin
sh %{php -l #{f}}
rescue Exception
exit 1
end
end
IO.write(lintCache, JSON.dump(sums))
end
desc "Run tests"
task :test do
begin
sh %{vendor/bin/phpunit --verbose -c tests --coverage-html build/coverage --coverage-clover build/logs/clover.xml --log-junit build/logs/junit.xml}
rescue Exception
exit 1
end
end
desc "Check coding standard"
task :cs do
system "phpcs --standard=Imbo #{source}"
end
desc "Check coding standard and generate checkstyle logs"
task :cs_ci do
system "phpcs --report=checkstyle --report-file=#{logs}/checkstyle.xml --standard=Imbo #{source}"
end