commit-live-cli 0.0.14 → 0.0.15
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 +4 -4
- data/bin/clive +1 -1
- data/lib/commit-live.rb +4 -4
- data/lib/commit-live/cli.rb +7 -7
- data/lib/commit-live/github.rb +1 -1
- data/lib/commit-live/lesson/current.rb +15 -6
- data/lib/commit-live/lesson/git-helper.rb +15 -7
- data/lib/commit-live/lesson/open.rb +17 -9
- data/lib/commit-live/lesson/status.rb +18 -5
- data/lib/commit-live/lesson/submit.rb +2 -2
- data/lib/commit-live/netrc-interactor.rb +1 -1
- data/lib/commit-live/sentry.rb +49 -0
- data/lib/commit-live/tests/runner.rb +10 -2
- data/lib/commit-live/tests/strategies/python-test.rb +4 -2
- data/lib/commit-live/user.rb +2 -2
- data/lib/commit-live/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98b9e2cec0855a3481eda131fb32a36dbd0aa887
|
4
|
+
data.tar.gz: 78fa93fd7a38369251bd103ccb54f1a7936768fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1688df5b5612f0bc2c27e3215a8a2a22e23ede878f9711a335c76d6c02057214be800095142d0a744e01de58856788b9405085d8e7d518134210cb27aaf7bce4
|
7
|
+
data.tar.gz: 690565eeda7694e5b7d5731a7d37c5f417a78dc418010673e0747a747aeec1d6c6117cc97160fdc64d7fd6c9414e6aa5af36e077277e7b881cfb1c499e99fd87
|
data/bin/clive
CHANGED
data/lib/commit-live.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "commit-live/version"
|
2
|
+
require "commit-live/cli"
|
3
|
+
require "commit-live/options-sanitizer"
|
4
|
+
require "commit-live/netrc-interactor"
|
5
5
|
|
6
6
|
module CommitLive
|
7
7
|
end
|
data/lib/commit-live/cli.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
1
|
+
require "commit-live/user"
|
2
|
+
require "commit-live/netrc-interactor"
|
3
|
+
require "commit-live/tests/runner"
|
4
|
+
require "commit-live/lesson/submit"
|
5
|
+
require "commit-live/lesson/open"
|
6
|
+
require "commit-live/lesson/parser"
|
7
|
+
require "thor"
|
8
8
|
|
9
9
|
module CommitLive
|
10
10
|
class CLI < Thor
|
data/lib/commit-live/github.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require "commit-live/api"
|
2
2
|
require "commit-live/netrc-interactor"
|
3
|
-
require
|
3
|
+
require "commit-live/sentry"
|
4
|
+
require "json"
|
4
5
|
|
5
6
|
module CommitLive
|
6
7
|
class Current
|
7
|
-
attr_accessor :lesson, :netrc
|
8
|
+
attr_accessor :lesson, :netrc, :sentry
|
8
9
|
|
9
10
|
def initialize()
|
10
11
|
@netrc = CommitLive::NetrcInteractor.new()
|
12
|
+
@sentry = CommitLive::Sentry.new()
|
11
13
|
end
|
12
14
|
|
13
15
|
def getCurrentLesson(puzzle_name)
|
@@ -18,11 +20,14 @@ module CommitLive
|
|
18
20
|
getLesson(url)
|
19
21
|
end
|
20
22
|
|
23
|
+
def token
|
24
|
+
netrc.read
|
25
|
+
netrc.password
|
26
|
+
end
|
27
|
+
|
21
28
|
def getLesson(url)
|
22
29
|
begin
|
23
30
|
Timeout::timeout(15) do
|
24
|
-
netrc.read
|
25
|
-
token = netrc.password
|
26
31
|
response = CommitLive::API.new().get(
|
27
32
|
url,
|
28
33
|
headers: { 'access-token' => "#{token}" }
|
@@ -30,8 +35,12 @@ module CommitLive
|
|
30
35
|
if response.status == 200
|
31
36
|
@lesson = JSON.parse(response.body)
|
32
37
|
else
|
33
|
-
|
34
|
-
|
38
|
+
sentry.log_message("Get Lesson Failed",
|
39
|
+
{
|
40
|
+
'url' => url,
|
41
|
+
'response' => response.body
|
42
|
+
}
|
43
|
+
)
|
35
44
|
end
|
36
45
|
end
|
37
46
|
rescue Timeout::Error
|
@@ -2,11 +2,12 @@ require "commit-live/lesson/current"
|
|
2
2
|
require "commit-live/lesson/status"
|
3
3
|
require "commit-live/netrc-interactor"
|
4
4
|
require "commit-live/github"
|
5
|
+
require "commit-live/sentry"
|
5
6
|
|
6
7
|
module CommitLive
|
7
8
|
class Submit
|
8
9
|
class GitHelper
|
9
|
-
attr_reader :git, :currentLesson, :netrc, :status, :lessonName
|
10
|
+
attr_reader :git, :currentLesson, :netrc, :status, :lessonName, :sentry
|
10
11
|
attr_accessor :remote_name
|
11
12
|
|
12
13
|
REPO_BELONGS_TO_US = [
|
@@ -19,6 +20,7 @@ module CommitLive
|
|
19
20
|
@currentLesson = CommitLive::Current.new
|
20
21
|
@status = CommitLive::Status.new
|
21
22
|
@lessonName = repo_name(remote: 'origin')
|
23
|
+
@sentry = CommitLive::Sentry.new()
|
22
24
|
end
|
23
25
|
|
24
26
|
def commitAndPush
|
@@ -114,9 +116,12 @@ module CommitLive
|
|
114
116
|
git.push(push_remote)
|
115
117
|
end
|
116
118
|
rescue Git::GitExecuteError => e
|
117
|
-
|
118
|
-
|
119
|
-
|
119
|
+
sentry.log_exception(e,
|
120
|
+
{
|
121
|
+
'event': 'pushing',
|
122
|
+
'lesson_name' => lessonName,
|
123
|
+
}
|
124
|
+
)
|
120
125
|
rescue Timeout::Error
|
121
126
|
puts "Can't reach GitHub right now. Please try again."
|
122
127
|
exit 1
|
@@ -139,9 +144,12 @@ module CommitLive
|
|
139
144
|
)
|
140
145
|
end
|
141
146
|
rescue Octokit::Error => err
|
142
|
-
|
143
|
-
|
144
|
-
|
147
|
+
sentry.log_exception(err,
|
148
|
+
{
|
149
|
+
'event': 'creating-pull-request',
|
150
|
+
'lesson_name' => lessonName,
|
151
|
+
}
|
152
|
+
)
|
145
153
|
rescue Timeout::Error
|
146
154
|
puts "Please check your internet connection."
|
147
155
|
exit 1
|
@@ -2,13 +2,14 @@ require "commit-live/lesson/current"
|
|
2
2
|
require "commit-live/lesson/status"
|
3
3
|
require "commit-live/api"
|
4
4
|
require "commit-live/github"
|
5
|
-
require
|
6
|
-
require
|
5
|
+
require "commit-live/sentry"
|
6
|
+
require "octokit"
|
7
|
+
require "git"
|
7
8
|
require "oj"
|
8
9
|
|
9
10
|
module CommitLive
|
10
11
|
class Open
|
11
|
-
attr_reader :rootDir, :lesson, :forkedRepo, :lesson_status
|
12
|
+
attr_reader :rootDir, :lesson, :forkedRepo, :lesson_status, :sentry
|
12
13
|
|
13
14
|
HOME_DIR = File.expand_path("~")
|
14
15
|
ALLOWED_TYPES = ["LAB", "PRACTICE"]
|
@@ -19,6 +20,7 @@ module CommitLive
|
|
19
20
|
end
|
20
21
|
@lesson = CommitLive::Current.new
|
21
22
|
@lesson_status = CommitLive::Status.new
|
23
|
+
@sentry = CommitLive::Sentry.new()
|
22
24
|
end
|
23
25
|
|
24
26
|
def ssh_url
|
@@ -85,9 +87,12 @@ module CommitLive
|
|
85
87
|
@forkedRepo = github.client.fork(lesson_repo)
|
86
88
|
end
|
87
89
|
rescue Octokit::Error => err
|
88
|
-
|
89
|
-
|
90
|
-
|
90
|
+
sentry.log_exception(err,
|
91
|
+
{
|
92
|
+
'event': 'forking',
|
93
|
+
'lesson_name' => lesson_name,
|
94
|
+
}
|
95
|
+
)
|
91
96
|
rescue Timeout::Error
|
92
97
|
puts "Please check your internet connection."
|
93
98
|
exit
|
@@ -101,9 +106,12 @@ module CommitLive
|
|
101
106
|
Git.clone(ssh_url, lesson_name, path: rootDir)
|
102
107
|
end
|
103
108
|
rescue Git::GitExecuteError => err
|
104
|
-
|
105
|
-
|
106
|
-
|
109
|
+
sentry.log_exception(err,
|
110
|
+
{
|
111
|
+
'event': 'cloning',
|
112
|
+
'lesson_name' => lesson_name,
|
113
|
+
}
|
114
|
+
)
|
107
115
|
rescue Timeout::Error
|
108
116
|
puts "Cannot clone this lesson right now. Please try again."
|
109
117
|
exit
|
@@ -1,21 +1,26 @@
|
|
1
1
|
require "commit-live/api"
|
2
2
|
require "commit-live/netrc-interactor"
|
3
|
+
require "commit-live/sentry"
|
3
4
|
require "uri"
|
4
5
|
|
5
6
|
module CommitLive
|
6
7
|
class Status
|
7
|
-
attr_reader :api, :netrc
|
8
|
+
attr_reader :api, :netrc, :sentry
|
8
9
|
|
9
10
|
def initialize()
|
10
11
|
@api = CommitLive::API.new
|
11
12
|
@netrc = CommitLive::NetrcInteractor.new()
|
13
|
+
@sentry = CommitLive::Sentry.new()
|
14
|
+
end
|
15
|
+
|
16
|
+
def token
|
17
|
+
netrc.read
|
18
|
+
netrc.password
|
12
19
|
end
|
13
20
|
|
14
21
|
def update(type, trackName)
|
15
22
|
begin
|
16
23
|
Timeout::timeout(15) do
|
17
|
-
netrc.read
|
18
|
-
token = netrc.password
|
19
24
|
enc_url = URI.escape("/v1/user/track/#{trackName}")
|
20
25
|
response = api.post(
|
21
26
|
enc_url,
|
@@ -26,8 +31,16 @@ module CommitLive
|
|
26
31
|
}
|
27
32
|
)
|
28
33
|
if response.status != 202
|
29
|
-
|
30
|
-
|
34
|
+
sentry.log_message("Update Lesson Status Failed",
|
35
|
+
{
|
36
|
+
'url' => enc_url,
|
37
|
+
'track_name' => trackName,
|
38
|
+
'params' => {
|
39
|
+
'method' => 'assignment_status',
|
40
|
+
'action' => type
|
41
|
+
}
|
42
|
+
}
|
43
|
+
)
|
31
44
|
end
|
32
45
|
end
|
33
46
|
rescue Timeout::Error
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "commit-live/netrc-interactor"
|
2
|
+
require "sentry-raven"
|
3
|
+
|
4
|
+
module CommitLive
|
5
|
+
class Sentry
|
6
|
+
attr_accessor :netrc
|
7
|
+
|
8
|
+
def initialize()
|
9
|
+
@netrc = CommitLive::NetrcInteractor.new()
|
10
|
+
end
|
11
|
+
|
12
|
+
def token
|
13
|
+
netrc.read
|
14
|
+
netrc.password
|
15
|
+
end
|
16
|
+
|
17
|
+
def username
|
18
|
+
netrc.read(machine: 'ga-extra')
|
19
|
+
netrc.login
|
20
|
+
end
|
21
|
+
|
22
|
+
def user_info
|
23
|
+
{
|
24
|
+
'username' => username,
|
25
|
+
'token' => token
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def merge_user_info_with_other_args(other_args)
|
30
|
+
user_info.merge(other_args)
|
31
|
+
end
|
32
|
+
|
33
|
+
def log_message(other_args)
|
34
|
+
Raven.capture_message("Get Lesson Failed",
|
35
|
+
:extra => merge_user_info_with_other_args(other_args)
|
36
|
+
)
|
37
|
+
puts "Something went wrong. Commit.Live Admin has been notified about the issue. Please wait until further instructions."
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
|
41
|
+
def log_exception(the_exception, other_args)
|
42
|
+
Raven.capture_message(the_exception,
|
43
|
+
:extra => merge_user_info_with_other_args(other_args)
|
44
|
+
)
|
45
|
+
puts "Something went wrong. Commit.Live Admin has been notified about the issue. Please wait until further instructions."
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -3,12 +3,13 @@ require "oj"
|
|
3
3
|
require "commit-live/lesson/current"
|
4
4
|
require "commit-live/lesson/status"
|
5
5
|
require "commit-live/api"
|
6
|
+
require "commit-live/sentry"
|
6
7
|
require "commit-live/netrc-interactor"
|
7
8
|
require "commit-live/tests/strategies/python-test"
|
8
9
|
|
9
10
|
module CommitLive
|
10
11
|
class Test
|
11
|
-
attr_reader :git
|
12
|
+
attr_reader :git, :sentry
|
12
13
|
|
13
14
|
REPO_BELONGS_TO_US = [
|
14
15
|
'commit-live-students'
|
@@ -18,6 +19,7 @@ module CommitLive
|
|
18
19
|
check_lesson_dir
|
19
20
|
check_if_practice_lesson
|
20
21
|
die if !strategy
|
22
|
+
@sentry = CommitLive::Sentry.new()
|
21
23
|
end
|
22
24
|
|
23
25
|
def set_git
|
@@ -118,7 +120,13 @@ module CommitLive
|
|
118
120
|
}
|
119
121
|
)
|
120
122
|
if response.status != 201
|
121
|
-
|
123
|
+
sentry.log_message("Test Results Dump Failed",
|
124
|
+
{
|
125
|
+
'url' => url,
|
126
|
+
'track_slug' => lesson_name,
|
127
|
+
'results' => strategy.results
|
128
|
+
}
|
129
|
+
)
|
122
130
|
end
|
123
131
|
end
|
124
132
|
rescue Timeout::Error
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "commit-live/tests/strategy"
|
2
2
|
|
3
3
|
module CommitLive
|
4
4
|
module Strategies
|
@@ -20,7 +20,9 @@ module CommitLive
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def cleanup
|
23
|
-
|
23
|
+
if File.exists?('.results.json')
|
24
|
+
FileUtils.rm('.results.json')
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
data/lib/commit-live/user.rb
CHANGED
data/lib/commit-live/version.rb
CHANGED
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.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- greyatom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -174,6 +174,20 @@ dependencies:
|
|
174
174
|
- - "~>"
|
175
175
|
- !ruby/object:Gem::Version
|
176
176
|
version: '2.9'
|
177
|
+
- !ruby/object:Gem::Dependency
|
178
|
+
name: sentry-raven
|
179
|
+
requirement: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - "~>"
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: '2.5'
|
184
|
+
type: :runtime
|
185
|
+
prerelease: false
|
186
|
+
version_requirements: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - "~>"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '2.5'
|
177
191
|
description:
|
178
192
|
email:
|
179
193
|
- greyatomedutech@gmail.com
|
@@ -197,6 +211,7 @@ files:
|
|
197
211
|
- lib/commit-live/lesson/submit.rb
|
198
212
|
- lib/commit-live/netrc-interactor.rb
|
199
213
|
- lib/commit-live/options-sanitizer.rb
|
214
|
+
- lib/commit-live/sentry.rb
|
200
215
|
- lib/commit-live/tests/runner.rb
|
201
216
|
- lib/commit-live/tests/strategies/python-test.rb
|
202
217
|
- lib/commit-live/tests/strategy.rb
|