parity 2.4.0 → 3.0.0.beta

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: cac3c3c44e1e297809b6bca4cfde1975d5350ca02a71811044b36c493207c2c8
4
- data.tar.gz: bb699b87a10d208c358f9215f690867d86b426b0db7443c99fd44fe2bc29f308
3
+ metadata.gz: 2295545fdc8b35529afb106f436be8becaaffa507ce9484af115639cb1a5b85e
4
+ data.tar.gz: 265339579a79bee3b13b64fee322754ca33bce70822fda019002634ba5bbfd6b
5
5
  SHA512:
6
- metadata.gz: 8cd2c26f9e67ed147353a4df769c593f72c3fa02b85ae570337000246f680c86509aa6c94692d107c9fe3e76e955169c4299c5a5ba0cdd4680337beb4320ba1a
7
- data.tar.gz: 2928886a795152cc579561a5beaee4d643d8fef9af64842ae76f00818cd07f756191d35b964c1c1d1fc274795554fe5dcee2257abb64a6fd062fdefda3abab55
6
+ metadata.gz: 74cb7ec338ad64a9068fb70fa1185eec139108714c81436609402c003a9f1bb273e6a6d44ba0c0aa9ac6462e8fd85684a820abaeb284e4c8b7f00dd6d76d5637
7
+ data.tar.gz: 96eba9ee304523c83c073b4e18193e07bedc5178095cfe7cb0b15ce55861983926fc1a58281c24e7cd623f60a5981565b1c7ee95893df26af16abfadca8595c2
data/README.md CHANGED
@@ -6,7 +6,7 @@ Shell commands for development, staging, and production parity for Heroku apps.
6
6
  Install
7
7
  -------
8
8
 
9
- On OS X, this installs everything you need:
9
+ On macOS, this installs everything you need:
10
10
 
11
11
  brew tap thoughtbot/formulae
12
12
  brew install parity
@@ -31,7 +31,7 @@ Parity requires these command-line programs:
31
31
  heroku
32
32
  pg_restore
33
33
 
34
- On OS X, these programs are installed
34
+ On macOS, these programs are installed
35
35
  as Homebrew package dependencies of
36
36
  the `parity` Homebrew package.
37
37
 
@@ -53,17 +53,17 @@ Or, if `restore-from` reads better to you, it's the same thing:
53
53
  development restore-from production
54
54
  development restore-from staging
55
55
 
56
+ * Note that the `restore` command will use the most recent backup (from _staging_ or _production_). You may first need to create a more recent backup before restoring, to prevent download of a very old backup.
57
+
56
58
  Push your local development database backup up to staging:
57
59
 
58
60
  staging restore development
59
61
 
60
- Deploy from master to production
61
- and migrate and restart the dynos if necessary:
62
+ Deploy master to production:
62
63
 
63
64
  production deploy
64
65
 
65
- Deploy the current branch to staging or a feature branch
66
- and migrate and restart the dynos if necessary:
66
+ Deploy the current branch to staging:
67
67
 
68
68
  staging deploy
69
69
 
@@ -73,21 +73,25 @@ Open a console:
73
73
 
74
74
  production console
75
75
  staging console
76
+ pr_app 1234 console
76
77
 
77
78
  Migrate a database and restart the dynos:
78
79
 
79
80
  production migrate
80
81
  staging migrate
82
+ pr_app 1234 migrate
81
83
 
82
84
  Tail a log:
83
85
 
84
86
  production tail
85
87
  staging tail
88
+ pr_app 1234 tail
86
89
 
87
90
  Use [redis-cli][2] with your `REDIS_URL` add-on:
88
91
 
89
92
  production redis-cli
90
93
  staging redis-cli
94
+ pr_app 1234 redis-cli
91
95
 
92
96
  The scripts also pass through, so you can do anything with them that you can do
93
97
  with `heroku ______ --remote staging` or `heroku ______ --remote production`:
@@ -111,6 +115,20 @@ heroku git:remote -r production -a your-production-app
111
115
  * There is a `config/database.yml` file that can be parsed as YAML for
112
116
  `['development']['database']`.
113
117
 
118
+ Pipelines
119
+ ---------
120
+
121
+ If you deploy review applications with Heroku pipelines, run commands against
122
+ those applications with the `pr_app` command, followed by the PR number for your
123
+ application:
124
+
125
+ ```
126
+ pr_app 1234 console
127
+ ```
128
+
129
+ This command assumes that your review applications have a name derived from the
130
+ name of the application your `staging` Git remote points at.
131
+
114
132
  Customization
115
133
  -------------
116
134
 
@@ -40,6 +40,7 @@ module Parity
40
40
  wipe_development_database
41
41
  restore_from_local_temp_backup
42
42
  delete_local_temp_backup
43
+ delete_rails_production_environment_settings
43
44
  end
44
45
 
45
46
  def wipe_development_database
@@ -72,7 +73,7 @@ module Parity
72
73
  def restore_from_local_temp_backup
73
74
  Kernel.system(
74
75
  "pg_restore tmp/latest.backup --verbose --clean --no-acl --no-owner "\
75
- "--dbname #{development_db} --jobs #{processor_cores} "\
76
+ "--dbname #{development_db} --jobs=#{processor_cores} "\
76
77
  "#{additional_args}",
77
78
  )
78
79
  end
@@ -81,6 +82,17 @@ module Parity
81
82
  Kernel.system("rm tmp/latest.backup")
82
83
  end
83
84
 
85
+ def delete_rails_production_environment_settings
86
+ Kernel.system(
87
+ "psql #{development_db} -c "\
88
+ "\"DO $$ BEGIN IF EXISTS "\
89
+ "(SELECT 1 FROM pg_tables WHERE tablename = 'ar_internal_metadata') "\
90
+ "THEN UPDATE ar_internal_metadata "\
91
+ "SET value = 'development' "\
92
+ "WHERE key = 'environment'; ELSE END IF; END $$;\"",
93
+ )
94
+ end
95
+
84
96
  def restore_to_remote_environment
85
97
  reset_remote_database
86
98
  Kernel.system(
@@ -2,10 +2,11 @@ require "parity/backup"
2
2
 
3
3
  module Parity
4
4
  class Environment
5
- def initialize(environment, subcommands)
5
+ def initialize(environment, subcommands, app_argument: "--remote")
6
6
  self.environment = environment
7
7
  self.subcommand = subcommands[0]
8
8
  self.arguments = subcommands[1..-1]
9
+ self.app_argument = app_argument
9
10
  end
10
11
 
11
12
  def run
@@ -16,7 +17,7 @@ module Parity
16
17
 
17
18
  PROTECTED_ENVIRONMENTS = %w(development production)
18
19
 
19
- attr_accessor :environment, :subcommand, :arguments
20
+ attr_accessor :app_argument, :environment, :subcommand, :arguments
20
21
 
21
22
  def run_command
22
23
  if self.class.private_method_defined?(methodized_subcommand)
@@ -31,22 +32,14 @@ module Parity
31
32
  end
32
33
 
33
34
  def run_via_cli
34
- Kernel.exec("heroku", subcommand, *arguments, "--remote", environment)
35
+ Kernel.exec("heroku", subcommand, *arguments, app_argument, environment)
35
36
  end
36
37
 
37
38
  def backup
38
- Kernel.system("heroku pg:backups:capture --remote #{environment}")
39
+ Kernel.system("heroku pg:backups:capture #{app_argument} #{environment}")
39
40
  end
40
41
 
41
42
  def deploy
42
- skip_migrations = !run_migrations?
43
-
44
- if deploy_to_heroku
45
- skip_migrations || migrate
46
- end
47
- end
48
-
49
- def deploy_to_heroku
50
43
  if production?
51
44
  Kernel.system("git push production master")
52
45
  else
@@ -113,17 +106,7 @@ module Parity
113
106
  end
114
107
 
115
108
  def redis_cli
116
- url = URI(raw_redis_url)
117
-
118
- Kernel.system(
119
- "redis-cli",
120
- "-h",
121
- url.host,
122
- "-p",
123
- url.port.to_s,
124
- "-a",
125
- url.password
126
- )
109
+ Kernel.system("redis-cli", "-u", raw_redis_url)
127
110
  end
128
111
 
129
112
  def raw_redis_url
@@ -137,38 +120,7 @@ module Parity
137
120
  end
138
121
 
139
122
  def command_for_remote(command)
140
- "heroku #{command} --remote #{environment}"
141
- end
142
-
143
- def run_migrations?
144
- rails_app? && pending_migrations?
145
- end
146
-
147
- def rails_app?
148
- has_rakefile? && has_migrations_folder?
149
- end
150
-
151
- def has_migrations_folder?
152
- Pathname.new("db").join("migrate").directory?
153
- end
154
-
155
- def has_rakefile?
156
- File.exists?("Rakefile")
157
- end
158
-
159
- def pending_migrations?
160
- !Kernel.system(%{
161
- git fetch #{environment} &&
162
- git diff --quiet #{environment}/master..#{compare_with} -- db/migrate
163
- })
164
- end
165
-
166
- def compare_with
167
- if production?
168
- "master"
169
- else
170
- "HEAD"
171
- end
123
+ "heroku #{command} #{app_argument} #{environment}"
172
124
  end
173
125
 
174
126
  def methodized_subcommand
@@ -1,3 +1,3 @@
1
1
  module Parity
2
- VERSION = "2.4.0".freeze
2
+ VERSION = "3.0.0.beta".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parity
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.0
4
+ version: 3.0.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-02 00:00:00.000000000 Z
12
+ date: 2018-09-15 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |2
15
15
  Development/staging/production parity makes it easier for
@@ -48,12 +48,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
48
  version: 2.2.0
49
49
  required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - ">="
51
+ - - ">"
52
52
  - !ruby/object:Gem::Version
53
- version: '0'
53
+ version: 1.3.1
54
54
  requirements: []
55
55
  rubyforge_project:
56
- rubygems_version: 2.7.4
56
+ rubygems_version: 2.7.7
57
57
  signing_key:
58
58
  specification_version: 4
59
59
  summary: Shell commands for development, staging, and production parity.