synchronised_migration 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/lib/synchronised_migration/main.rb +8 -1
- data/lib/synchronised_migration/version.rb +1 -1
- data/spec/synchronised_migration/main_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 212072787b988c9bbf519fcbc300f47c43b369d0
|
4
|
+
data.tar.gz: 6c11fc29b21f4b21997ce99d9ac487417d975260
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb93c86309e617ee74f2bf28129310028fe6eaa29836b80eb9b41b7ac6ad5a9a4c17ae58f00a95921d114f8ffefbee7c6ed007cdd255778d785b7baff66f49fc
|
7
|
+
data.tar.gz: b390df5675f5ba096e4be05ce0b12aa9151eccfd45b9f5cc2259ed4c14025152a15c343333a37e1fa9c302de894802ce9568963df1a2d766a0cdfa8f0eb20a9c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -27,6 +27,7 @@ You may override these settings through environment variables.
|
|
27
27
|
|
28
28
|
```
|
29
29
|
SYNCHRONISED_COMMAND=bin/launch/migrate
|
30
|
+
WITH_CLEAN_BUNDLER_ENV=1 # Non-empty for true
|
30
31
|
REDLOCK_TIMEOUT_MS=3600000
|
31
32
|
REDLOCK_RETRY_DELAY_MS=200
|
32
33
|
REDLOCK_LOCK_KEY=migration-in-progress
|
@@ -49,7 +49,14 @@ class SynchronisedMigration::Main
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def migrate
|
52
|
-
Kernel.system target_command
|
52
|
+
return Kernel.system target_command unless with_clean_env?
|
53
|
+
Bundler.with_clean_env do
|
54
|
+
Kernel.system target_command
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def with_clean_env?
|
59
|
+
not ENV.fetch('WITH_CLEAN_BUNDLER_ENV', '').empty?
|
53
60
|
end
|
54
61
|
|
55
62
|
def migration_failed?
|
@@ -27,6 +27,8 @@ describe SynchronisedMigration::Main do
|
|
27
27
|
method.call *args
|
28
28
|
}
|
29
29
|
|
30
|
+
allow(Bundler).to receive(:with_clean_env).and_call_original
|
31
|
+
|
30
32
|
stub_const(
|
31
33
|
'RedisConfig', double(
|
32
34
|
get: {
|
@@ -45,10 +47,24 @@ describe SynchronisedMigration::Main do
|
|
45
47
|
expect(redis).to have_received(:get).with('migration-failed')
|
46
48
|
expect(redis).to have_received(:set).with('migration-failed', 1)
|
47
49
|
expect(Kernel).to have_received(:system)
|
50
|
+
expect(Bundler).not_to have_received(:with_clean_env)
|
48
51
|
expect(redis).to have_received(:del).with('migration-failed')
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
55
|
+
context 'when require a clean Bundler environment' do
|
56
|
+
before do
|
57
|
+
allow(ENV).to receive(:fetch).and_call_original
|
58
|
+
allow(ENV).to receive(:fetch).with('WITH_CLEAN_BUNDLER_ENV', '').and_return('1')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'executes it with a clean Bundler environment' do
|
62
|
+
expect(result).to be_success
|
63
|
+
expect(Kernel).to have_received(:system)
|
64
|
+
expect(Bundler).to have_received(:with_clean_env)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
52
68
|
context 'after a deployment failed previously' do
|
53
69
|
let(:fail_marker_value) { '1' }
|
54
70
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synchronised_migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alvin Yim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redlock
|