commit-live-cli 0.0.12 → 0.0.13
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/lib/commit-live/lesson/current.rb +9 -0
- data/lib/commit-live/lesson/git-helper.rb +14 -6
- data/lib/commit-live/lesson/open.rb +39 -27
- data/lib/commit-live/lesson/status.rb +1 -1
- data/lib/commit-live/tests/runner.rb +56 -5
- data/lib/commit-live/tests/strategies/python-test.rb +9 -1
- data/lib/commit-live/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47eab11485d97b319cfe86b06681d66c474bdc88
|
4
|
+
data.tar.gz: cf16223e13c52a45422f4a90c66f46660b605cae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d167094a0053f99a311445cf3723dd2aa2d662514882ece1f873b439b09e4c838c6d9f25d021e34a0a953c0380a501abcb5af8b5bdec66a4939300988f35c3e0
|
7
|
+
data.tar.gz: 61561352d2902a28f543e346677a3a3b35018f1a0ba975b5b5e2889626a9092352636e69fd98535682887ffd1327089651259ca32e4e743e5b5be16b7632f54e
|
@@ -24,9 +24,9 @@ module CommitLive
|
|
24
24
|
def commitAndPush
|
25
25
|
checkRemote
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
testCasePassed =
|
27
|
+
check_if_practice_lesson
|
28
|
+
|
29
|
+
testCasePassed = currentLesson.getValue('test_case_pass')
|
30
30
|
# Check if User passed test cases
|
31
31
|
if testCasePassed
|
32
32
|
# Push to User's Github
|
@@ -34,7 +34,7 @@ module CommitLive
|
|
34
34
|
commitChanges
|
35
35
|
push
|
36
36
|
|
37
|
-
pullRequestSubmitted =
|
37
|
+
pullRequestSubmitted = currentLesson.getValue('submitted_pull_request')
|
38
38
|
if !pullRequestSubmitted
|
39
39
|
# Create Pull Request
|
40
40
|
createPullRequest
|
@@ -51,6 +51,15 @@ module CommitLive
|
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
+
def check_if_practice_lesson
|
55
|
+
currentLesson.getCurrentLesson(lessonName)
|
56
|
+
lessonType = currentLesson.getValue('type')
|
57
|
+
if lessonType == "PRACTICE"
|
58
|
+
puts "This is a practice lesson. No need to submit anything."
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
54
63
|
def setGit
|
55
64
|
begin
|
56
65
|
Git.open(FileUtils.pwd)
|
@@ -123,8 +132,7 @@ module CommitLive
|
|
123
132
|
username = netrc.login
|
124
133
|
begin
|
125
134
|
Timeout::timeout(45) do
|
126
|
-
|
127
|
-
parentRepo = lessonData['repo_url']
|
135
|
+
parentRepo = currentLesson.getValue('repo_url')
|
128
136
|
pullRequest = userGithub.client.create_pull_request(
|
129
137
|
parentRepo,
|
130
138
|
'master',
|
@@ -7,9 +7,10 @@ require 'git'
|
|
7
7
|
|
8
8
|
module CommitLive
|
9
9
|
class Open
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :rootDir, :lesson, :forkedRepo, :lesson_status
|
11
11
|
|
12
12
|
HOME_DIR = File.expand_path("~")
|
13
|
+
ALLOWED_TYPES = ["LAB", "PRACTICE"]
|
13
14
|
|
14
15
|
def initialize()
|
15
16
|
if File.exists?("#{HOME_DIR}/.ga-config")
|
@@ -19,35 +20,52 @@ module CommitLive
|
|
19
20
|
@lesson_status = CommitLive::Status.new
|
20
21
|
end
|
21
22
|
|
23
|
+
def ssh_url
|
24
|
+
if lesson_type === "PRACTICE"
|
25
|
+
"git@github.com:#{lesson_repo}.git"
|
26
|
+
else
|
27
|
+
forkedRepo.ssh_url
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def lesson_name
|
32
|
+
lesson.getValue('track_slug')
|
33
|
+
end
|
34
|
+
|
35
|
+
def lesson_type
|
36
|
+
lesson.getValue('type')
|
37
|
+
end
|
38
|
+
|
39
|
+
def lesson_forked
|
40
|
+
lesson.getValue('forked')
|
41
|
+
end
|
42
|
+
|
43
|
+
def lesson_repo
|
44
|
+
lesson.getValue('repo_url')
|
45
|
+
end
|
46
|
+
|
22
47
|
def openALesson(puzzle_name)
|
23
48
|
# get currently active lesson
|
24
49
|
puts "Getting current lesson..."
|
25
50
|
lesson.getCurrentLesson(puzzle_name)
|
26
|
-
|
27
|
-
|
28
|
-
if !lessonData['current_track'].nil?
|
29
|
-
@lessonName = lessonData['current_track']['track_slug']
|
30
|
-
isAssignment = lessonData['current_track']['assignment_flag']
|
31
|
-
forked = lessonData['current_track']['forked']
|
32
|
-
else
|
33
|
-
@lessonName = lessonData['track_slug']
|
34
|
-
isAssignment = lessonData['assignment_flag']
|
35
|
-
forked = lessonData['forked']
|
36
|
-
end
|
37
|
-
if !isAssignment
|
51
|
+
|
52
|
+
if !ALLOWED_TYPES.include? lesson_type
|
38
53
|
puts "This is a read only lesson!"
|
39
54
|
exit
|
40
55
|
end
|
41
|
-
|
56
|
+
|
57
|
+
if !File.exists?("#{rootDir}/#{lesson_name}")
|
42
58
|
# fork lesson repo via github api
|
43
|
-
|
59
|
+
if lesson_type == "LAB"
|
60
|
+
forkCurrentLesson
|
61
|
+
end
|
44
62
|
# clone forked lesson into machine
|
45
63
|
cloneCurrentLesson
|
46
64
|
# change group owner
|
47
65
|
change_grp_owner
|
48
66
|
# lesson forked API change
|
49
|
-
if !
|
50
|
-
lesson_status.update('forked',
|
67
|
+
if lesson_type == "LAB" && !lesson_forked
|
68
|
+
lesson_status.update('forked', lesson_name)
|
51
69
|
end
|
52
70
|
end
|
53
71
|
# install dependencies
|
@@ -60,13 +78,7 @@ module CommitLive
|
|
60
78
|
github = CommitLive::Github.new()
|
61
79
|
begin
|
62
80
|
Timeout::timeout(15) do
|
63
|
-
|
64
|
-
if !lessonData['current_track'].nil?
|
65
|
-
lessonRepo = lessonData['current_track']['repo_url']
|
66
|
-
else
|
67
|
-
lessonRepo = lessonData['repo_url']
|
68
|
-
end
|
69
|
-
@forkedRepo = github.client.fork(lessonRepo)
|
81
|
+
@forkedRepo = github.client.fork(lesson_repo)
|
70
82
|
end
|
71
83
|
rescue Octokit::Error => err
|
72
84
|
puts "Error while forking!"
|
@@ -82,7 +94,7 @@ module CommitLive
|
|
82
94
|
puts "Cloning lesson..."
|
83
95
|
begin
|
84
96
|
Timeout::timeout(15) do
|
85
|
-
Git.clone(
|
97
|
+
Git.clone(ssh_url, lesson_name, path: rootDir)
|
86
98
|
end
|
87
99
|
rescue Git::GitExecuteError => err
|
88
100
|
puts "Error while cloning!"
|
@@ -95,12 +107,12 @@ module CommitLive
|
|
95
107
|
end
|
96
108
|
|
97
109
|
def change_grp_owner
|
98
|
-
system("chgrp -R ubuntu #{rootDir}/#{
|
110
|
+
system("chgrp -R ubuntu #{rootDir}/#{lesson_name}")
|
99
111
|
end
|
100
112
|
|
101
113
|
def cdToLesson
|
102
114
|
puts "Opening lesson..."
|
103
|
-
Dir.chdir("#{rootDir}/#{
|
115
|
+
Dir.chdir("#{rootDir}/#{lesson_name}")
|
104
116
|
puts "Done."
|
105
117
|
exec("#{ENV['SHELL']} -l")
|
106
118
|
end
|
@@ -1,7 +1,10 @@
|
|
1
|
-
require
|
1
|
+
require "yaml"
|
2
|
+
require "oj"
|
3
|
+
require "commit-live/lesson/current"
|
2
4
|
require "commit-live/lesson/status"
|
5
|
+
require "commit-live/api"
|
3
6
|
require "commit-live/netrc-interactor"
|
4
|
-
require
|
7
|
+
require "commit-live/tests/strategies/python-test"
|
5
8
|
|
6
9
|
module CommitLive
|
7
10
|
class Test
|
@@ -13,6 +16,7 @@ module CommitLive
|
|
13
16
|
|
14
17
|
def initialize()
|
15
18
|
check_lesson_dir
|
19
|
+
check_if_practice_lesson
|
16
20
|
die if !strategy
|
17
21
|
end
|
18
22
|
|
@@ -39,6 +43,10 @@ module CommitLive
|
|
39
43
|
url.match(/^.+[\w-]+\/(.*?)(?:\.git)?$/)[1]
|
40
44
|
end
|
41
45
|
|
46
|
+
def lesson_name
|
47
|
+
repo_name(remote: 'origin')
|
48
|
+
end
|
49
|
+
|
42
50
|
def put_error_msg
|
43
51
|
puts "It doesn't look like you're in a lesson directory."
|
44
52
|
puts 'Please cd into an appropriate directory and try again.'
|
@@ -51,15 +59,19 @@ module CommitLive
|
|
51
59
|
strategy.configure
|
52
60
|
results = strategy.run
|
53
61
|
if updateStatus
|
54
|
-
lessonName = repo_name(remote: 'origin')
|
55
62
|
if results
|
56
63
|
# test case passed
|
57
|
-
CommitLive::Status.new().update('test_case_pass',
|
64
|
+
CommitLive::Status.new().update('test_case_pass', lesson_name)
|
58
65
|
else
|
59
66
|
# test case failed
|
60
|
-
CommitLive::Status.new().update('test_case_fail',
|
67
|
+
CommitLive::Status.new().update('test_case_fail', lesson_name)
|
61
68
|
end
|
62
69
|
end
|
70
|
+
if strategy.results
|
71
|
+
dump_results
|
72
|
+
end
|
73
|
+
strategy.cleanup
|
74
|
+
puts 'Done.'
|
63
75
|
return results
|
64
76
|
end
|
65
77
|
|
@@ -73,6 +85,45 @@ module CommitLive
|
|
73
85
|
|
74
86
|
private
|
75
87
|
|
88
|
+
def check_if_practice_lesson
|
89
|
+
lesson = CommitLive::Current.new
|
90
|
+
lesson.getCurrentLesson(lesson_name)
|
91
|
+
lessonType = lesson.getValue('type')
|
92
|
+
if lessonType == "PRACTICE"
|
93
|
+
puts "This is a practice lesson. No need to run test on it."
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def dump_results
|
99
|
+
begin
|
100
|
+
Timeout::timeout(15) do
|
101
|
+
api = CommitLive::API.new
|
102
|
+
netrc = CommitLive::NetrcInteractor.new()
|
103
|
+
netrc.read
|
104
|
+
token = netrc.password
|
105
|
+
url = URI.escape("/v1/dumps")
|
106
|
+
response = api.post(
|
107
|
+
url,
|
108
|
+
headers: {
|
109
|
+
'access-token' => "#{token}",
|
110
|
+
'content-type' => 'application/json',
|
111
|
+
},
|
112
|
+
body: {
|
113
|
+
'data' => Oj.dump(strategy.results, mode: :compat),
|
114
|
+
'track_slug' => lesson_name
|
115
|
+
}
|
116
|
+
)
|
117
|
+
if response.status != 201
|
118
|
+
puts "Error while dumping test results."
|
119
|
+
end
|
120
|
+
end
|
121
|
+
rescue Timeout::Error
|
122
|
+
puts "Error while dumping test results."
|
123
|
+
exit
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
76
127
|
def strategies
|
77
128
|
[
|
78
129
|
CommitLive::Strategies::PythonUnittest
|
@@ -12,7 +12,15 @@ module CommitLive
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run
|
15
|
-
system("nosetests --verbose")
|
15
|
+
system("nosetests --verbose --with-json --json-file=\"./.results.json\"")
|
16
|
+
end
|
17
|
+
|
18
|
+
def results
|
19
|
+
@output ||= Oj.load(File.read('.results.json'), mode: :compat)
|
20
|
+
end
|
21
|
+
|
22
|
+
def cleanup
|
23
|
+
FileUtils.rm('.results.json')
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
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.13
|
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-
|
11
|
+
date: 2017-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -160,6 +160,20 @@ dependencies:
|
|
160
160
|
- - "~>"
|
161
161
|
- !ruby/object:Gem::Version
|
162
162
|
version: '0.9'
|
163
|
+
- !ruby/object:Gem::Dependency
|
164
|
+
name: oj
|
165
|
+
requirement: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - "~>"
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '2.9'
|
170
|
+
type: :runtime
|
171
|
+
prerelease: false
|
172
|
+
version_requirements: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - "~>"
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '2.9'
|
163
177
|
description:
|
164
178
|
email:
|
165
179
|
- greyatomedutech@gmail.com
|