grade_runner 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +116 -0
- data/LICENSE.txt +20 -0
- data/README.markdown +23 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/grade_runner.gemspec +85 -0
- data/lib/grade_runner/railtie.rb +11 -0
- data/lib/grade_runner/runner.rb +50 -0
- data/lib/grade_runner.rb +3 -0
- data/lib/tasks/grade.rake +108 -0
- data/lib/tasks/grade_runner.rake +25 -0
- data/spec/spec_helper.rb +5 -0
- metadata +214 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bdddefa2399b9c437faa49e359f159c0a5db0a61cf31b5c10e675a0c3063ccef
|
4
|
+
data.tar.gz: 2c76c1571f2db2d40e2bbef1c22dc1a8ab2e11ed822ef6ca34db83542150a3af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc1a24f1694547e00630a8068b215da0ab26c54b728dc99aa6318bb34f203a26399454479996bb28549f7283ee00cc5c7c576c0eab14d9dc012975f9a2caa5c9
|
7
|
+
data.tar.gz: 1d4c215cde695cd244f3543c1a6a4031e9bef0a11b499bef079b4a027f9b5685c61239e74f2ce60225979f5117129fb1f5fb176527a7ddbd9016d92a49007ed6
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 3.5.0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "juwelier", "~> 2.1.0"
|
13
|
+
gem "simplecov", ">= 0"
|
14
|
+
gem "pry", "~> 0"
|
15
|
+
gem "pry-byebug", "~> 3"
|
16
|
+
gem "pry-doc", "~> 0"
|
17
|
+
gem "pry-remote", "~> 0"
|
18
|
+
gem "pry-rescue", "~> 1"
|
19
|
+
gem "pry-stack_explorer", "~> 0"
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.6.0)
|
5
|
+
public_suffix (>= 2.0.2, < 4.0)
|
6
|
+
binding_of_caller (0.8.0)
|
7
|
+
debug_inspector (>= 0.0.1)
|
8
|
+
builder (3.2.3)
|
9
|
+
byebug (11.0.1)
|
10
|
+
coderay (1.1.2)
|
11
|
+
debug_inspector (0.0.3)
|
12
|
+
descendants_tracker (0.0.4)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
14
|
+
diff-lcs (1.3)
|
15
|
+
docile (1.3.1)
|
16
|
+
faraday (0.15.4)
|
17
|
+
multipart-post (>= 1.2, < 3)
|
18
|
+
git (1.5.0)
|
19
|
+
github_api (0.18.2)
|
20
|
+
addressable (~> 2.4)
|
21
|
+
descendants_tracker (~> 0.0.4)
|
22
|
+
faraday (~> 0.8)
|
23
|
+
hashie (~> 3.5, >= 3.5.2)
|
24
|
+
oauth2 (~> 1.0)
|
25
|
+
hashie (3.6.0)
|
26
|
+
highline (2.0.2)
|
27
|
+
interception (0.5)
|
28
|
+
json (1.8.6)
|
29
|
+
juwelier (2.1.3)
|
30
|
+
builder
|
31
|
+
bundler (>= 1.13)
|
32
|
+
git (>= 1.2.5)
|
33
|
+
github_api
|
34
|
+
highline (>= 1.6.15)
|
35
|
+
nokogiri (>= 1.5.10)
|
36
|
+
rake
|
37
|
+
rdoc
|
38
|
+
semver
|
39
|
+
jwt (2.1.0)
|
40
|
+
method_source (0.9.2)
|
41
|
+
mini_portile2 (2.4.0)
|
42
|
+
multi_json (1.13.1)
|
43
|
+
multi_xml (0.6.0)
|
44
|
+
multipart-post (2.0.0)
|
45
|
+
nokogiri (1.10.3)
|
46
|
+
mini_portile2 (~> 2.4.0)
|
47
|
+
oauth2 (1.4.1)
|
48
|
+
faraday (>= 0.8, < 0.16.0)
|
49
|
+
jwt (>= 1.0, < 3.0)
|
50
|
+
multi_json (~> 1.3)
|
51
|
+
multi_xml (~> 0.5)
|
52
|
+
rack (>= 1.2, < 3)
|
53
|
+
pry (0.12.2)
|
54
|
+
coderay (~> 1.1.0)
|
55
|
+
method_source (~> 0.9.0)
|
56
|
+
pry-byebug (3.7.0)
|
57
|
+
byebug (~> 11.0)
|
58
|
+
pry (~> 0.10)
|
59
|
+
pry-doc (0.13.5)
|
60
|
+
pry (~> 0.11)
|
61
|
+
yard (~> 0.9.11)
|
62
|
+
pry-remote (0.1.8)
|
63
|
+
pry (~> 0.9)
|
64
|
+
slop (~> 3.0)
|
65
|
+
pry-rescue (1.5.0)
|
66
|
+
interception (>= 0.5)
|
67
|
+
pry (>= 0.12.0)
|
68
|
+
pry-stack_explorer (0.4.9.3)
|
69
|
+
binding_of_caller (>= 0.7)
|
70
|
+
pry (>= 0.9.11)
|
71
|
+
public_suffix (3.0.3)
|
72
|
+
rack (2.0.7)
|
73
|
+
rake (12.3.2)
|
74
|
+
rdoc (3.12.2)
|
75
|
+
json (~> 1.4)
|
76
|
+
rspec (3.5.0)
|
77
|
+
rspec-core (~> 3.5.0)
|
78
|
+
rspec-expectations (~> 3.5.0)
|
79
|
+
rspec-mocks (~> 3.5.0)
|
80
|
+
rspec-core (3.5.4)
|
81
|
+
rspec-support (~> 3.5.0)
|
82
|
+
rspec-expectations (3.5.0)
|
83
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
+
rspec-support (~> 3.5.0)
|
85
|
+
rspec-mocks (3.5.0)
|
86
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
+
rspec-support (~> 3.5.0)
|
88
|
+
rspec-support (3.5.0)
|
89
|
+
semver (1.0.1)
|
90
|
+
simplecov (0.16.1)
|
91
|
+
docile (~> 1.1)
|
92
|
+
json (>= 1.8, < 3)
|
93
|
+
simplecov-html (~> 0.10.0)
|
94
|
+
simplecov-html (0.10.2)
|
95
|
+
slop (3.6.0)
|
96
|
+
thread_safe (0.3.6)
|
97
|
+
yard (0.9.19)
|
98
|
+
|
99
|
+
PLATFORMS
|
100
|
+
ruby
|
101
|
+
|
102
|
+
DEPENDENCIES
|
103
|
+
bundler (~> 1.0)
|
104
|
+
juwelier (~> 2.1.0)
|
105
|
+
pry (~> 0)
|
106
|
+
pry-byebug (~> 3)
|
107
|
+
pry-doc (~> 0)
|
108
|
+
pry-remote (~> 0)
|
109
|
+
pry-rescue (~> 1)
|
110
|
+
pry-stack_explorer (~> 0)
|
111
|
+
rdoc (~> 3.12)
|
112
|
+
rspec (~> 3.5.0)
|
113
|
+
simplecov
|
114
|
+
|
115
|
+
BUNDLED WITH
|
116
|
+
1.16.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2017 Raghu Betina
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# grade_runner
|
2
|
+
|
3
|
+
A Ruby client for [firstdraft Grades](https://grades.firstdraft.com)
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "grade_runner", git: "https://github.com/firstdraft/web_git"
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
```bash
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Copyright
|
20
|
+
---------
|
21
|
+
|
22
|
+
Copyright (c) 2018 Raghu Betina. See
|
23
|
+
LICENSE.txt for further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
require 'juwelier'
|
14
|
+
Juwelier::Tasks.new do |gem|
|
15
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
16
|
+
gem.name = "grade_runner"
|
17
|
+
gem.homepage = "http://github.com/firstdraft/grade_runner"
|
18
|
+
gem.license = "MIT"
|
19
|
+
gem.summary = %Q{A Ruby client for [firstdraft Grades](https://grades.firstdraft.com)}
|
20
|
+
gem.description = %Q{This gem runs your RSpec test suite and posts the JSON output to grades.firstdraft.com.}
|
21
|
+
gem.email = "raghu@firstdraft.com"
|
22
|
+
gem.authors = ["Raghu Betina"]
|
23
|
+
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Juwelier::RubygemsDotOrgTasks.new
|
27
|
+
require 'rspec/core'
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
30
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Code coverage detail"
|
34
|
+
task :simplecov do
|
35
|
+
ENV['COVERAGE'] = "true"
|
36
|
+
Rake::Task['spec'].execute
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "grade_runner #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# Generated by juwelier
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: grade_runner 0.0.2 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "grade_runner".freeze
|
9
|
+
s.version = "0.0.2"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib".freeze]
|
13
|
+
s.authors = ["Raghu Betina".freeze]
|
14
|
+
s.date = "2019-05-01"
|
15
|
+
s.description = "This gem runs your RSpec test suite and posts the JSON output to grades.firstdraft.com.".freeze
|
16
|
+
s.email = "raghu@firstdraft.com".freeze
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.markdown"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"LICENSE.txt",
|
27
|
+
"README.markdown",
|
28
|
+
"Rakefile",
|
29
|
+
"VERSION",
|
30
|
+
"grade_runner.gemspec",
|
31
|
+
"lib/grade_runner.rb",
|
32
|
+
"lib/grade_runner/railtie.rb",
|
33
|
+
"lib/grade_runner/runner.rb",
|
34
|
+
"lib/tasks/grade.rake",
|
35
|
+
"lib/tasks/grade_runner.rake",
|
36
|
+
"spec/spec_helper.rb"
|
37
|
+
]
|
38
|
+
s.homepage = "http://github.com/firstdraft/grade_runner".freeze
|
39
|
+
s.licenses = ["MIT".freeze]
|
40
|
+
s.rubygems_version = "2.7.8".freeze
|
41
|
+
s.summary = "A Ruby client for [firstdraft Grades](https://grades.firstdraft.com)".freeze
|
42
|
+
|
43
|
+
if s.respond_to? :specification_version then
|
44
|
+
s.specification_version = 4
|
45
|
+
|
46
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
+
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
48
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
49
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
50
|
+
s.add_development_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
51
|
+
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<pry>.freeze, ["~> 0"])
|
53
|
+
s.add_development_dependency(%q<pry-byebug>.freeze, ["~> 3"])
|
54
|
+
s.add_development_dependency(%q<pry-doc>.freeze, ["~> 0"])
|
55
|
+
s.add_development_dependency(%q<pry-remote>.freeze, ["~> 0"])
|
56
|
+
s.add_development_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
57
|
+
s.add_development_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
60
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
61
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
62
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
63
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
64
|
+
s.add_dependency(%q<pry>.freeze, ["~> 0"])
|
65
|
+
s.add_dependency(%q<pry-byebug>.freeze, ["~> 3"])
|
66
|
+
s.add_dependency(%q<pry-doc>.freeze, ["~> 0"])
|
67
|
+
s.add_dependency(%q<pry-remote>.freeze, ["~> 0"])
|
68
|
+
s.add_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
69
|
+
s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
70
|
+
end
|
71
|
+
else
|
72
|
+
s.add_dependency(%q<rspec>.freeze, ["~> 3.5.0"])
|
73
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 3.12"])
|
74
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 1.0"])
|
75
|
+
s.add_dependency(%q<juwelier>.freeze, ["~> 2.1.0"])
|
76
|
+
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
77
|
+
s.add_dependency(%q<pry>.freeze, ["~> 0"])
|
78
|
+
s.add_dependency(%q<pry-byebug>.freeze, ["~> 3"])
|
79
|
+
s.add_dependency(%q<pry-doc>.freeze, ["~> 0"])
|
80
|
+
s.add_dependency(%q<pry-remote>.freeze, ["~> 0"])
|
81
|
+
s.add_dependency(%q<pry-rescue>.freeze, ["~> 1"])
|
82
|
+
s.add_dependency(%q<pry-stack_explorer>.freeze, ["~> 0"])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "net/http"
|
2
|
+
module GradeRunner
|
3
|
+
class Runner
|
4
|
+
|
5
|
+
def initialize(submission_root_url, grades_access_token, rspec_output_json, username, reponame, sha, source)
|
6
|
+
@submission_url = submission_root_url + submission_path
|
7
|
+
@grades_access_token = grades_access_token
|
8
|
+
@rspec_output_json = rspec_output_json
|
9
|
+
@username = username
|
10
|
+
@reponame = reponame
|
11
|
+
@sha = sha
|
12
|
+
@source = source
|
13
|
+
end
|
14
|
+
|
15
|
+
def process
|
16
|
+
puts "* Submitting the results."
|
17
|
+
post_to_grades
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def post_to_grades
|
23
|
+
puts "- Posting to URL: " + "#{@submission_url}"
|
24
|
+
uri = URI.parse(@submission_url)
|
25
|
+
req = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')
|
26
|
+
req.body = data.to_json
|
27
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
28
|
+
http.request(req)
|
29
|
+
end
|
30
|
+
results_url = JSON.parse(res.body)["url"]
|
31
|
+
puts "- Done! Results URL: " + "#{results_url}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def submission_path
|
35
|
+
"/builds"
|
36
|
+
end
|
37
|
+
|
38
|
+
def data
|
39
|
+
{
|
40
|
+
access_token: @grades_access_token,
|
41
|
+
test_output: @rspec_output_json,
|
42
|
+
commit_sha: @sha,
|
43
|
+
username: @username,
|
44
|
+
reponame: @reponame,
|
45
|
+
source: @source
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
data/lib/grade_runner.rb
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
desc "Alias for \"grade:next\"."
|
2
|
+
task grade: "grade:all" do
|
3
|
+
end
|
4
|
+
|
5
|
+
namespace :grade do
|
6
|
+
desc "Run all tests and submit a build report."
|
7
|
+
task all: :environment do
|
8
|
+
ARGV.each { |a| task a.to_sym do ; end }
|
9
|
+
input_token = ARGV[1]
|
10
|
+
file_token = nil
|
11
|
+
|
12
|
+
config_file_name = Rails.root.join("grades.yml")
|
13
|
+
student_config = {}
|
14
|
+
student_config["submission_url"] = "https://grades.firstdraft.com"
|
15
|
+
|
16
|
+
if File.exist?(config_file_name)
|
17
|
+
begin
|
18
|
+
config = YAML.load_file(config_file_name)
|
19
|
+
rescue
|
20
|
+
abort "It looks like there's something wrong with your token in `/grades.yml`. Please delete that file and try `rails grade:all` again, and be sure to provide the access token for THIS project.".red
|
21
|
+
end
|
22
|
+
submission_url = config["submission_url"]
|
23
|
+
file_token = config["personal_access_token"]
|
24
|
+
student_config["submission_url"] = config["submission_url"]
|
25
|
+
else
|
26
|
+
submission_url = "https://grades.firstdraft.com"
|
27
|
+
end
|
28
|
+
|
29
|
+
if input_token.present?
|
30
|
+
token = input_token
|
31
|
+
student_config["personal_access_token"] = input_token
|
32
|
+
update_config_file(config_file_name, student_config)
|
33
|
+
elsif input_token.nil? && file_token.present?
|
34
|
+
token = file_token
|
35
|
+
elsif input_token.nil? && file_token.nil?
|
36
|
+
puts "Enter your access token for this project"
|
37
|
+
new_personal_access_token = ""
|
38
|
+
|
39
|
+
while new_personal_access_token == "" do
|
40
|
+
print "> "
|
41
|
+
new_personal_access_token = $stdin.gets.chomp.strip
|
42
|
+
|
43
|
+
if new_personal_access_token!= "" && is_valid_token?(submission_url, new_personal_access_token) == false
|
44
|
+
puts "Please enter valid token"
|
45
|
+
new_personal_access_token = ""
|
46
|
+
end
|
47
|
+
|
48
|
+
if new_personal_access_token != ""
|
49
|
+
student_config["personal_access_token"] = new_personal_access_token
|
50
|
+
update_config_file(config_file_name, student_config)
|
51
|
+
token = new_personal_access_token
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if token.present?
|
57
|
+
if is_valid_token?(submission_url, token) == false
|
58
|
+
student_config["personal_access_token"] = nil
|
59
|
+
update_config_file(config_file_name, student_config)
|
60
|
+
puts "Your access token looked invalid, so we've reset it to be blank. Please re-run rails grade and, when asked, copy-paste your token carefully from the assignment page."
|
61
|
+
else
|
62
|
+
path = Rails.root.join("/tmp/output/#{Time.now.to_i}.json")
|
63
|
+
`bin/rails db:migrate RAILS_ENV=test`
|
64
|
+
`RAILS_ENV=test bundle exec rspec --order default --format JsonOutputFormatter --out #{path}`
|
65
|
+
rspec_output_json = JSON.parse(File.read(path))
|
66
|
+
git_url = `git config --get remote.origin.url`.chomp
|
67
|
+
username = git_url.split(':')[1].split('/')[0]
|
68
|
+
reponame = git_url.split(':')[1].split('/')[1].sub(".git", "")
|
69
|
+
sha = `git rev-parse --verify HEAD`.chomp
|
70
|
+
|
71
|
+
GradeRunner::Runner.new(submission_url, token, rspec_output_json, username, reponame, sha, "manual").process
|
72
|
+
end
|
73
|
+
else
|
74
|
+
puts "We couldn't find your access token, so we couldn't record your grade. Please click on the assignment link again and run the rails grade ... command shown there."
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Run only the next failing test."
|
79
|
+
task next: :environment do
|
80
|
+
path = Rails.root.join("examples.txt")
|
81
|
+
if File.exist?(path)
|
82
|
+
`bin/rails db:migrate RAILS_ENV=test`
|
83
|
+
puts `RAILS_ENV=test bundle exec rspec --next-failure --format HintFormatter`
|
84
|
+
else
|
85
|
+
puts `RAILS_ENV=test bundle exec rspec`
|
86
|
+
puts "Please rerun rails grade:next to run the first failing spec"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
def update_config_file(config_file_name, config)
|
93
|
+
File.write(config_file_name, YAML.dump(config))
|
94
|
+
end
|
95
|
+
|
96
|
+
def is_valid_token?(root_url, token)
|
97
|
+
return false unless token.is_a?(String) && token =~ /^[1-9A-Za-z][^OIl]{23}$/
|
98
|
+
url = "#{root_url}/submissions/validate_token?token=#{token}"
|
99
|
+
uri = URI.parse(url)
|
100
|
+
req = Net::HTTP::Get.new(uri, 'Content-Type' => 'application/json')
|
101
|
+
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
102
|
+
http.request(req)
|
103
|
+
end
|
104
|
+
result = JSON.parse(res.body)
|
105
|
+
result["success"]
|
106
|
+
rescue => e
|
107
|
+
return false
|
108
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :grade_runner do
|
2
|
+
desc "Grade project"
|
3
|
+
task runner: :environment do
|
4
|
+
default_submission_url = "https://grades.firstdraft.com"
|
5
|
+
config = {}
|
6
|
+
path = Rails.root.join("grades.yml")
|
7
|
+
if File.exist?(path)
|
8
|
+
begin
|
9
|
+
config = YAML.load_file(path)
|
10
|
+
rescue
|
11
|
+
abort "It looks like there's something wrong with your token in `/grades.yml`. Please delete that file and try `rails grade:all` again, and be sure to provide the access token for THIS project.".red
|
12
|
+
end
|
13
|
+
end
|
14
|
+
rspec_output_json = JSON.parse(File.read("#{ENV['CIRCLE_ARTIFACTS']}/output/rspec_output.json"))
|
15
|
+
username = ENV["CIRCLE_PROJECT_USERNAME"]
|
16
|
+
reponame = ENV["CIRCLE_PROJECT_REPONAME"]
|
17
|
+
sha = ENV["CIRCLE_SHA1"]
|
18
|
+
token = ENV['GRADES_PERSONAL_ACCESS_TOKEN']
|
19
|
+
if token.present?
|
20
|
+
GradeRunner::Runner.new('', config['submission_url'] || default_submission_url, token, rspec_output_json, username, reponame, sha, 'circle_ci').process
|
21
|
+
else
|
22
|
+
puts "We couldn't find your access token, so we couldn't record your grade. Please click on the assignment link again and run the rails grade ... command shown there."
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grade_runner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Raghu Betina
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.5.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: juwelier
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.1.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry-doc
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry-remote
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry-rescue
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '1'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '1'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry-stack_explorer
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description: This gem runs your RSpec test suite and posts the JSON output to grades.firstdraft.com.
|
168
|
+
email: raghu@firstdraft.com
|
169
|
+
executables: []
|
170
|
+
extensions: []
|
171
|
+
extra_rdoc_files:
|
172
|
+
- LICENSE.txt
|
173
|
+
- README.markdown
|
174
|
+
files:
|
175
|
+
- ".document"
|
176
|
+
- ".rspec"
|
177
|
+
- Gemfile
|
178
|
+
- Gemfile.lock
|
179
|
+
- LICENSE.txt
|
180
|
+
- README.markdown
|
181
|
+
- Rakefile
|
182
|
+
- VERSION
|
183
|
+
- grade_runner.gemspec
|
184
|
+
- lib/grade_runner.rb
|
185
|
+
- lib/grade_runner/railtie.rb
|
186
|
+
- lib/grade_runner/runner.rb
|
187
|
+
- lib/tasks/grade.rake
|
188
|
+
- lib/tasks/grade_runner.rake
|
189
|
+
- spec/spec_helper.rb
|
190
|
+
homepage: http://github.com/firstdraft/grade_runner
|
191
|
+
licenses:
|
192
|
+
- MIT
|
193
|
+
metadata: {}
|
194
|
+
post_install_message:
|
195
|
+
rdoc_options: []
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
requirements:
|
200
|
+
- - ">="
|
201
|
+
- !ruby/object:Gem::Version
|
202
|
+
version: '0'
|
203
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - ">="
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
208
|
+
requirements: []
|
209
|
+
rubyforge_project:
|
210
|
+
rubygems_version: 2.7.8
|
211
|
+
signing_key:
|
212
|
+
specification_version: 4
|
213
|
+
summary: A Ruby client for [firstdraft Grades](https://grades.firstdraft.com)
|
214
|
+
test_files: []
|