-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathRakefile
More file actions
159 lines (129 loc) · 4.84 KB
/
Rakefile
File metadata and controls
159 lines (129 loc) · 4.84 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
require "rubygems"
require 'rake'
require 'yaml'
require 'time'
namespace 'travis' do
SOURCE_BRANCH = 'dev'
DEPLOY_BRANCH = 'master'
REPORT_BRANCH = 'report'
VERSION_URL = 'https://pages.github.com/versions.json'
desc 'Test the site'
task :test do
result = 0
if ENV['TRAVIS_BRANCH'] == 'master'
puts "UI Automation tests Serenity-JBehave"
resultS = system("mvn verify -f ./tests/serenity/pom.xml -Denv=local -Dmetafilter=\"-prod -NotImplemented\"")
puts resultS
if (resultS) == false
puts 'test failed'
exit 1
end
next
else
puts "Unit Tests Jest"
puts 'npm install'
system 'npm install'
puts 'npm run test'
resultU = system 'npm run test'
if (resultU) == false
puts 'Unit tests failed'
exit 1
end
next
end
puts 'test final result'
puts result
exit result
end
desc 'Publish site to GitHub Pages from Travis'
task :deploy do
if ENV['TRAVIS_TEST_RESULT'].to_i != 0
puts "Skipping deployment due to test failure"
next
end
if ENV['TRAVIS_PULL_REQUEST'] != "false" or ENV['TRAVIS_BRANCH'] != SOURCE_BRANCH
puts "Skipping deployment from #{ENV['TRAVIS_BRANCH']}"
if ENV['TRAVIS_PULL_REQUEST'] != "false"
puts "This branch is pull request."
end
next
end
repo = %x(git config remote.origin.url).gsub(/^git:/, 'https:')
system "git remote set-url --push origin #{repo}"
system 'git config credential.helper "store --file=.git/credentials"'
File.open('.git/credentials', 'w') do |f|
f.write("https://#{ENV['GH_TOKEN']}:x-oauth-basic@github.com")
end
# Notice: if you want add new directories to build, please do it here:
status_api_expoloer_v2_scriptjs = `git show -m --name-only --pretty=format:%N HEAD | grep 'scripts/api-explorer/v2/script.js'`
status_api_json_updated = `git show -m --name-only --pretty=format:%N HEAD | grep '_data/orgs'`
status_api_expoloer_v2_updated = `git show -m --name-only --pretty=format:%N HEAD | grep 'scripts/api-explorer/v2/'`
if (status_api_json_updated != '' || status_api_expoloer_v2_updated !='') && status_api_expoloer_v2_scriptjs == ''
puts "Last commit has changes in swagger .json files or in API Exploerer V2"
system 'npm install'
system 'npm run build'
status = `git status --porcelain`
if status != ''
puts "Files changed: \n#{status}"
system "git config --global user.email 'de.gratnik@gmail.com'"
system "git config --global user.name 'degratnik' "
system "git config --global push.default current"
# current repo has detached HEAD, so let do checkout:
puts "git checkout #{SOURCE_BRANCH}"
system "git checkout #{SOURCE_BRANCH}"
puts "git status"
system 'git status'
puts "git add --all"
system 'git add --all -v'
puts "git status"
system 'git status'
puts "git commit"
system 'git commit -v -m "TRAVIS BUILD COMMIT"'
puts "git status"
system 'git status'
puts "git log"
system 'git log -n 3'
puts "git push"
build_commit = system "git push -u -v origin #{SOURCE_BRANCH}"
puts "git status"
system 'git status'
puts "Build commit: #{build_commit}"
File.delete '.git/credentials'
exit 0
end
end
puts "Deploying from #{SOURCE_BRANCH} to #{DEPLOY_BRANCH}"
deployed = system "git push origin #{SOURCE_BRANCH}:#{DEPLOY_BRANCH}"
puts "Deployed: #{deployed}"
File.delete '.git/credentials'
if not deployed
exit 1
end
end
desc 'save report to GitHub from Travis'
task :report do
repo = %x(git config remote.origin.url).gsub(/^git:/, 'https:')
system "git remote set-url --push origin #{repo}"
system 'git config credential.helper "store --file=.git/credentials"'
File.open('.git/credentials', 'w') do |f|
f.write("https://#{ENV['GH_TOKEN']}:x-oauth-basic@github.com")
end
if ENV['TRAVIS_BRANCH'] == 'master'
REPORT_BRANCH = 'report_master'
end
puts "Report from #{SOURCE_BRANCH} to #{REPORT_BRANCH} add files to 'tests/galen/reports/all'"
system "git config --global user.email 'de.gratnik@gmail.com'"
system "git config --global user.name 'degratnik' "
system "git config --global push.default current"
system "git add tests/serenity/target/site"
system "git commit --allow-empty --amend -m 'Auto-Report from Travis #{Time.now.utc.to_s}'"
system "git checkout -b #{REPORT_BRANCH}"
reported = system "git push -u -f origin #{REPORT_BRANCH}"
puts "Reported: #{reported}"
puts "Reported-time(at UTC=+0000): #{Time.now.utc.to_s}"
File.delete '.git/credentials'
if not reported
exit 1
end
end
end