cid 0.2.2 → 0.2.3
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 +8 -8
- data/.travis.yml +1 -0
- data/README.md +20 -8
- data/Rakefile +2 -1
- data/bin/cid +16 -0
- data/cid.gemspec +2 -0
- data/features/bootstrap.feature +42 -0
- data/features/support/env.rb +1 -1
- data/lib/cid.rb +4 -0
- data/lib/cid/bootstrap.rb +40 -0
- data/lib/cid/version.rb +1 -1
- metadata +33 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWE5MjE3MDc5N2RmYmYxYzVkMWI0MWZmZmUwM2I5ODhkOTg2NGUxZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDc4NzgwNWMyMzRhYzVjYjBkMmQ0ZDYxZjgxNjkzMjI3ZTFmMjVhNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NDQzZjMwYzM4NWVjYjQ4YmQzYWY0Y2Y5OTQzNGVhMzAyYTJiYmE1NjljYjNl
|
10
|
+
YWM5ZGIzMjg3YmM2NzM5NGJlZTUyNGRhNzI2NTkwMmZmMDk0OGQzZjYzMGFh
|
11
|
+
MmI0Y2JlYzM4MTQ2NjM1ZjM0YTVmOTczMGY2MTY0YmEwY2QwMDU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGIyMTdlMDkyZWI0MGIzODIyMmQ5OTNhM2RmNzRmOWUxYjU1YTBkYzA2Mzkx
|
14
|
+
M2MwMzc2ODRkNGFhZjZmODU1ODMyMGY4OTI3MTMwOTRhOGI1ZjhlMTdhMmUy
|
15
|
+
NGI2YmU2MDkzOTI5MTY2YTZhNmJhOTIyMWQxZTc5YjhkMmYzODM=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -65,7 +65,26 @@ If you just want to skip the GitHub push altogether, just run
|
|
65
65
|
|
66
66
|
## Getting this in Travis
|
67
67
|
|
68
|
-
Obviously, Cid is at its most powerful when used in a CI build. To get Cid working in Travis, simply
|
68
|
+
Obviously, Cid is at its most powerful when used in a CI build. To get Cid working in Travis, simply run:
|
69
|
+
|
70
|
+
cid bootstrap --github-token=YOUR_TOKEN_HERE
|
71
|
+
|
72
|
+
This will create a `.travis.yml` to your repo and add your encrypted Github key.
|
73
|
+
|
74
|
+
Then just add your repo to Travis, and push your changes.
|
75
|
+
|
76
|
+
Now whenever someone makes a pull request on your data, Cid will validate the
|
77
|
+
data against the schema, and you'll get a nice build status telling you if it's good to go!
|
78
|
+
|
79
|
+
If the branch is master, it will also generate a new `datapackage.json` and push that to Github.
|
80
|
+
|
81
|
+
If you would rather generate the `datapackage.json` on a different branch (for example, `gh-pages`),
|
82
|
+
simply add the option `branch` like so:
|
83
|
+
|
84
|
+
cid bootstrap --github-token=YOUR_TOKEN_HERE --branch=gh-pages
|
85
|
+
|
86
|
+
You can also do this manually if you prefer - simply add a `.travis.yml` file to your repo
|
87
|
+
that looks a bit like this:
|
69
88
|
|
70
89
|
before_script:
|
71
90
|
- gem install cid
|
@@ -74,17 +93,10 @@ Obviously, Cid is at its most powerful when used in a CI build. To get Cid worki
|
|
74
93
|
after_success:
|
75
94
|
- '[ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && cid publish'
|
76
95
|
|
77
|
-
This installs cid, runs the validation, and then (if the branch is master) generates a new `datapackage.json` and pushes it to github.
|
78
|
-
|
79
96
|
You'll also need to add your Github token to the `.travis.yml` file. To do this, just run:
|
80
97
|
|
81
|
-
gem install travis
|
82
98
|
travis encrypt GITHUB_OAUTH_TOKEN="YOUR_TOKEN_HERE" --add
|
83
99
|
|
84
|
-
Then just add your repo to Travis, and push your changes.
|
85
|
-
|
86
|
-
Now whenever someone makes a pull request on your data, Cid will validate the data against the schema, and you'll get a nice build status telling you if it's good to go!
|
87
|
-
|
88
100
|
## Examples
|
89
101
|
|
90
102
|
There's only two repos that use Cid so far (it is a new thing after all), and you can see it here:
|
data/Rakefile
CHANGED
@@ -11,7 +11,8 @@ require 'rspec/core/rake_task'
|
|
11
11
|
RSpec::Core::RakeTask.new(:spec)
|
12
12
|
Coveralls::RakeTask.new
|
13
13
|
Cucumber::Rake::Task.new(:features) do |t|
|
14
|
-
|
14
|
+
tags = "--tags ~@skip-ci" if ENV['TRAVIS']
|
15
|
+
t.cucumber_opts = "features --format pretty #{tags}"
|
15
16
|
end
|
16
17
|
|
17
18
|
task :default => [:spec, :features, 'coveralls:push']
|
data/bin/cid
CHANGED
@@ -7,6 +7,22 @@ require 'thor'
|
|
7
7
|
|
8
8
|
class CidBin < Thor
|
9
9
|
|
10
|
+
desc "bootstrap", "sets up your .travis.yml"
|
11
|
+
long_desc <<-LONGDESC
|
12
|
+
`cid bootstrap` will populate your repo's `.travis.yml` file.
|
13
|
+
LONGDESC
|
14
|
+
option :branch, :type => :string, :desc => "The branch you want to deploy from (default is master)"
|
15
|
+
option :github_token, :type => :string, :desc => "Your Github Oauth Token"
|
16
|
+
def bootstrap
|
17
|
+
branch = options[:branch] || "master"
|
18
|
+
travis = Cid::Bootstrap.new(:branch => branch, :github_token => options[:github_token])
|
19
|
+
travis.perform
|
20
|
+
if travis.no_remote === true
|
21
|
+
puts "Warning: Can't figure out GitHub repo name. Please ensure your directory contains a Github remote".colorize(:red)
|
22
|
+
end
|
23
|
+
puts "Cid sucessfully bootstrapped!".colorize(:green)
|
24
|
+
end
|
25
|
+
|
10
26
|
desc "validate PATH", "validate a package"
|
11
27
|
long_desc <<-LONGDESC
|
12
28
|
`cid validate` will validate a datapackage containing CSVs and schemas.
|
data/cid.gemspec
CHANGED
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_dependency "dotenv"
|
26
26
|
spec.add_dependency "memoist"
|
27
27
|
spec.add_dependency "thor"
|
28
|
+
spec.add_dependency "travis"
|
28
29
|
|
29
30
|
spec.add_development_dependency "bundler", "~> 1.3"
|
30
31
|
spec.add_development_dependency "rake"
|
@@ -37,5 +38,6 @@ Gem::Specification.new do |spec|
|
|
37
38
|
spec.add_development_dependency "spork"
|
38
39
|
spec.add_development_dependency "vcr"
|
39
40
|
spec.add_development_dependency "webmock"
|
41
|
+
spec.add_development_dependency "aruba-doubles"
|
40
42
|
|
41
43
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
@bootstrap @inprocess
|
2
|
+
Feature: Bootstrap .travis.yml file
|
3
|
+
|
4
|
+
Scenario: Create a .travis.yml file
|
5
|
+
Given I run `cp -r ../../spec/fixtures/valid valid`
|
6
|
+
And I cd to "valid"
|
7
|
+
When I run `cid bootstrap`
|
8
|
+
And I run `cat .travis.yml`
|
9
|
+
Then the output should contain:
|
10
|
+
"""
|
11
|
+
---
|
12
|
+
before_script: gem install cid
|
13
|
+
script: cid validate
|
14
|
+
after_success: '[ "$TRAVIS_BRANCH" == "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && cid publish'
|
15
|
+
|
16
|
+
"""
|
17
|
+
|
18
|
+
Scenario: Specify different branch
|
19
|
+
Given I run `cp -r ../../spec/fixtures/valid valid`
|
20
|
+
And I cd to "valid"
|
21
|
+
When I run `cid bootstrap --branch=gh-pages`
|
22
|
+
And I run `cat .travis.yml`
|
23
|
+
Then the output should contain "gh-pages"
|
24
|
+
|
25
|
+
@skip-ci
|
26
|
+
Scenario: Create a .travis.yml file with a Github token
|
27
|
+
Given I run `git clone https://github.com/theodi/cid-test.git`
|
28
|
+
And I cd to "cid-test"
|
29
|
+
And I run `rm .travis.yml`
|
30
|
+
When I run `cid bootstrap --github-token=foobarbaz`
|
31
|
+
Then the output should not contain "Can't figure out GitHub repo name."
|
32
|
+
And I run `cat .travis.yml`
|
33
|
+
Then the output should contain "secure:"
|
34
|
+
|
35
|
+
@skip-ci
|
36
|
+
Scenario: Not in a repo with a Github remote
|
37
|
+
Given I run `mkdir no-remote && cd no-remote`
|
38
|
+
And I set up a new git repo
|
39
|
+
And I run `cid bootstrap --github-token=foobarbaz`
|
40
|
+
Then the output should contain "Can't figure out GitHub repo name."
|
41
|
+
And I run `cat .travis.yml`
|
42
|
+
Then the output should not contain "secure:"
|
data/features/support/env.rb
CHANGED
data/lib/cid.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Cid
|
2
|
+
class Bootstrap
|
3
|
+
|
4
|
+
attr_accessor :no_remote
|
5
|
+
|
6
|
+
def initialize(options)
|
7
|
+
@branch = options[:branch]
|
8
|
+
@github_token = options[:github_token]
|
9
|
+
end
|
10
|
+
|
11
|
+
def perform
|
12
|
+
write
|
13
|
+
if @github_token
|
14
|
+
encrypt_token
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def encrypt_token
|
19
|
+
output = `travis encrypt GITHUB_OAUTH_TOKEN=#{@github_token} --add`
|
20
|
+
no_remote = true if output.match /Can't figure out GitHub repo name/
|
21
|
+
end
|
22
|
+
|
23
|
+
def write
|
24
|
+
File.write(travis_yaml, yaml_string)
|
25
|
+
end
|
26
|
+
|
27
|
+
def travis_yaml(dir = Dir.pwd)
|
28
|
+
path = File.expand_path('.travis.yml', dir)
|
29
|
+
end
|
30
|
+
|
31
|
+
def yaml_string
|
32
|
+
{
|
33
|
+
'before_script' => 'gem install cid',
|
34
|
+
'script' => 'cid validate',
|
35
|
+
'after_success' => "[ \"$TRAVIS_BRANCH\" == \"#{@branch}\" ] && [ \"$TRAVIS_PULL_REQUEST\" == \"false\" ] && cid publish"
|
36
|
+
}.to_yaml(options = {line_width: -1})
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/cid/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pezholio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: csvlint
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ! '>='
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: travis
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
140
|
name: bundler
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -276,6 +290,20 @@ dependencies:
|
|
276
290
|
- - ! '>='
|
277
291
|
- !ruby/object:Gem::Version
|
278
292
|
version: '0'
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: aruba-doubles
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - ! '>='
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: '0'
|
300
|
+
type: :development
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - ! '>='
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: '0'
|
279
307
|
description:
|
280
308
|
email:
|
281
309
|
- pezholio@gmail.com
|
@@ -292,11 +320,13 @@ files:
|
|
292
320
|
- Rakefile
|
293
321
|
- bin/cid
|
294
322
|
- cid.gemspec
|
323
|
+
- features/bootstrap.feature
|
295
324
|
- features/publish.feature
|
296
325
|
- features/step_definitions/cid.rb
|
297
326
|
- features/support/env.rb
|
298
327
|
- features/validate.feature
|
299
328
|
- lib/cid.rb
|
329
|
+
- lib/cid/bootstrap.rb
|
300
330
|
- lib/cid/datapackage.rb
|
301
331
|
- lib/cid/helpers/github.rb
|
302
332
|
- lib/cid/publish.rb
|
@@ -354,6 +384,7 @@ signing_key:
|
|
354
384
|
specification_version: 4
|
355
385
|
summary: Tools to allow continuous integration when collaborating on data in Github
|
356
386
|
test_files:
|
387
|
+
- features/bootstrap.feature
|
357
388
|
- features/publish.feature
|
358
389
|
- features/step_definitions/cid.rb
|
359
390
|
- features/support/env.rb
|