tomo 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 43daca76a8f7fc58c99f3365f71d6ef1349643879d5237f9be63fcf956a1a238
4
- data.tar.gz: 5a37ebc5429e0feb93fd2591fd268ee0544de08145a950d3f3f37bab50b9a58e
3
+ metadata.gz: 4f17c4f644a912a79bac63de1bf2bd3d27d87e3bbe58ffdb63e1ee1ffaea160c
4
+ data.tar.gz: cc22d62f9bd02f647197a7d691c005a5ddf095141f40c12a8af3ea211fd41c04
5
5
  SHA512:
6
- metadata.gz: 06f34c6c9d0ea370e6fc3cd1095874b53b423edae499b88f8ed7789ee308bbacd69324fadcab590b3e264ebdaf4093129708358744f6e9ded69ef7c7432b8c71
7
- data.tar.gz: 605619d1fc09d99eee6c244adba219cd263c0b00d4975f06a3ea1110699a0a0f64cf5226be1a69ff80491906c9e51e35da2be2a8ef2fffc683b214ffee5fd770
6
+ metadata.gz: 52e06ed4c55e3d1630108802847c04235b1d48ee26225c1e78207931311333c00003c50e5a204aeb2a6752f9013bd3e2610436f2cc65222ea46bdb08513fbeea
7
+ data.tar.gz: f898fbf717712c309d5c30431fe6a30c71263c1139a4426ad573e8354506cc69dbfba3b443ff100dd1ce35b67c7c837b17d468698ba12a25762e6455cba07859
data/README.md CHANGED
@@ -111,7 +111,7 @@ Out of the box, tomo will:
111
111
  Whereas `tomo setup` is typically run once, you can use `tomo deploy` every time you want to deploy a new version of your app. The deploy command will sequentially run the [deploy](https://tomo-deploy.com/configuration#deployblock) list of tasks specified in `.tomo/config.rb`. You can customize this list to meet the needs of your app. By default, tomo runs these tasks:
112
112
 
113
113
  1. Create a release (using the [git:create_release](https://tomo-deploy.com/plugins/git#gitcreate_release) task)
114
- 2. Build the project (e.g. [bundler:install](https://tomo-deploy.com/plugins/bundler#bundlerinstall), [rails:assets_precompile](../plugins/rails.md#railsassets_precompile))
114
+ 2. Build the project (e.g. [bundler:install](https://tomo-deploy.com/plugins/bundler#bundlerinstall), [rails:assets_precompile](https://tomo-deploy.com/plugins/rails#railsassets_precompile))
115
115
  3. Migrate data to the meet the requirements of the new release (e.g. [rails:db_migrate](https://tomo-deploy.com/plugins/rails#railsdb_migrate))
116
116
  4. Make the new release the "current" one ([core:symlink_current](https://tomo-deploy.com/plugins/core#coresymlink_current))
117
117
  5. Restart the app to use the new current release (e.g. [puma:restart](https://tomo-deploy.com/plugins/puma#pumarestart))
data/lib/tomo/paths.rb CHANGED
@@ -29,6 +29,8 @@ module Tomo
29
29
  end
30
30
 
31
31
  def path(setting)
32
+ return nil if settings[setting].nil?
33
+
32
34
  path = settings.fetch(setting).to_s.gsub(%r{//+}, "/")
33
35
  Path.new(path)
34
36
  end
@@ -1,9 +1,27 @@
1
+ require "yaml"
2
+
1
3
  module Tomo::Plugin::Bundler
2
4
  class Tasks < Tomo::TaskLibrary
5
+ CONFIG_SETTINGS = %i[
6
+ bundler_deployment
7
+ bundler_gemfile
8
+ bundler_jobs
9
+ bundler_path
10
+ bundler_retry
11
+ bundler_without
12
+ ].freeze
13
+ private_constant :CONFIG_SETTINGS
14
+
15
+ def config
16
+ configuration = settings_to_configuration
17
+ remote.mkdir_p paths.bundler_config.dirname
18
+ remote.write(text: YAML.dump(configuration), to: paths.bundler_config)
19
+ end
20
+
3
21
  def install
4
- return if remote.bundle?("check", *check_options) && !dry_run?
22
+ return if remote.bundle?("check") && !dry_run?
5
23
 
6
- remote.bundle("install", *install_options)
24
+ remote.bundle("install")
7
25
  end
8
26
 
9
27
  def clean
@@ -23,31 +41,19 @@ module Tomo::Plugin::Bundler
23
41
 
24
42
  private
25
43
 
26
- def version_setting
27
- settings[:bundler_version]
28
- end
29
-
30
- def check_options
31
- gemfile = settings[:bundler_gemfile]
32
- path = paths.bundler
44
+ def settings_to_configuration
45
+ CONFIG_SETTINGS.each_with_object({}) do |key, config|
46
+ next if settings[key].nil?
33
47
 
34
- options = []
35
- options.push("--gemfile", gemfile) if gemfile
36
- options.push("--path", path) if path
37
- options
48
+ entry_key = "BUNDLE_#{key.to_s.sub(/^bundler_/, '').upcase}"
49
+ entry_value = settings.fetch(key)
50
+ entry_value = entry_value.join(":") if entry_value.is_a?(Array)
51
+ config[entry_key] = entry_value.to_s
52
+ end
38
53
  end
39
54
 
40
- def install_options
41
- jobs = settings[:bundler_jobs]
42
- without = settings[:bundler_without]
43
- flags = settings[:bundler_install_flags]
44
-
45
- options = check_options.dup
46
- options.push("--jobs", jobs) if jobs
47
- options.push("--without", without) if without
48
- options.push(flags) if flags
49
-
50
- options.flatten
55
+ def version_setting
56
+ settings[:bundler_version]
51
57
  end
52
58
 
53
59
  def extract_bundler_ver_from_lockfile
@@ -8,11 +8,13 @@ module Tomo::Plugin
8
8
  tasks Tomo::Plugin::Bundler::Tasks
9
9
  helpers Tomo::Plugin::Bundler::Helpers
10
10
 
11
- defaults bundler_install_flags: ["--deployment"],
12
- bundler_gemfile: nil,
13
- bundler_jobs: "4",
14
- bundler_path: "%<shared_path>/bundle",
15
- bundler_version: nil,
16
- bundler_without: %w[development test]
11
+ defaults bundler_config_path: ".bundle/config",
12
+ bundler_deployment: true,
13
+ bundler_gemfile: nil,
14
+ bundler_jobs: "4",
15
+ bundler_path: "%<shared_path>/bundle",
16
+ bundler_retry: "3",
17
+ bundler_version: nil,
18
+ bundler_without: %w[development test]
17
19
  end
18
20
  end
@@ -60,9 +60,12 @@ module Tomo::Plugin::Core
60
60
 
61
61
  # rubocop:disable Metrics/AbcSize
62
62
  def log_revision
63
+ ref = remote.release[:ref]
64
+ revision = remote.release[:revision]
65
+
63
66
  message = remote.release[:deploy_date].to_s
64
- message << " - #{remote.release[:revision] || '<unknown>'}"
65
- message << " (#{remote.release[:branch] || '<unknown>'})"
67
+ message << " - #{revision || '<unknown>'}"
68
+ message << " (#{ref})" if ref && revision && !revision.start_with?(ref)
66
69
  message << " deployed by #{remote.release[:deploy_user] || '<unknown>'}"
67
70
  message << "\n"
68
71
 
@@ -15,24 +15,45 @@ module Tomo::Plugin::Git
15
15
  end
16
16
  end
17
17
 
18
+ # rubocop:disable Metrics/MethodLength
18
19
  def create_release
19
- configure_git_attributes
20
20
  remote.chdir(paths.git_repo) do
21
21
  remote.git("remote update --prune")
22
- remote.mkdir_p(paths.release)
22
+ end
23
+
24
+ store_release_info
25
+ configure_git_attributes
26
+ remote.mkdir_p(paths.release)
27
+
28
+ remote.chdir(paths.git_repo) do
23
29
  remote.git(
24
- "archive #{branch.shellescape} | "\
30
+ "archive #{ref.shellescape} | "\
25
31
  "tar -x -f - -C #{paths.release.shellescape}"
26
32
  )
27
33
  end
28
- store_release_info
29
34
  end
35
+ # rubocop:enable Metrics/MethodLength
30
36
  # rubocop:enable Metrics/AbcSize
31
37
 
32
38
  private
33
39
 
34
- def branch
35
- settings[:git_branch]
40
+ def ref
41
+ require_setting :git_ref if settings[:git_branch].nil?
42
+
43
+ warn_if_ref_overrides_branch
44
+ settings[:git_ref] || settings[:git_branch]
45
+ end
46
+
47
+ def warn_if_ref_overrides_branch
48
+ return if defined?(@ref_override_warning)
49
+ return unless settings[:git_ref] && settings[:git_branch]
50
+
51
+ logger.warn(
52
+ ":git_ref (#{settings[:git_ref]}) and "\
53
+ ":git_branch (#{settings[:git_branch]}) are both specified. "\
54
+ "Ignoring :git_branch."
55
+ )
56
+ @ref_override_warning = true
36
57
  end
37
58
 
38
59
  def set_origin_url
@@ -57,13 +78,14 @@ module Tomo::Plugin::Git
57
78
  log = remote.chdir(paths.git_repo) do
58
79
  remote.git(
59
80
  'log -n1 --date=iso --pretty=format:"%H/%cd/%ae" '\
60
- "#{branch.shellescape}",
81
+ "#{ref.shellescape} --",
61
82
  silent: true
62
83
  ).stdout.strip
63
84
  end
64
85
 
65
86
  sha, date, email = log.split("/", 3)
66
- remote.release[:branch] = branch
87
+ remote.release[:branch] = ref if ref == settings[:git_branch]
88
+ remote.release[:ref] = ref
67
89
  remote.release[:author] = email
68
90
  remote.release[:revision] = sha
69
91
  remote.release[:revision_date] = date
@@ -13,6 +13,7 @@ module Tomo::Plugin
13
13
  git_repo_path: "%<deploy_to>/git_repo",
14
14
  git_exclusions: [],
15
15
  git_env: { GIT_SSH_COMMAND: "ssh -o PasswordAuthentication=no -o StrictHostKeyChecking=no" },
16
+ git_ref: nil,
16
17
  git_url: nil
17
18
  # rubocop:enable Metrics/LineLength
18
19
  end
@@ -29,7 +29,6 @@ set env_vars: {
29
29
  SECRET_KEY_BASE: :prompt
30
30
  }
31
31
  set linked_dirs: %w[
32
- .bundle
33
32
  log
34
33
  node_modules
35
34
  public/assets
@@ -47,6 +46,7 @@ setup do
47
46
  run "nodenv:install"
48
47
  run "rbenv:install"
49
48
  run "bundler:upgrade_bundler"
49
+ run "bundler:config"
50
50
  run "bundler:install"
51
51
  run "rails:db_create"
52
52
  run "rails:db_schema_load"
data/lib/tomo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tomo
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brictson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-23 00:00:00.000000000 Z
11
+ date: 2019-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -306,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
306
306
  - !ruby/object:Gem::Version
307
307
  version: '0'
308
308
  requirements: []
309
- rubygems_version: 3.0.4
309
+ rubygems_version: 3.0.6
310
310
  signing_key:
311
311
  specification_version: 4
312
312
  summary: A simple SSH-based deployment tool, built for Rails