parity 3.2.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -26
- data/bin/pr_app +1 -1
- data/lib/parity/backup.rb +9 -6
- data/lib/parity/environment.rb +22 -15
- data/lib/parity/version.rb +1 -1
- data/lib/parity.rb +1 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ee16d3e40ea984e2097512f153e70f697fc6621ace79745935fee0d8a921f77
|
4
|
+
data.tar.gz: 47b60c7616ead54c4d9f2d06757b278be7976901a43156488d6abce73e1cdfc3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f1ac796f6f3ee3ea4ea4f7c59ba9f9ce123b22400b992bc1cc83fef6e7abddea3a505d83bd6b7935f9640249e81bfae19d1064b725a7e877e3e8f4e13ec5a9d
|
7
|
+
data.tar.gz: 1523534c0881decc98401235471ba433b44c53d023a4ab08fb639a9f318372be95dab0029fd62a1f04fa043be079d14da92d83dbd02aea1458b6848b282b8cfb
|
data/README.md
CHANGED
@@ -8,22 +8,11 @@ Shell commands for development, staging, and production parity for Heroku apps.
|
|
8
8
|
Install
|
9
9
|
-------
|
10
10
|
|
11
|
-
|
11
|
+
gem install parity
|
12
12
|
|
13
|
-
|
14
|
-
brew install parity
|
13
|
+
Or bundle it in your project:
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
wget -qO - https://apt.thoughtbot.com/thoughtbot.gpg.key | sudo apt-key add -
|
19
|
-
echo "deb http://apt.thoughtbot.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/thoughtbot.list
|
20
|
-
sudo apt-get update
|
21
|
-
sudo apt-get install parity
|
22
|
-
|
23
|
-
On other systems you can:
|
24
|
-
|
25
|
-
1. Download the package for your system from the [releases page][releases]
|
26
|
-
1. Extract the tarball and place it so that `/bin` is in your `PATH`
|
15
|
+
gem "parity"
|
27
16
|
|
28
17
|
[releases]: https://github.com/thoughtbot/parity/releases
|
29
18
|
|
@@ -33,10 +22,6 @@ Parity requires these command-line programs:
|
|
33
22
|
heroku
|
34
23
|
pg_restore
|
35
24
|
|
36
|
-
On macOS, these programs are installed
|
37
|
-
as Homebrew package dependencies of
|
38
|
-
the `parity` Homebrew package.
|
39
|
-
|
40
25
|
Usage
|
41
26
|
-----
|
42
27
|
|
@@ -61,7 +46,7 @@ Push your local development database backup up to staging:
|
|
61
46
|
|
62
47
|
staging restore development
|
63
48
|
|
64
|
-
Deploy
|
49
|
+
Deploy main to production (note that prior versions of Parity would run
|
65
50
|
database migrations, that's now better handled using [Heroku release phase]):
|
66
51
|
|
67
52
|
production deploy
|
@@ -92,18 +77,18 @@ Tail a log:
|
|
92
77
|
staging tail
|
93
78
|
pr_app 1234 tail
|
94
79
|
|
95
|
-
Use [redis-cli][2] with your `REDIS_URL` add-on:
|
96
|
-
|
97
|
-
production redis-cli
|
98
|
-
staging redis-cli
|
99
|
-
pr_app 1234 redis-cli
|
100
|
-
|
101
80
|
The scripts also pass through, so you can do anything with them that you can do
|
102
81
|
with `heroku ______ --remote staging` or `heroku ______ --remote production`:
|
103
82
|
|
104
83
|
watch production ps
|
105
84
|
staging open
|
106
85
|
|
86
|
+
You can optionally parallelize a DB restore by passing `--parallelize`
|
87
|
+
as a flag to the `development` or `production` commands:
|
88
|
+
```
|
89
|
+
development restore-from production --parallelize
|
90
|
+
```
|
91
|
+
|
107
92
|
[2]: http://redis.io/commands
|
108
93
|
|
109
94
|
Convention
|
@@ -191,7 +176,7 @@ See guidelines in [`RELEASING.md`](RELEASING.md) for details
|
|
191
176
|
License
|
192
177
|
-------
|
193
178
|
|
194
|
-
Parity is © 2013-
|
179
|
+
Parity is © 2013-2021 thoughtbot, inc.
|
195
180
|
It is free software,
|
196
181
|
and may be redistributed under the terms specified in the [LICENSE] file.
|
197
182
|
|
data/bin/pr_app
CHANGED
@@ -9,7 +9,7 @@ if ARGV.empty?
|
|
9
9
|
else
|
10
10
|
review_app_number = ARGV.first
|
11
11
|
staging_git_remote = Open3.capture3("git remote get-url staging")[0].strip
|
12
|
-
review_app_prefix = staging_git_remote.split("/").last.gsub(/\.git\Z/, "")[0,
|
12
|
+
review_app_prefix = staging_git_remote.split("/").last.gsub(/\.git\Z/, "")[0, 20]
|
13
13
|
|
14
14
|
exit Parity::Environment.new(
|
15
15
|
"#{review_app_prefix}-pr-#{review_app_number}",
|
data/lib/parity/backup.rb
CHANGED
@@ -10,6 +10,7 @@ module Parity
|
|
10
10
|
def initialize(args)
|
11
11
|
@from, @to = args.values_at(:from, :to)
|
12
12
|
@additional_args = args[:additional_args] || BLANK_ARGUMENTS
|
13
|
+
@parallelize = args[:parallelize] || false
|
13
14
|
end
|
14
15
|
|
15
16
|
def restore
|
@@ -24,7 +25,9 @@ module Parity
|
|
24
25
|
|
25
26
|
private
|
26
27
|
|
27
|
-
attr_reader :additional_args, :from, :to
|
28
|
+
attr_reader :additional_args, :from, :to, :parallelize
|
29
|
+
|
30
|
+
alias :parallelize? :parallelize
|
28
31
|
|
29
32
|
def restore_from_development
|
30
33
|
reset_remote_database
|
@@ -72,7 +75,7 @@ module Parity
|
|
72
75
|
|
73
76
|
def restore_from_local_temp_backup
|
74
77
|
Kernel.system(
|
75
|
-
"pg_restore tmp/latest.backup --verbose --
|
78
|
+
"pg_restore tmp/latest.backup --verbose --no-acl --no-owner "\
|
76
79
|
"--dbname #{development_db} --jobs=#{processor_cores} "\
|
77
80
|
"#{additional_args}",
|
78
81
|
)
|
@@ -105,20 +108,20 @@ module Parity
|
|
105
108
|
end
|
106
109
|
|
107
110
|
def development_db
|
108
|
-
YAML.
|
111
|
+
YAML.safe_load(database_yaml_file, aliases: true).
|
109
112
|
fetch(DEVELOPMENT_ENVIRONMENT_KEY_NAME).
|
110
113
|
fetch(DATABASE_KEY_NAME)
|
111
114
|
end
|
112
115
|
|
113
116
|
def database_yaml_file
|
114
|
-
IO.read(DATABASE_YML_RELATIVE_PATH)
|
117
|
+
ERB.new(IO.read(DATABASE_YML_RELATIVE_PATH)).result
|
115
118
|
end
|
116
119
|
|
117
120
|
def processor_cores
|
118
|
-
if ruby_version_over_2_2?
|
121
|
+
if parallelize? && ruby_version_over_2_2?
|
119
122
|
Etc.nprocessors
|
120
123
|
else
|
121
|
-
|
124
|
+
1
|
122
125
|
end
|
123
126
|
end
|
124
127
|
|
data/lib/parity/environment.rb
CHANGED
@@ -41,14 +41,27 @@ module Parity
|
|
41
41
|
|
42
42
|
def deploy
|
43
43
|
if production?
|
44
|
-
Kernel.system("git push production
|
44
|
+
Kernel.system("git push production #{branch_ref}")
|
45
45
|
else
|
46
46
|
Kernel.system(
|
47
|
-
"git push #{environment} HEAD
|
47
|
+
"git push #{environment} HEAD:#{branch_ref} --force",
|
48
48
|
)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
def branch_ref
|
53
|
+
main_ref_exists = system("git show-ref --verify --quiet refs/heads/main")
|
54
|
+
master_ref_exists = system(
|
55
|
+
"git show-ref --verify --quiet refs/heads/master",
|
56
|
+
)
|
57
|
+
|
58
|
+
if main_ref_exists && !master_ref_exists
|
59
|
+
"main"
|
60
|
+
else
|
61
|
+
"master"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
52
65
|
def restore
|
53
66
|
if production? && !forced?
|
54
67
|
$stdout.puts "Parity does not support restoring backups into your "\
|
@@ -57,6 +70,7 @@ module Parity
|
|
57
70
|
Backup.new(
|
58
71
|
from: arguments.first,
|
59
72
|
to: environment,
|
73
|
+
parallelize: parallelize?,
|
60
74
|
additional_args: additional_restore_arguments,
|
61
75
|
).restore
|
62
76
|
end
|
@@ -72,10 +86,13 @@ module Parity
|
|
72
86
|
arguments.include?("--force")
|
73
87
|
end
|
74
88
|
|
89
|
+
def parallelize?
|
90
|
+
arguments.include?("--parallelize")
|
91
|
+
end
|
92
|
+
|
75
93
|
def additional_restore_arguments
|
76
|
-
(arguments.drop(1) - ["--force"] +
|
77
|
-
compact.
|
78
|
-
join(" ")
|
94
|
+
(arguments.drop(1) - ["--force", "--parallelize"] +
|
95
|
+
[restore_confirmation_argument]).compact.join(" ")
|
79
96
|
end
|
80
97
|
|
81
98
|
def restore_confirmation_argument
|
@@ -109,16 +126,6 @@ module Parity
|
|
109
126
|
)
|
110
127
|
end
|
111
128
|
|
112
|
-
def redis_cli
|
113
|
-
Kernel.system("redis-cli", "-u", raw_redis_url)
|
114
|
-
end
|
115
|
-
|
116
|
-
def raw_redis_url
|
117
|
-
@redis_to_go_url ||= Open3.
|
118
|
-
capture3(command_for_remote("config:get REDIS_URL"))[0].
|
119
|
-
strip
|
120
|
-
end
|
121
|
-
|
122
129
|
def heroku_app_name
|
123
130
|
HerokuAppName.new(environment).to_s
|
124
131
|
end
|
data/lib/parity/version.rb
CHANGED
data/lib/parity.rb
CHANGED
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: 3.
|
4
|
+
version: 3.5.0
|
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:
|
12
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: |2
|
15
15
|
Development/staging/production parity makes it easier for
|
@@ -54,8 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
requirements: []
|
57
|
-
|
58
|
-
rubygems_version: 2.7.6
|
57
|
+
rubygems_version: 3.1.4
|
59
58
|
signing_key:
|
60
59
|
specification_version: 4
|
61
60
|
summary: Shell commands for development, staging, and production parity.
|