skynet-deploy 1.2.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d95d2b638d8f8be544d5c42e7e6641cc5cb25d15c7b7ede90cb1619cef4898ee
4
+ data.tar.gz: 2442555551e7836aed334417344571c7e0aaf54e83960e2f3dc4c6d718992445
5
+ SHA512:
6
+ metadata.gz: 5c4e37a158a27f1b1e95c448d6ca7b11cf2e66f1398c874a89950fad652bdb338552c9c4724f937c5c9b972b880e3d1021c8d1b6d64544d8ea718822f98dd2db
7
+ data.tar.gz: 9d89854abc786aad9e87e3d1d5061525d2c0aa6431a668e1b67b64e87d39435d8547af35de4a4a24e90b5f3a9aea345454df18c94c22c6105e11a13764f4ed65
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  spec/test.log
6
+ tags
@@ -0,0 +1 @@
1
+ 2.7.2
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.7
4
+ - ruby-head
5
+ matrix:
6
+ allow_failures:
7
+ - rvm: ruby-head
8
+ script: bundle exec rake spec
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  Skynet
2
2
  ======
3
3
 
4
+ [![Build Status](https://travis-ci.com/rahearn/skynet.svg?branch=master)](https://travis-ci.com/rahearn/skynet)
5
+
4
6
  GitHub-aware website builder
5
7
 
6
8
  Skynet builds and deploys web sites on your VPS or bare metal server. It is triggered by the post-receive hook.
@@ -20,7 +22,8 @@ Usage
20
22
  * Install basic config file: `$ skynet config <first project name>`
21
23
  * edit config file to add your repositories
22
24
  * Run builder by hand to ensure everything works: `$ skynet build`
23
- * Add `http://YOUR_SKYNET_SERVER/PROJECT_NAME` as a WebHook URL to your repository under `Admin -> Service Hooks`
25
+ * Add `http://YOUR_SKYNET_SERVER/PROJECT_NAME` as a Webhook Payload URL to your repository under
26
+ `Settings -> Webhooks`. Choose `application/json` as the Content type.
24
27
  * Start server: `$ skynet server`
25
28
 
26
29
  Config file arguments
@@ -55,3 +58,8 @@ a git server other than GitHub.
55
58
 
56
59
  The URL must be visible from the Skynet server, as it will pull a new
57
60
  copy of the repository from this server.
61
+
62
+ Upgrading from 1.x
63
+ ==================
64
+
65
+ * Private repositories must explicitly set the `repository` key in the config to the ssh-compatible url. Previously this was optional for Github repos
@@ -1,6 +1,9 @@
1
1
  require 'skynet/version'
2
2
  require 'logger'
3
3
 
4
+ require 'i18n'
5
+ I18n.enforce_available_locales = false
6
+
4
7
  module Skynet
5
8
 
6
9
  autoload :Builder, 'skynet/builder'
@@ -10,7 +13,7 @@ module Skynet
10
13
  autoload :HookGenerator, 'skynet/hook_generator'
11
14
 
12
15
  def self.logger
13
- @logger ||= Logger.new(STDOUT)
16
+ @logger ||= Logger.new($stdout)
14
17
  end
15
18
 
16
19
  def self.logger=(logger)
@@ -3,19 +3,21 @@ require 'json'
3
3
  require 'active_support/core_ext/object/blank'
4
4
 
5
5
  module Skynet
6
-
7
6
  class App < Sinatra::Base
8
-
9
7
  before do
10
- @payload = JSON.parse params[:payload] unless params[:payload].nil?
8
+ @payload = begin
9
+ JSON.parse request.body.read
10
+ rescue JSON::ParserError
11
+ {}
12
+ end
11
13
  end
12
14
 
13
15
  get '/' do
14
- %[Hello. Check <a href="https://github.com/coshx/skynet">github</a> for more infomation on skynet]
16
+ %[Hello. Check <a href="https://github.com/rahearn/skynet">github</a> for more infomation on skynet]
15
17
  end
16
18
 
17
19
  post '/' do
18
- Skynet.logger.debug "post root params: #{params.inspect}"
20
+ Skynet.logger.debug "post '/' payload: #{@payload.inspect}"
19
21
  app_name = settings.config.each { |n, c| break n if c[:url] == @payload['repository']['url'] }
20
22
  if app_name.is_a? String
21
23
  deploy app_name
@@ -26,14 +28,14 @@ module Skynet
26
28
  end
27
29
 
28
30
  post '/:app_name' do |app_name|
29
- Skynet.logger.debug "post /#{app_name} params: #{params.inspect}"
31
+ Skynet.logger.debug "post '/#{app_name}' payload: #{@payload.inspect}"
30
32
  deploy app_name
31
33
  end
32
34
 
33
35
  private
34
36
 
35
37
  def deploy(app_name)
36
- Skynet.logger.info %{Attempting to deploy "#{app_name.class.name}"}
38
+ Skynet.logger.info %{Attempting to deploy "#{app_name}"}
37
39
  config = settings.config[app_name]
38
40
  if deployable? config
39
41
  Builder.build app_name, config, branch
@@ -44,15 +46,18 @@ module Skynet
44
46
  end
45
47
 
46
48
  def deployable?(config)
49
+ Skynet.logger.debug "Payload url: #{@payload['repository']['url']}"
50
+ Skynet.logger.debug "Payload after: #{@payload['after']}"
47
51
  config.present? &&
48
52
  config[:url] == @payload['repository']['url'] &&
53
+ @payload['after'].present? &&
49
54
  @payload['after'] !~ /^0{40}$/
50
55
  end
51
56
 
52
57
  def branch
58
+ Skynet.logger.debug "Payload ref: #{@payload['ref']}"
53
59
  @payload['ref'] =~ %r[^refs/heads/(.*)$]
54
60
  $1
55
61
  end
56
62
  end
57
-
58
63
  end
@@ -13,7 +13,7 @@ module Skynet
13
13
  attr_accessor :app, :url, :branch, :destination, :branches, :type, :repository
14
14
  attr_reader :source, :key
15
15
 
16
- validates_presence_of :app, :url, :branch, :destination, :branches
16
+ validates_presence_of :app, :url, :branches, :branch, :destination
17
17
  validates_inclusion_of :type,
18
18
  in: ALLOWED_BUILDERS,
19
19
  message: "must be one of #{ALLOWED_BUILDERS}"
@@ -26,26 +26,28 @@ module Skynet
26
26
  @source = File.join Dir.pwd, app, '.'
27
27
  @key = config[:key]
28
28
 
29
- if config[:branches].blank?
30
- Skynet.logger.warn "Passing a single branch and destination is deprecated and will be removed in 2.0"
31
- Skynet.logger.warn "Please change to:\nbranches:\n #{config[:branch]}: #{config[:destination]}"
32
- self.branches = { config[:branch] => config[:destination] }
33
- else
34
- self.branches = config[:branches]
29
+ self.branches = config[:branches]
30
+ if branches.present? && branches.first.present?
31
+ self.branch = branches.first[0]
32
+ self.destination = branches.first[1]
35
33
  end
36
- self.branch = branches.first[0]
37
- self.destination = branches.first[1]
38
- self.url = config[:url]
39
- self.type = config[:type]
40
- self.repository = config[:repository]
34
+ self.url = config[:url]
35
+ self.type = config[:type]
36
+ self.repository = config[:repository]
41
37
  end
42
38
 
43
39
  def build(branch=nil)
44
- unless branch.blank?
40
+ if branch.present?
45
41
  return if branches[branch].blank?
46
42
  self.branches = { branch => branches[branch] }
47
43
  end
48
44
 
45
+ unless valid?
46
+ Skynet.logger.error "Configuration error for #{app} (branch: #{branch})"
47
+ Skynet.logger.error errors.full_messages.join '. '
48
+ raise ArgumentError
49
+ end
50
+
49
51
  branches.each_pair do |branch, destination|
50
52
  self.branch = branch.to_s
51
53
  self.destination = destination
@@ -70,18 +72,7 @@ module Skynet
70
72
  end
71
73
 
72
74
  def remote_repository
73
- repository || translate_url
74
- end
75
-
76
- def translate_url
77
- uri = URI.parse url
78
- if uri.host == 'github.com'
79
- "git@github.com:#{uri.path.gsub %r[(^/)|(/$)|(\.git$)], ''}.git"
80
- else
81
- url
82
- end
83
- rescue URI::InvalidURIError
84
- url
75
+ repository || url
85
76
  end
86
77
 
87
78
  def create_repo
@@ -6,7 +6,7 @@ module Skynet
6
6
 
7
7
  def execute
8
8
  Skynet.logger.debug "PWD: #{Dir.pwd} Source: #{source} Destination: #{destination}"
9
- Skynet.logger.info `jekyll --no-server --no-auto #{source} #{destination}`
9
+ Skynet.logger.info `jekyll build --source #{source} --destination #{destination}`
10
10
 
11
11
  Skynet.logger.info 'Jekyll finished'
12
12
  end
@@ -20,9 +20,9 @@ module Skynet
20
20
  method_option :port, type: :numeric, default: 7575, aliases: '-p', desc: 'Port to listen on'
21
21
  method_option :host, type: :string, default: '0.0.0.0', aliases: '-h', desc: 'Interface to listen on'
22
22
  method_option :file, type: :string, default: './config.yml', aliases: '-f', desc: 'Configuration file'
23
- method_option :log, type: :string, default: 'skynet.log', aliases: '-l', desc: 'Log file'
23
+ method_option :log, type: :string, aliases: '-l', desc: 'Log file'
24
24
  def server
25
- Skynet.logger = Logger.new options[:log], 'weekly'
25
+ Skynet.logger = Logger.new(options[:log], 'weekly') unless options[:log].nil?
26
26
 
27
27
  unless File.exist? options[:file]
28
28
  Skynet.logger.fatal "Configuration file #{options[:file]} cannot be found"
@@ -1,3 +1,3 @@
1
1
  module Skynet
2
- VERSION = "1.2.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -19,9 +19,9 @@ module Skynet
19
19
  def repository_url
20
20
  if ask('Is the repository on github? (y/n)').downcase == 'y'
21
21
  @github = true
22
- owner = ask 'Repository owner:'
23
- project = ask 'Github project name:'
24
- "https://github.com/#{owner}/#{project}"
22
+ @owner = ask 'Repository owner:'
23
+ @project = ask 'Github project name:'
24
+ "https://github.com/#{@owner}/#{@project}"
25
25
  else
26
26
  @github = false
27
27
  ask 'Repository URL:'
@@ -40,9 +40,13 @@ module Skynet
40
40
  def private_key
41
41
  needs_key = ask('Is this a private repository? (y/n)').downcase
42
42
  if needs_key == 'y'
43
- [" key: #{ask 'Full path to ssh key:'}"].tap do |pk|
44
- pk << " repository: #{ask 'SSH repository address:'}" unless @github
45
- end.join "\n"
43
+ private_configs = [" key: #{ask 'Full path to ssh key:'}"]
44
+ if @github
45
+ private_configs << " repository: git@github.com:#{@owner}/#{@project}.git"
46
+ else
47
+ private_configs << " repository: #{ask 'SSH repository address:'}"
48
+ end
49
+ private_configs.join "\n"
46
50
  else
47
51
  nil
48
52
  end
@@ -7,28 +7,28 @@ Gem::Specification.new do |s|
7
7
  s.version = Skynet::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["Ryan Ahearn"]
10
- s.email = ["ryan@coshx.com"]
11
- s.homepage = "https://github.com/coshx/skynet"
10
+ s.email = ["ryan.ahearn@hey.com"]
11
+ s.homepage = "https://github.com/rahearn/skynet"
12
12
  s.summary = %q{Sinatra app that listens for GitHub post-receive callbacks and deploys your code}
13
13
  s.description = %q{Sinatra app that listens for GitHub post-receive callbacks and deploys your code}
14
14
 
15
- s.required_rubygems_version = ">= 1.3.6"
15
+ s.required_ruby_version = ">= 2.7.1"
16
16
 
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
- s.add_runtime_dependency 'sinatra', '~> 1.3'
23
- s.add_runtime_dependency 'thin', '~> 1.4'
24
- s.add_runtime_dependency 'json', '~> 1.7'
25
- s.add_runtime_dependency 'jekyll', '~> 0.11'
26
- s.add_runtime_dependency 'thor', '~> 0.16'
27
- s.add_runtime_dependency 'activesupport', '~> 3.2'
28
- s.add_runtime_dependency 'activemodel', '~> 3.2'
29
- s.add_runtime_dependency 'multi_json', '~> 1.0'
22
+ s.add_runtime_dependency 'sinatra', '~> 2.1'
23
+ s.add_runtime_dependency 'thin', '~> 1.7'
24
+ s.add_runtime_dependency 'json', '~> 2.3'
25
+ s.add_runtime_dependency 'jekyll', '~> 4.1'
26
+ s.add_runtime_dependency 'thor', '~> 1.0'
27
+ s.add_runtime_dependency 'activesupport', '~> 6.0'
28
+ s.add_runtime_dependency 'activemodel', '~> 6.0'
29
+ s.add_runtime_dependency 'multi_json', '~> 1.15'
30
30
 
31
- s.add_development_dependency 'rake', '~> 0.9'
32
- s.add_development_dependency 'rspec', '~> 2.11'
33
- s.add_development_dependency 'shoulda-matchers', '~> 1.2'
31
+ s.add_development_dependency 'rake', '~> 13.0'
32
+ s.add_development_dependency 'rspec', '~> 3.9'
33
+ s.add_development_dependency 'shoulda-matchers', '~> 4.4'
34
34
  end
@@ -1,13 +1,11 @@
1
1
  require 'spec_helper'
2
- require 'active_model'
3
- require 'shoulda-matchers'
4
2
 
5
- describe Skynet::Builder::Base do
3
+ describe Skynet::Builder::Base, type: :model do
6
4
 
7
5
  let(:source) { File.join Dir.pwd, 'app', '.' }
8
6
  let(:url) { 'https://github.com/org/app' }
9
7
  let(:repo) { 'git@github.com:org/app.git' }
10
- let(:options) { {url: url, branch: 'master', destination: '/var/www', type: 'static'} }
8
+ let(:options) { {url: url, branches: {main: '/var/www'}, type: 'static'} }
11
9
  subject { described_class.new 'app', options }
12
10
 
13
11
  describe ".validations" do
@@ -16,48 +14,48 @@ describe Skynet::Builder::Base do
16
14
  it { should validate_presence_of :branch }
17
15
  it { should validate_presence_of :destination }
18
16
  it { should validate_presence_of :branches }
19
- it { should ensure_inclusion_of(:type).in_array(%w[static jekyll]).allow_nil(false).allow_blank(false) }
17
+ it { should validate_inclusion_of(:type).in_array(%w[static jekyll]).with_message("must be one of [\"static\", \"jekyll\"]") }
20
18
  it { should_not allow_value('base').for :type }
21
19
  describe "on @branches" do
22
20
  before(:each) { subject.valid? }
23
21
 
24
22
  context "when passed a single branch" do
25
- specify { subject.errors[:branches].should be_empty }
23
+ specify { expect(subject.errors[:branches]).to be_empty }
26
24
  end
27
25
  context "when passed multiple valid branches" do
28
- let(:options) { {url: url, type: 'static', branches: {master: '/var/www/production', develop: '/var/www/staging'}} }
29
- specify { subject.errors[:branches].should be_empty }
26
+ let(:options) { {url: url, type: 'static', branches: {main: '/var/www/production', develop: '/var/www/staging'}} }
27
+ specify { expect(subject.errors[:branches]).to be_empty }
30
28
  end
31
29
  context "when passed an invalid branch" do
32
- let(:options) { {url: url, type: 'static', branches: {master: '/var/www', develop: ''}} }
30
+ let(:options) { {url: url, type: 'static', branches: {main: '/var/www', develop: ''}} }
33
31
  it "has an error on branches" do
34
- subject.errors[:branches].should include('develop must have a destination')
32
+ expect(subject.errors[:branches]).to include('develop must have a destination')
35
33
  end
36
34
  end
37
35
  end
38
36
  describe "on @key" do
39
37
  context "when not passed a key" do
40
38
  before(:each) { subject.valid? }
41
- specify { subject.errors[:key].should be_empty }
39
+ specify { expect(subject.errors[:key]).to be_empty }
42
40
  end
43
41
 
44
42
  context "when passed a valid key" do
45
- let(:options) { {key: 'keyfile'} }
43
+ let(:options) { {branches: {main: "/tmp"}, key: 'keyfile'} }
46
44
  before(:each) do
47
- File.stub(:readable?).and_return true
45
+ allow(File).to receive(:readable?).and_return true
48
46
  subject.valid?
49
47
  end
50
- specify { subject.errors[:key].should be_empty }
48
+ specify { expect(subject.errors[:key]).to be_empty }
51
49
  end
52
50
 
53
51
  context "when passed an invalid key" do
54
- let(:options) { {key: 'missing_keyfile'} }
52
+ let(:options) { {branches: {main: "/tmp"}, key: 'missing_keyfile'} }
55
53
  before(:each) do
56
- File.stub(:readable?).and_return false
54
+ allow(File).to receive(:readable?).and_return false
57
55
  subject.valid?
58
56
  end
59
57
  it "has an error on key" do
60
- subject.errors[:key].should include('must be present and readable')
58
+ expect(subject.errors[:key]).to include('must be present and readable')
61
59
  end
62
60
  end
63
61
  end
@@ -65,8 +63,8 @@ describe Skynet::Builder::Base do
65
63
 
66
64
  describe "#build" do
67
65
  before(:each) do
68
- subject.stub :build_repository
69
- subject.stub :execute
66
+ allow(subject).to receive(:build_repository)
67
+ allow(subject).to receive(:execute)
70
68
  end
71
69
 
72
70
  context "when valid" do
@@ -77,7 +75,7 @@ describe Skynet::Builder::Base do
77
75
  it { expect { subject.build }.to raise_error ArgumentError }
78
76
  end
79
77
  context "when passing a branch" do
80
- it { expect { subject.build 'master' }.to_not raise_error }
78
+ it { expect { subject.build 'main' }.to_not raise_error }
81
79
  it "d" do
82
80
  subject.build 'develop'
83
81
  end
@@ -86,44 +84,44 @@ describe Skynet::Builder::Base do
86
84
 
87
85
  context "private methods" do
88
86
  before(:each) do
89
- subject.branch = 'master'
87
+ subject.branch = 'main'
90
88
  subject.destination = '/var/www'
91
89
  end
92
90
 
93
91
  describe "#build_repository" do
94
92
  context "repo already exists" do
95
- before(:each) { subject.stub(:repo_exists?).and_return true }
93
+ before(:each) { allow(subject).to receive(:repo_exists?).and_return true }
96
94
 
97
95
  it "updates the repository" do
98
- subject.should_receive(:update_repo).with no_args
96
+ expect(subject).to receive(:update_repo).with no_args
99
97
  subject.send :build_repository
100
98
  end
101
99
  end
102
100
 
103
101
  context "repo does not exist" do
104
- before(:each) { subject.stub(:repo_exists?).and_return false }
102
+ before(:each) { allow(subject).to receive(:repo_exists?).and_return false }
105
103
 
106
104
  it "creates a new repository" do
107
- subject.should_receive(:create_repo).with no_args
105
+ expect(subject).to receive(:create_repo).with no_args
108
106
  subject.send :build_repository
109
107
  end
110
108
  end
111
109
  end
112
110
 
113
111
  describe "#create_repo" do
114
- before(:each) { subject.should_receive(:`).with "rm -rf #{source}" }
112
+ before(:each) { expect(subject).to receive(:`).with "rm -rf #{source}" }
115
113
 
116
114
  context "without key" do
117
115
  it "should call git clone" do
118
- subject.should_receive(:`).with "git clone #{repo} app; cd #{source}; git checkout master"
116
+ expect(subject).to receive(:`).with "git clone #{url} app; cd #{source}; git checkout main"
119
117
  subject.send :create_repo
120
118
  end
121
119
  end
122
120
 
123
121
  context "with key" do
124
- let(:options) { {key: 'keyfile', url: url, branch: 'master', destination: '/var/www', type: 'static'} }
122
+ let(:options) { {key: 'keyfile', url: url, repository: repo, branches: {main: '/var/www'}, type: 'static'} }
125
123
  it "should call git clone" do
126
- subject.should_receive(:`).with "ssh-agent bash -c 'ssh-add keyfile; git clone #{repo} app'; cd #{source}; git checkout master"
124
+ expect(subject).to receive(:`).with "ssh-agent bash -c 'ssh-add keyfile; git clone #{repo} app'; cd #{source}; git checkout main"
127
125
  subject.send :create_repo
128
126
  end
129
127
  end
@@ -132,15 +130,15 @@ describe Skynet::Builder::Base do
132
130
  describe "#update_repo" do
133
131
  context "without key" do
134
132
  it "should call git pull" do
135
- subject.should_receive(:`).with "cd #{source}; git checkout master; git pull origin master"
133
+ expect(subject).to receive(:`).with "cd #{source}; git checkout main; git pull origin main"
136
134
  subject.send :update_repo
137
135
  end
138
136
  end
139
137
 
140
138
  context "with key" do
141
- let(:options) { {key: 'keyfile', url: url, branch: 'master', destination: '/var/www', type: 'static'} }
139
+ let(:options) { {key: 'keyfile', url: url, branches: {main: '/var/www'}, type: 'static'} }
142
140
  it "should call git pull" do
143
- subject.should_receive(:`).with "cd #{source}; git checkout master; ssh-agent bash -c 'ssh-add keyfile; git pull origin master'"
141
+ expect(subject).to receive(:`).with "cd #{source}; git checkout main; ssh-agent bash -c 'ssh-add keyfile; git pull origin main'"
144
142
  subject.send :update_repo
145
143
  end
146
144
  end
@@ -148,7 +146,7 @@ describe Skynet::Builder::Base do
148
146
 
149
147
  describe "#repo_exists?" do
150
148
  before(:each) do
151
- File.should_receive(:exist?).with File.join(source, '.git')
149
+ expect(File).to receive(:exist?).with(File.join(source, '.git'))
152
150
  end
153
151
 
154
152
  it { subject.send :repo_exists? }
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Skynet::Builder::Jekyll do
3
+ describe Skynet::Builder::Jekyll, type: :model do
4
4
 
5
5
  let(:app) { 'app' }
6
6
  let(:dest) { '/var/www/app' }
7
- let(:options) { {destination: dest} }
7
+ let(:options) { {branches: {main: dest}} }
8
8
  let(:source) { File.join Dir.pwd, app, '.' }
9
9
  subject do
10
10
  described_class.new(app, options).tap do |b|
@@ -14,7 +14,7 @@ describe Skynet::Builder::Jekyll do
14
14
 
15
15
  describe "#execute" do
16
16
  it "runs jekyll with the source and destination" do
17
- subject.should_receive(:`).with "jekyll --no-server --no-auto #{source} #{dest}"
17
+ expect(subject).to receive(:`).with "jekyll build --source #{source} --destination #{dest}"
18
18
  subject.execute
19
19
  end
20
20
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Skynet::Builder::Static do
3
+ describe Skynet::Builder::Static, type: :model do
4
4
 
5
5
  let(:app) { 'app' }
6
6
  let(:dest) { '/var/www/app' }
7
- let(:options) { {destination: dest} }
7
+ let(:options) { {branches: {main: dest}} }
8
8
  let(:source) { File.join Dir.pwd, app, '.' }
9
9
  subject do
10
10
  described_class.new(app, options).tap do |b|
@@ -13,26 +13,26 @@ describe Skynet::Builder::Static do
13
13
  end
14
14
 
15
15
  describe "#execute" do
16
- before(:each) { Dir.stub(:glob).and_return [:one, :two] }
16
+ before(:each) { allow(Dir).to receive(:glob).and_return([:one, :two]) }
17
17
 
18
18
  it "removes destination files first" do
19
- FileUtils.stub :remove_entry_secure
20
- FileUtils.stub :cp_r
21
- FileUtils.should_receive(:rm_rf).with [:one, :two], secure: true
19
+ allow(FileUtils).to receive(:remove_entry_secure)
20
+ allow(FileUtils).to receive(:cp_r)
21
+ expect(FileUtils).to receive(:rm_rf).with([:one, :two], secure: true)
22
22
  subject.execute
23
23
  end
24
24
 
25
25
  it "copies files to the destination" do
26
- FileUtils.stub :rm_rf
27
- FileUtils.stub :remove_entry_secure
28
- FileUtils.should_receive(:cp_r).with(source, dest)
26
+ allow(FileUtils).to receive(:rm_rf)
27
+ allow(FileUtils).to receive(:remove_entry_secure)
28
+ expect(FileUtils).to receive(:cp_r).with(source, dest)
29
29
  subject.execute
30
30
  end
31
31
 
32
32
  it "removes .git from the destination" do
33
- FileUtils.stub :rm_rf
34
- FileUtils.stub :cp_r
35
- FileUtils.should_receive(:remove_entry_secure).with "#{dest}/.git"
33
+ allow(FileUtils).to receive(:rm_rf)
34
+ allow(FileUtils).to receive(:cp_r)
35
+ expect(FileUtils).to receive(:remove_entry_secure).with("#{dest}/.git")
36
36
  subject.execute
37
37
  end
38
38
  end
@@ -2,16 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  describe Skynet::Builder do
4
4
 
5
- let(:builder) { mock('builder').as_null_object }
6
- let(:mock_class) { mock('builder class').as_null_object }
5
+ let(:builder) { double('builder').as_null_object }
6
+ let(:mock_class) { double('builder class').as_null_object }
7
7
  let(:config) { {type: 'static'} }
8
8
 
9
9
  describe ".for_app" do
10
10
  let(:args) { [:app, config] }
11
11
 
12
12
  it "initializes a new builder class" do
13
- described_class.should_receive(:const_get).with('Static').and_return mock_class
14
- mock_class.should_receive(:new).with(:app, config).and_return builder
13
+ expect(described_class).to receive(:const_get).with('Static').and_return(mock_class)
14
+ expect(mock_class).to receive(:new).with(:app, config).and_return(builder)
15
15
 
16
16
  described_class.for_app *args
17
17
  end
@@ -21,8 +21,8 @@ describe Skynet::Builder do
21
21
  let(:args) { [:app, config, :master] }
22
22
 
23
23
  it "calls build on the new builder" do
24
- described_class.stub(:for_app).and_return builder
25
- builder.should_receive(:build).with :master
24
+ allow(described_class).to receive(:for_app).and_return(builder)
25
+ expect(builder).to receive(:build).with(:master)
26
26
 
27
27
  described_class.build *args
28
28
  end
@@ -1,4 +1,6 @@
1
1
  require 'bundler/setup'
2
+ require 'active_model'
3
+ require 'shoulda-matchers'
2
4
 
3
5
  require 'skynet'
4
6
 
@@ -6,4 +8,15 @@ Skynet.logger = Logger.new File.join(File.dirname(__FILE__), 'test.log')
6
8
 
7
9
  RSpec.configure do |config|
8
10
  config.mock_with :rspec
11
+ config.expect_with :rspec
12
+ end
13
+
14
+ Shoulda::Matchers.configure do |config|
15
+ config.integrate do |with|
16
+ with.test_framework :rspec
17
+
18
+ # Keep as many of these lines as are necessary:
19
+ # with.library :active_record
20
+ with.library :active_model
21
+ end
9
22
  end
metadata CHANGED
@@ -1,204 +1,182 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skynet-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Ahearn
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-27 00:00:00.000000000 Z
11
+ date: 2020-10-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sinatra
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '1.3'
19
+ version: '2.1'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '1.3'
26
+ version: '2.1'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thin
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '1.4'
33
+ version: '1.7'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '1.4'
40
+ version: '1.7'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: json
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '1.7'
47
+ version: '2.3'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '1.7'
54
+ version: '2.3'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: jekyll
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
- version: '0.11'
61
+ version: '4.1'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
- version: '0.11'
68
+ version: '4.1'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: thor
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
- version: '0.16'
75
+ version: '1.0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
- version: '0.16'
82
+ version: '1.0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: activesupport
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ~>
87
+ - - "~>"
100
88
  - !ruby/object:Gem::Version
101
- version: '3.2'
89
+ version: '6.0'
102
90
  type: :runtime
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ~>
94
+ - - "~>"
108
95
  - !ruby/object:Gem::Version
109
- version: '3.2'
96
+ version: '6.0'
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: activemodel
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ~>
101
+ - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: '3.2'
103
+ version: '6.0'
118
104
  type: :runtime
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ~>
108
+ - - "~>"
124
109
  - !ruby/object:Gem::Version
125
- version: '3.2'
110
+ version: '6.0'
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: multi_json
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ~>
115
+ - - "~>"
132
116
  - !ruby/object:Gem::Version
133
- version: '1.0'
117
+ version: '1.15'
134
118
  type: :runtime
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ~>
122
+ - - "~>"
140
123
  - !ruby/object:Gem::Version
141
- version: '1.0'
124
+ version: '1.15'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: rake
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ~>
129
+ - - "~>"
148
130
  - !ruby/object:Gem::Version
149
- version: '0.9'
131
+ version: '13.0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ~>
136
+ - - "~>"
156
137
  - !ruby/object:Gem::Version
157
- version: '0.9'
138
+ version: '13.0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: rspec
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ~>
143
+ - - "~>"
164
144
  - !ruby/object:Gem::Version
165
- version: '2.11'
145
+ version: '3.9'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ~>
150
+ - - "~>"
172
151
  - !ruby/object:Gem::Version
173
- version: '2.11'
152
+ version: '3.9'
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: shoulda-matchers
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ~>
157
+ - - "~>"
180
158
  - !ruby/object:Gem::Version
181
- version: '1.2'
159
+ version: '4.4'
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ~>
164
+ - - "~>"
188
165
  - !ruby/object:Gem::Version
189
- version: '1.2'
166
+ version: '4.4'
190
167
  description: Sinatra app that listens for GitHub post-receive callbacks and deploys
191
168
  your code
192
169
  email:
193
- - ryan@coshx.com
170
+ - ryan.ahearn@hey.com
194
171
  executables:
195
172
  - skynet
196
173
  extensions: []
197
174
  extra_rdoc_files: []
198
175
  files:
199
- - .gitignore
200
- - .rspec
201
- - .rvmrc
176
+ - ".gitignore"
177
+ - ".rspec"
178
+ - ".ruby-version"
179
+ - ".travis.yml"
202
180
  - Gemfile
203
181
  - README.md
204
182
  - Rakefile
@@ -220,32 +198,27 @@ files:
220
198
  - spec/skynet/builder/static_spec.rb
221
199
  - spec/skynet/builder_spec.rb
222
200
  - spec/spec_helper.rb
223
- homepage: https://github.com/coshx/skynet
201
+ homepage: https://github.com/rahearn/skynet
224
202
  licenses: []
225
- post_install_message:
203
+ metadata: {}
204
+ post_install_message:
226
205
  rdoc_options: []
227
206
  require_paths:
228
207
  - lib
229
208
  required_ruby_version: !ruby/object:Gem::Requirement
230
- none: false
231
209
  requirements:
232
- - - ! '>='
210
+ - - ">="
233
211
  - !ruby/object:Gem::Version
234
- version: '0'
235
- segments:
236
- - 0
237
- hash: -3009597360161477294
212
+ version: 2.7.1
238
213
  required_rubygems_version: !ruby/object:Gem::Requirement
239
- none: false
240
214
  requirements:
241
- - - ! '>='
215
+ - - ">="
242
216
  - !ruby/object:Gem::Version
243
- version: 1.3.6
217
+ version: '0'
244
218
  requirements: []
245
- rubyforge_project:
246
- rubygems_version: 1.8.23
247
- signing_key:
248
- specification_version: 3
219
+ rubygems_version: 3.1.4
220
+ signing_key:
221
+ specification_version: 4
249
222
  summary: Sinatra app that listens for GitHub post-receive callbacks and deploys your
250
223
  code
251
224
  test_files:
data/.rvmrc DELETED
@@ -1,41 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
- environment_id="ruby-1.9.3-p327@skynet"
8
-
9
- #
10
- # First we attempt to load the desired environment directly from the environment
11
- # file. This is very fast and efficient compared to running through the entire
12
- # CLI and selector. If you want feedback on which environment was used then
13
- # insert the word 'use' after --create as this triggers verbose mode.
14
- #
15
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
16
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
17
- then
18
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
19
-
20
- if [[ -s ".rvm/hooks/after_use" ]]
21
- then
22
- . ".rvm/hooks/after_use"
23
- fi
24
- else
25
- # If the environment file has not yet been created, use the RVM CLI to select.
26
- if ! rvm --create "$environment_id"
27
- then
28
- echo "Failed to create RVM environment ''."
29
- fi
30
- fi
31
-
32
- #
33
- # If you use an RVM gemset file to install a list of gems (*.gems), you can have
34
- # it be automatically loaded. Uncomment the following and adjust the filename if
35
- # necessary.
36
- #
37
- # filename=".gems"
38
- # if [[ -s "$filename" ]] ; then
39
- # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
40
- # fi
41
-