commit-live-cli 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cbd2ff0437f481596381b8f1efa9df84394297a
4
- data.tar.gz: d2c618d94b7e0aa18e3d24f5c9b33b364bbbd1aa
3
+ metadata.gz: 062a20f271b98d140dba254c60bfcd31661469a5
4
+ data.tar.gz: 975affbb4b2779f4cf405e3f182947ce5325e91a
5
5
  SHA512:
6
- metadata.gz: addb83172bcf9a6f712672a6f4246e28b3ee2e7e5a7ce467ecc9a7114662a8880a6482fddf1ae294fb836fd5af43b7a1c4f3be10fbf13b2f0f22a28fd3667f84
7
- data.tar.gz: ae51babe59560362c9015ddf7c689c45eddcab55d307912941dd00734361b192e5287e5e1e034f9963a88e781a90cfcd18dd60f028383418a149549909faa1dd
6
+ metadata.gz: e43c648b09acfd98057d1e2bd17f296757148b2eb4fb88f0b883d118e2c944b6dcc4a8f660ab7e09fdae376dec8a41402a1f8af80d16083e1993826d586ac6a6
7
+ data.tar.gz: 155c6817abb6418707ef2862cf3cba0ef6730675f2329a236392b0e651d771df5759f48770c38c244b0bd5281076f2a734a79986b2d93c074b0d0ec05dbd1c58
@@ -7,9 +7,10 @@ require "commit-live/sentry"
7
7
  module CommitLive
8
8
  class Submit
9
9
  class GitHelper
10
- attr_reader :git, :currentLesson, :netrc, :status, :lessonName, :sentry, :track_slug
10
+ attr_reader :git, :currentLesson, :netrc, :status, :lessonName, :sentry, :track_slug, :rootDir
11
11
  attr_accessor :remote_name
12
12
 
13
+ HOME_DIR = File.expand_path("~")
13
14
  REPO_BELONGS_TO_US = [
14
15
  'commit-live-students'
15
16
  ]
@@ -22,6 +23,9 @@ module CommitLive
22
23
  @status = CommitLive::Status.new
23
24
  @lessonName = repo_name(remote: 'origin')
24
25
  @sentry = CommitLive::Sentry.new()
26
+ if File.exists?("#{HOME_DIR}/.ga-config")
27
+ @rootDir = YAML.load(File.read("#{HOME_DIR}/.ga-config"))[:workspace]
28
+ end
25
29
  end
26
30
 
27
31
  def commitAndPush
@@ -51,11 +55,26 @@ module CommitLive
51
55
 
52
56
  private
53
57
 
58
+ def dir_path
59
+ filePath = "#{title_slug}/"
60
+ filePath += "#{test_slug}/" if is_project_assignment
61
+ return filePath
62
+ end
63
+
54
64
  def is_test_case_passed
55
65
  isTestCasesPassed = currentLesson.getValue('testCasesPassed')
56
66
  !isTestCasesPassed.nil? && isTestCasesPassed == 1
57
67
  end
58
68
 
69
+ def test_slug
70
+ currentLesson.getValue('testCase')
71
+ end
72
+
73
+ def is_project_assignment
74
+ isProjectAssignment = currentLesson.getValue('isProjectAssignment')
75
+ !isProjectAssignment.nil? && isProjectAssignment == 1
76
+ end
77
+
59
78
  def is_submitted_pr
60
79
  isSubmittedPr = currentLesson.getValue('submittedPr')
61
80
  !isSubmittedPr.nil? && isSubmittedPr == 1
@@ -204,7 +223,8 @@ module CommitLive
204
223
  end
205
224
 
206
225
  def update_lesson_status
207
- status.update('submittedPr', track_slug)
226
+ file_path = "#{rootDir}/#{dir_path}/build.py"
227
+ status.update('submittedPr', track_slug, true, {}, file_path)
208
228
  end
209
229
  end
210
230
  end
@@ -2,6 +2,7 @@ require "commit-live/api"
2
2
  require "commit-live/netrc-interactor"
3
3
  require "commit-live/sentry"
4
4
  require "uri"
5
+ require "oj"
5
6
 
6
7
  module CommitLive
7
8
  class Status
@@ -18,7 +19,7 @@ module CommitLive
18
19
  netrc.password
19
20
  end
20
21
 
21
- def update(type, trackName)
22
+ def update(type, trackName, shouldAnalyze = false, dump_data = {}, file_path = "")
22
23
  enc_url = URI.escape("/v2/user/track/#{trackName}")
23
24
  begin
24
25
  Timeout::timeout(60) do
@@ -29,7 +30,10 @@ module CommitLive
29
30
  'Content-Type' => 'application/json'
30
31
  },
31
32
  body: {
32
- 'action' => type
33
+ 'action' => type,
34
+ 'analysis' => shouldAnalyze ? 1 : 0,
35
+ 'data' => Oj.dump(dump_data, mode: :compat),
36
+ 'filePath' => file_path
33
37
  }
34
38
  )
35
39
  if response.status != 201
@@ -71,21 +71,19 @@ module CommitLive
71
71
  if strategy.results
72
72
  strategy.print_results
73
73
  end
74
- if updateStatus
74
+ file_path = "#{rootDir}/#{dir_path}/build.py"
75
+ if updateStatus && strategy.results
75
76
  if results
76
77
  # test case passed
77
78
  puts 'Great! You have passed all the test cases.'
78
79
  puts 'Use `clive submit` to push your changes.'
79
- CommitLive::Status.new().update('testCasesPassed', track_slug)
80
+ CommitLive::Status.new().update('testCasesPassed', track_slug, true, strategy.results, file_path)
80
81
  else
81
82
  # test case failed
82
83
  puts 'Oops! You still have to pass all the test cases.'
83
- CommitLive::Status.new().update('testCasesFailed', track_slug)
84
+ CommitLive::Status.new().update('testCasesFailed', track_slug, true, strategy.results, file_path)
84
85
  end
85
86
  end
86
- if strategy.results
87
- dump_results
88
- end
89
87
  strategy.cleanup
90
88
  return results
91
89
  end
@@ -98,6 +96,12 @@ module CommitLive
98
96
  system("git checkout HEAD -- #{test_case_dir_path}")
99
97
  end
100
98
 
99
+ def dir_path
100
+ filePath = "#{title_slug}/"
101
+ filePath += "#{test_slug}/" if is_project_assignment
102
+ return filePath
103
+ end
104
+
101
105
  def test_case_dir_path
102
106
  filePath = ""
103
107
  filePath += "#{test_slug}/" if is_project_assignment
@@ -154,43 +158,6 @@ module CommitLive
154
158
  end
155
159
  end
156
160
 
157
- def dump_results
158
- begin
159
- Timeout::timeout(15) do
160
- api = CommitLive::API.new
161
- netrc = CommitLive::NetrcInteractor.new()
162
- netrc.read
163
- token = netrc.password
164
- url = URI.escape("/v2/dumps")
165
- response = api.post(
166
- url,
167
- headers: {
168
- 'Authorization' => "#{token}",
169
- 'Content-Type' => 'application/json',
170
- },
171
- body: {
172
- 'data' => Oj.dump(strategy.results, mode: :compat),
173
- 'titleSlugTestCase' => track_slug
174
- }
175
- )
176
- if response.status != 200
177
- sentry.log_message("Test Results Dump Failed",
178
- {
179
- 'url' => url,
180
- 'track-slug' => track_slug,
181
- 'results' => strategy.results,
182
- 'response-body' => response.body,
183
- 'response-status' => response.status
184
- }
185
- )
186
- end
187
- end
188
- rescue Timeout::Error
189
- puts "Error while dumping test results."
190
- exit
191
- end
192
- end
193
-
194
161
  def strategies
195
162
  [
196
163
  CommitLive::Strategies::PythonUnittest
@@ -1,5 +1,5 @@
1
1
  module CommitLive
2
2
  module Cli
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commit-live-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - greyatom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-12 00:00:00.000000000 Z
11
+ date: 2018-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler