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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7d087ed2ece99b39781fc88a31f6ad778b9d51e
4
- data.tar.gz: 034efbe8861b7d13f59da283418f29639e976734
3
+ metadata.gz: 98b9e2cec0855a3481eda131fb32a36dbd0aa887
4
+ data.tar.gz: 78fa93fd7a38369251bd103ccb54f1a7936768fd
5
5
  SHA512:
6
- metadata.gz: 07d52777b0fa3e9cef684f37fded154bb8ebe4c1c6f25dccc08088c9ba7f8a516d2cd1c2c7bd8da7a4890ef7796701edf15e49156c90989acd3e6eb0db168205
7
- data.tar.gz: 163bb38d935af132654c3a74ae54c672eb8dffc3738b20a4728ba703521e69f7375b8498d0f2fd70eb7ca547a3792d5c0441052efb550beca01119a02ec7ca84
6
+ metadata.gz: 1688df5b5612f0bc2c27e3215a8a2a22e23ede878f9711a335c76d6c02057214be800095142d0a744e01de58856788b9405085d8e7d518134210cb27aaf7bce4
7
+ data.tar.gz: 690565eeda7694e5b7d5731a7d37c5f417a78dc418010673e0747a747aeec1d6c6117cc97160fdc64d7fd6c9414e6aa5af36e077277e7b881cfb1c499e99fd87
data/bin/clive CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'commit-live'
3
+ require "commit-live"
4
4
 
5
5
  if ['-v', '--version'].include?(ARGV.first)
6
6
  puts CommitLive::Cli::VERSION
@@ -1,7 +1,7 @@
1
- require 'commit-live/version'
2
- require 'commit-live/cli'
3
- require 'commit-live/options-sanitizer'
4
- require 'commit-live/netrc-interactor'
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
@@ -1,10 +1,10 @@
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'
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
@@ -1,5 +1,5 @@
1
1
  require "commit-live/netrc-interactor"
2
- require 'octokit'
2
+ require "octokit"
3
3
 
4
4
  module CommitLive
5
5
  class Github
@@ -1,13 +1,15 @@
1
1
  require "commit-live/api"
2
2
  require "commit-live/netrc-interactor"
3
- require 'json'
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
- puts "Something went wrong. Please try again."
34
- exit 1
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
- puts 'There was an error while pushing. Please try again later.'
118
- puts e.message
119
- exit 1
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
- puts "Error while creating PR!"
143
- puts err
144
- exit 1
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 'octokit'
6
- require 'git'
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
- puts "Error while forking!"
89
- puts err
90
- exit
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
- puts "Error while cloning!"
105
- puts err
106
- exit
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
- puts "Failed updating lesson status."
30
- exit 1
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
@@ -1,5 +1,5 @@
1
- require 'commit-live/lesson/git-helper'
2
- require 'octokit'
1
+ require "commit-live/lesson/git-helper"
2
+ require "octokit"
3
3
 
4
4
  module CommitLive
5
5
  class Submit
@@ -1,4 +1,4 @@
1
- require 'netrc'
1
+ require "netrc"
2
2
 
3
3
  module CommitLive
4
4
  class NetrcInteractor
@@ -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
- puts "Error while dumping test results."
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 'commit-live/tests/strategy'
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
- FileUtils.rm('.results.json')
23
+ if File.exists?('.results.json')
24
+ FileUtils.rm('.results.json')
25
+ end
24
26
  end
25
27
  end
26
28
  end
@@ -1,7 +1,7 @@
1
1
  require "commit-live/api"
2
2
  require "commit-live/netrc-interactor"
3
- require 'json'
4
- require 'yaml'
3
+ require "json"
4
+ require "yaml"
5
5
 
6
6
  module CommitLive
7
7
  class User
@@ -1,5 +1,5 @@
1
1
  module CommitLive
2
2
  module Cli
3
- VERSION = "0.0.14"
3
+ VERSION = "0.0.15"
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.0.14
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-05-25 00:00:00.000000000 Z
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