skynet-deploy 1.3.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +5 -3
- data/README.md +7 -2
- data/lib/skynet/app.rb +12 -7
- data/lib/skynet/builder/base.rb +16 -25
- data/lib/skynet/builder/jekyll.rb +1 -1
- data/lib/skynet/cli.rb +2 -2
- data/lib/skynet/version.rb +1 -1
- data/lib/skynet/wizard.rb +10 -6
- data/lib/skynet.rb +1 -1
- data/skynet.gemspec +14 -14
- data/spec/skynet/builder/base_spec.rb +31 -33
- data/spec/skynet/builder/jekyll_spec.rb +3 -3
- data/spec/skynet/builder/static_spec.rb +12 -12
- data/spec/skynet/builder_spec.rb +4 -4
- data/spec/spec_helper.rb +13 -0
- metadata +32 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 69dcd5aefe908720208f760d0fb14cbc33eff969eceeb0e34aaa9e0d1e0267b2
|
4
|
+
data.tar.gz: c372ce234723970aaa93c5dcd791e5eb38e4807104289bf832ed737798da4f9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ad9880337c18c0c295d604617e0f7275c9f76e3f644eac8f89c407637296f8fd7ce3c8e00c058522c9f14d08ccd9c3758bde7fed6abe1c86c4ecd72a491216
|
7
|
+
data.tar.gz: 052b4ccfc922e8ba0b74943efadf584479924ccf95a34450278d9b789a16bd94dfee50ce2b2702c0708e5c8c8b0f68e1e5339a58b0dac07d1c2051ee60a8baf3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.3
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Skynet
|
2
2
|
======
|
3
3
|
|
4
|
-
[![Build Status](https://travis-ci.
|
4
|
+
[![Build Status](https://travis-ci.com/rahearn/skynet.svg?branch=master)](https://travis-ci.com/rahearn/skynet)
|
5
5
|
|
6
6
|
GitHub-aware website builder
|
7
7
|
|
@@ -23,7 +23,7 @@ Usage
|
|
23
23
|
* edit config file to add your repositories
|
24
24
|
* Run builder by hand to ensure everything works: `$ skynet build`
|
25
25
|
* Add `http://YOUR_SKYNET_SERVER/PROJECT_NAME` as a Webhook Payload URL to your repository under
|
26
|
-
`Settings -> Webhooks
|
26
|
+
`Settings -> Webhooks`. Choose `application/json` as the Content type.
|
27
27
|
* Start server: `$ skynet server`
|
28
28
|
|
29
29
|
Config file arguments
|
@@ -58,3 +58,8 @@ a git server other than GitHub.
|
|
58
58
|
|
59
59
|
The URL must be visible from the Skynet server, as it will pull a new
|
60
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
|
data/lib/skynet/app.rb
CHANGED
@@ -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 =
|
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/
|
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 '/'
|
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,7 +28,7 @@ module Skynet
|
|
26
28
|
end
|
27
29
|
|
28
30
|
post '/:app_name' do |app_name|
|
29
|
-
Skynet.logger.debug "post '/#{app_name}'
|
31
|
+
Skynet.logger.debug "post '/#{app_name}' payload: #{@payload.inspect}"
|
30
32
|
deploy app_name
|
31
33
|
end
|
32
34
|
|
@@ -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
|
data/lib/skynet/builder/base.rb
CHANGED
@@ -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, :
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
self.
|
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.
|
37
|
-
self.
|
38
|
-
self.
|
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
|
-
|
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 ||
|
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
|
9
|
+
Skynet.logger.info `jekyll build --source #{source} --destination #{destination}`
|
10
10
|
|
11
11
|
Skynet.logger.info 'Jekyll finished'
|
12
12
|
end
|
data/lib/skynet/cli.rb
CHANGED
@@ -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,
|
23
|
+
method_option :log, type: :string, aliases: '-l', desc: 'Log file'
|
24
24
|
def server
|
25
|
-
Skynet.logger = Logger.new
|
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"
|
data/lib/skynet/version.rb
CHANGED
data/lib/skynet/wizard.rb
CHANGED
@@ -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:'}"]
|
44
|
-
|
45
|
-
|
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
|
data/lib/skynet.rb
CHANGED
data/skynet.gemspec
CHANGED
@@ -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@
|
11
|
-
s.homepage = "https://github.com/
|
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.
|
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
|
23
|
-
s.add_runtime_dependency 'thin', '~> 1.
|
24
|
-
s.add_runtime_dependency 'json', '~>
|
25
|
-
s.add_runtime_dependency 'jekyll', '~> 1
|
26
|
-
s.add_runtime_dependency 'thor', '~> 0
|
27
|
-
s.add_runtime_dependency 'activesupport', '~>
|
28
|
-
s.add_runtime_dependency 'activemodel', '~>
|
29
|
-
s.add_runtime_dependency 'multi_json', '~> 1.
|
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', '~>
|
32
|
-
s.add_development_dependency 'rspec', '~>
|
33
|
-
s.add_development_dependency 'shoulda-matchers', '~>
|
31
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
32
|
+
s.add_development_dependency 'rspec', '~> 3.9'
|
33
|
+
s.add_development_dependency 'shoulda-matchers', '~> 5.0'
|
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,
|
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
|
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].
|
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: {
|
29
|
-
specify { subject.errors[:branches].
|
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: {
|
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].
|
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].
|
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.
|
45
|
+
allow(File).to receive(:readable?).and_return true
|
48
46
|
subject.valid?
|
49
47
|
end
|
50
|
-
specify { subject.errors[:key].
|
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.
|
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].
|
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.
|
69
|
-
subject.
|
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 '
|
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 = '
|
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.
|
93
|
+
before(:each) { allow(subject).to receive(:repo_exists?).and_return true }
|
96
94
|
|
97
95
|
it "updates the repository" do
|
98
|
-
subject.
|
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.
|
102
|
+
before(:each) { allow(subject).to receive(:repo_exists?).and_return false }
|
105
103
|
|
106
104
|
it "creates a new repository" do
|
107
|
-
subject.
|
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.
|
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.
|
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,
|
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.
|
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.
|
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,
|
139
|
+
let(:options) { {key: 'keyfile', url: url, branches: {main: '/var/www'}, type: 'static'} }
|
142
140
|
it "should call git pull" do
|
143
|
-
subject.
|
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.
|
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) { {
|
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.
|
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) { {
|
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.
|
16
|
+
before(:each) { allow(Dir).to receive(:glob).and_return([:one, :two]) }
|
17
17
|
|
18
18
|
it "removes destination files first" do
|
19
|
-
FileUtils.
|
20
|
-
FileUtils.
|
21
|
-
FileUtils.
|
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.
|
27
|
-
FileUtils.
|
28
|
-
FileUtils.
|
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.
|
34
|
-
FileUtils.
|
35
|
-
FileUtils.
|
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
|
data/spec/skynet/builder_spec.rb
CHANGED
@@ -10,8 +10,8 @@ describe Skynet::Builder do
|
|
10
10
|
let(:args) { [:app, config] }
|
11
11
|
|
12
12
|
it "initializes a new builder class" do
|
13
|
-
described_class.
|
14
|
-
mock_class.
|
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.
|
25
|
-
builder.
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skynet-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Ahearn
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -16,158 +16,158 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1
|
19
|
+
version: '2.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thin
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.7'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.7'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.3'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: jekyll
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1
|
61
|
+
version: '4.1'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1
|
68
|
+
version: '4.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thor
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0
|
75
|
+
version: '1.0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: activesupport
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '6.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '6.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: activemodel
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '6.0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '6.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: multi_json
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
117
|
+
version: '1.15'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
124
|
+
version: '1.15'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rake
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '13.0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '13.0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: rspec
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
145
|
+
version: '3.9'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
152
|
+
version: '3.9'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: shoulda-matchers
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '5.0'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '5.0'
|
167
167
|
description: Sinatra app that listens for GitHub post-receive callbacks and deploys
|
168
168
|
your code
|
169
169
|
email:
|
170
|
-
- ryan@
|
170
|
+
- ryan.ahearn@hey.com
|
171
171
|
executables:
|
172
172
|
- skynet
|
173
173
|
extensions: []
|
@@ -198,10 +198,10 @@ files:
|
|
198
198
|
- spec/skynet/builder/static_spec.rb
|
199
199
|
- spec/skynet/builder_spec.rb
|
200
200
|
- spec/spec_helper.rb
|
201
|
-
homepage: https://github.com/
|
201
|
+
homepage: https://github.com/rahearn/skynet
|
202
202
|
licenses: []
|
203
203
|
metadata: {}
|
204
|
-
post_install_message:
|
204
|
+
post_install_message:
|
205
205
|
rdoc_options: []
|
206
206
|
require_paths:
|
207
207
|
- lib
|
@@ -209,16 +209,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
209
|
requirements:
|
210
210
|
- - ">="
|
211
211
|
- !ruby/object:Gem::Version
|
212
|
-
version:
|
212
|
+
version: 2.7.1
|
213
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
214
|
requirements:
|
215
215
|
- - ">="
|
216
216
|
- !ruby/object:Gem::Version
|
217
|
-
version:
|
217
|
+
version: '0'
|
218
218
|
requirements: []
|
219
|
-
|
220
|
-
|
221
|
-
signing_key:
|
219
|
+
rubygems_version: 3.2.32
|
220
|
+
signing_key:
|
222
221
|
specification_version: 4
|
223
222
|
summary: Sinatra app that listens for GitHub post-receive callbacks and deploys your
|
224
223
|
code
|