prodder 1.7.7 → 1.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +2 -0
- data/.github/workflows/ci.yml +69 -0
- data/.gitignore +0 -21
- data/Dockerfile +23 -0
- data/README.md +1 -1
- data/compose.yml +54 -0
- data/entrypoints/entry.sh +15 -0
- data/lib/prodder/pg.rb +1 -0
- data/lib/prodder/prodder.rake +15 -16
- data/lib/prodder/version.rb +1 -1
- metadata +25 -8
- data/.travis.yml +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3ab994663f2c4c9e24475f197d4aa5c2cc29fb98f2ee14841fb4f9df4dc680e
|
4
|
+
data.tar.gz: 59000cbb6bade96b5ae1e9143897fdf4706c149fa55ead7bc975832587dcebe8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7914656c214ae8f87f23fe15de87a67bc9b471c65454408496639c4632364dccda94cbd8551b101b2989bd5d649fa6f3ff68a49da07fc476921af802f52d982
|
7
|
+
data.tar.gz: 2d3485303746abae32e25e57fbad7793a07878a1cdf2be230b6c94d250efaf7de3023b053bfb795539f205421fa386289332816783be4fdb1376cde320ddc732
|
data/.dockerignore
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- main
|
8
|
+
pull_request_target:
|
9
|
+
branches:
|
10
|
+
- main
|
11
|
+
|
12
|
+
permissions:
|
13
|
+
contents: read
|
14
|
+
|
15
|
+
jobs:
|
16
|
+
test:
|
17
|
+
runs-on: ubuntu-latest
|
18
|
+
strategy:
|
19
|
+
fail-fast: false
|
20
|
+
matrix:
|
21
|
+
ruby-version: [2.6, 2.7, 3.0]
|
22
|
+
services:
|
23
|
+
postgres:
|
24
|
+
image: postgres:13-alpine
|
25
|
+
ports:
|
26
|
+
- 5432:5432
|
27
|
+
env:
|
28
|
+
POSTGRES_USER: postgres
|
29
|
+
POSTGRES_PASSWORD: postgres
|
30
|
+
POSTGRES_HOST_AUTH_METHOD: trust
|
31
|
+
options: >-
|
32
|
+
--health-cmd pg_isready
|
33
|
+
--health-interval 10s
|
34
|
+
--health-timeout 5s
|
35
|
+
--health-retries 5
|
36
|
+
steps:
|
37
|
+
- name: Checkout Project
|
38
|
+
uses: actions/checkout@v4
|
39
|
+
- name: Set up Ruby
|
40
|
+
uses: ruby/setup-ruby@v1
|
41
|
+
with:
|
42
|
+
ruby-version: ${{ matrix.ruby-version }}
|
43
|
+
bundler-cache: true
|
44
|
+
- name: Install Library Dependencies
|
45
|
+
run: sudo apt update && sudo apt install -y postgresql-client
|
46
|
+
- name: Setup Database
|
47
|
+
run: |
|
48
|
+
mkdir -p config
|
49
|
+
cat <<EOF > config/database.yml
|
50
|
+
test:
|
51
|
+
adapter: postgresql
|
52
|
+
encoding: unicode
|
53
|
+
pool: 20
|
54
|
+
database: prodder_test
|
55
|
+
EOF
|
56
|
+
- name: Test with RSpec
|
57
|
+
env:
|
58
|
+
PGHOST: localhost
|
59
|
+
PGPORT: 5432
|
60
|
+
PGUSER: postgres
|
61
|
+
PGPASSWORD: postgres
|
62
|
+
run: bundle exec rspec
|
63
|
+
- name: Test with Cucumber
|
64
|
+
env:
|
65
|
+
PGHOST: localhost
|
66
|
+
PGPORT: 5432
|
67
|
+
PGUSER: postgres
|
68
|
+
PGPASSWORD: postgres
|
69
|
+
run: bundle exec cucumber
|
data/.gitignore
CHANGED
@@ -1,23 +1,2 @@
|
|
1
1
|
Gemfile.lock
|
2
|
-
*.gem
|
3
|
-
*.rbc
|
4
|
-
.bundle
|
5
|
-
.config
|
6
|
-
coverage
|
7
|
-
InstalledFiles
|
8
|
-
lib/bundler/man
|
9
|
-
pkg
|
10
|
-
rdoc
|
11
|
-
spec/reports
|
12
|
-
test/tmp
|
13
|
-
test/version_tmp
|
14
2
|
tmp
|
15
|
-
|
16
|
-
# YARD artifacts
|
17
|
-
.yardoc
|
18
|
-
_yardoc
|
19
|
-
doc/
|
20
|
-
|
21
|
-
nc.yml
|
22
|
-
prodder-workspace/
|
23
|
-
features/support/blog.git
|
data/Dockerfile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
ARG RUBY_VERSION=3.0
|
2
|
+
|
3
|
+
FROM ruby:${RUBY_VERSION}
|
4
|
+
|
5
|
+
WORKDIR /app
|
6
|
+
|
7
|
+
RUN apt update && \
|
8
|
+
apt install -y git postgresql-client && \
|
9
|
+
apt clean && \
|
10
|
+
rm -rf /var/lib/apt/lists/*
|
11
|
+
|
12
|
+
ENV BUNDLER_VERSION 2.4.22
|
13
|
+
|
14
|
+
RUN gem install bundler -v $BUNDLER_VERSION
|
15
|
+
|
16
|
+
COPY Gemfile ./
|
17
|
+
|
18
|
+
RUN bundle install -j $(nproc)
|
19
|
+
|
20
|
+
COPY . .
|
21
|
+
|
22
|
+
ENTRYPOINT ["entrypoints/entry.sh"]
|
23
|
+
CMD ["bin/prodder"]
|
data/README.md
CHANGED
@@ -82,7 +82,7 @@ Things that really matter:
|
|
82
82
|
created. Those initial seeds should have included your production app's `schema_migrations`
|
83
83
|
table contents. This means only those migrations that have not yet run in production
|
84
84
|
will need to be run locally.
|
85
|
-
3. If you
|
85
|
+
3. If you configured to have 3 users in your `#config/database.yml` file and have a `permissions.sql` file present,
|
86
86
|
all your `db:*` commands will be run in the context of the user it makes the most sense to run as, mimicking
|
87
87
|
our production environment. For instance(s), to reset the database (god forbid we do this in production), it will
|
88
88
|
run as `superuser`, to run a migration, as the `migration_user` and your application will connect to the database
|
data/compose.yml
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
services:
|
2
|
+
postgres:
|
3
|
+
image: postgres:13-alpine
|
4
|
+
volumes:
|
5
|
+
- postgres_data:/var/lib/postgresql/data
|
6
|
+
ports:
|
7
|
+
- 5432:5432
|
8
|
+
environment:
|
9
|
+
POSTGRES_USER: postgres
|
10
|
+
POSTGRES_PASSWORD: postgres
|
11
|
+
POSTGRES_HOST_AUTH_METHOD: trust
|
12
|
+
healthcheck:
|
13
|
+
test: ["CMD", "pg_isready"]
|
14
|
+
interval: 10s
|
15
|
+
timeout: 5s
|
16
|
+
retries: 5
|
17
|
+
restart: on-failure:5
|
18
|
+
|
19
|
+
prodder:
|
20
|
+
platform: linux/arm64
|
21
|
+
build:
|
22
|
+
context: .
|
23
|
+
dockerfile: Dockerfile
|
24
|
+
args:
|
25
|
+
RUBY_VERSION: 3.0
|
26
|
+
volumes:
|
27
|
+
- .:/app
|
28
|
+
- /app/config
|
29
|
+
depends_on:
|
30
|
+
postgres:
|
31
|
+
condition: service_healthy
|
32
|
+
environment:
|
33
|
+
PGHOST: localhost
|
34
|
+
PGPORT: "5432"
|
35
|
+
PGUSER: postgres
|
36
|
+
PGPASSWORD: postgres
|
37
|
+
network_mode: host
|
38
|
+
|
39
|
+
rspec:
|
40
|
+
profiles:
|
41
|
+
- test
|
42
|
+
extends:
|
43
|
+
service: prodder
|
44
|
+
command: bundle exec rspec
|
45
|
+
|
46
|
+
cucumber:
|
47
|
+
profiles:
|
48
|
+
- test
|
49
|
+
extends:
|
50
|
+
service: prodder
|
51
|
+
command: bundle exec cucumber
|
52
|
+
|
53
|
+
volumes:
|
54
|
+
postgres_data:
|
data/lib/prodder/pg.rb
CHANGED
data/lib/prodder/prodder.rake
CHANGED
@@ -169,7 +169,7 @@ namespace :db do
|
|
169
169
|
end
|
170
170
|
as("superuser", in: environments) do
|
171
171
|
ActiveRecord::Tasks::DatabaseTasks.create_current
|
172
|
-
ActiveRecord::Base.configurations.each do |env, config|
|
172
|
+
ActiveRecord::Base.configurations.to_h.each do |env, config|
|
173
173
|
if environments.include?(env) && config["migration_user"] && config['database']
|
174
174
|
set_psql_env config
|
175
175
|
`psql --no-psqlrc --command "ALTER DATABASE #{config['database']} OWNER TO #{config['migration_user']}" #{Shellwords.escape(config['database'])}`
|
@@ -182,7 +182,7 @@ namespace :db do
|
|
182
182
|
task :all => dependencies do
|
183
183
|
as("superuser") do
|
184
184
|
ActiveRecord::Tasks::DatabaseTasks.create_all
|
185
|
-
ActiveRecord::Base.configurations.each do |env, config|
|
185
|
+
ActiveRecord::Base.configurations.to_h.each do |env, config|
|
186
186
|
if config["migration_user"] && config['database']
|
187
187
|
set_psql_env config
|
188
188
|
`psql --no-psqlrc --command "ALTER DATABASE #{config['database']} OWNER TO #{config['migration_user']}" #{Shellwords.escape(config['database'])}`
|
@@ -204,7 +204,7 @@ namespace :db do
|
|
204
204
|
desc "Load db/structure.sql into the current environment's database"
|
205
205
|
task :load => dependencies do
|
206
206
|
as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
|
207
|
-
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
|
207
|
+
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env].with_indifferent_access
|
208
208
|
set_psql_env config
|
209
209
|
puts "Loading db/structure.sql into database '#{config['database']}'"
|
210
210
|
`psql --no-psqlrc -f db/structure.sql #{Shellwords.escape(config['database'])}`
|
@@ -217,7 +217,7 @@ namespace :db do
|
|
217
217
|
task :seed => dependencies do
|
218
218
|
if File.exist?('db/seeds.sql')
|
219
219
|
as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
|
220
|
-
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
|
220
|
+
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env].with_indifferent_access
|
221
221
|
set_psql_env config
|
222
222
|
puts "Loading db/seeds.sql into database '#{config['database']}'"
|
223
223
|
`psql --no-psqlrc -f db/seeds.sql #{Shellwords.escape(config['database'])}`
|
@@ -232,7 +232,7 @@ namespace :db do
|
|
232
232
|
task :quality_check => dependencies do
|
233
233
|
if File.exist?('db/quality_checks.sql')
|
234
234
|
as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
|
235
|
-
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
|
235
|
+
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env].with_indifferent_access
|
236
236
|
set_psql_env config
|
237
237
|
puts "Loading db/quality_checks.sql into database '#{config['database']}'"
|
238
238
|
`psql --no-psqlrc -f db/quality_checks.sql #{Shellwords.escape(config['database'])}`
|
@@ -247,7 +247,7 @@ namespace :db do
|
|
247
247
|
task :permission => dependencies do
|
248
248
|
if File.exist?('db/permissions.sql')
|
249
249
|
as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
|
250
|
-
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
|
250
|
+
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env].with_indifferent_access
|
251
251
|
set_psql_env config
|
252
252
|
puts "Loading db/permissions.sql into database '#{config['database']}'"
|
253
253
|
result = ActiveRecord::Base.connection.execute(<<-SQL).first
|
@@ -268,7 +268,7 @@ namespace :db do
|
|
268
268
|
task :settings => dependencies do
|
269
269
|
if File.exist?('db/settings.sql')
|
270
270
|
as("superuser", in: ENV['RAILS_ENV'] || Rails.env) do
|
271
|
-
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env]
|
271
|
+
config = ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env].with_indifferent_access
|
272
272
|
set_psql_env config
|
273
273
|
puts "Loading db/settings.sql into database '#{config['database']}'"
|
274
274
|
result = ActiveRecord::Base.connection.execute(<<-SQL).first
|
@@ -362,20 +362,19 @@ namespace :db do
|
|
362
362
|
|
363
363
|
def as(user, opts = {}, &block)
|
364
364
|
if File.exist?('db/permissions.sql')
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
config
|
371
|
-
ActiveRecord::Base.configurations = config
|
365
|
+
original_config = ActiveRecord::Base.configurations.deep_dup
|
366
|
+
in_env = Array(opts[:in]) || ActiveRecord::Base.configurations.deep_dup.to_h.keys
|
367
|
+
disconnect
|
368
|
+
in_env.each do |env|
|
369
|
+
config = ActiveRecord::Base.configurations.find_db_config(env)
|
370
|
+
config["username"] = config[user]
|
372
371
|
end
|
373
372
|
else
|
374
373
|
puts "No permissions file (db/permissions.sql) found, running everything in context of user"
|
375
374
|
end
|
376
375
|
yield
|
377
376
|
ensure
|
378
|
-
ActiveRecord::Base.configurations =
|
377
|
+
ActiveRecord::Base.configurations = original_config if original_config
|
379
378
|
in_env.each { |env| ActiveRecord::Base.establish_connection(env.intern) } if in_env
|
380
379
|
end
|
381
380
|
|
@@ -394,5 +393,5 @@ end
|
|
394
393
|
|
395
394
|
# Yes, I really want migrations to run against the test DB.
|
396
395
|
Rake::Task['db:migrate'].actions.unshift(proc {
|
397
|
-
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env])
|
396
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[ENV['RAILS_ENV'] || Rails.env].with_indifferent_access)
|
398
397
|
})
|
data/lib/prodder/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prodder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Hargraves
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deject
|
@@ -32,13 +32,17 @@ executables:
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
+
- ".dockerignore"
|
36
|
+
- ".github/workflows/ci.yml"
|
35
37
|
- ".gitignore"
|
36
|
-
-
|
38
|
+
- Dockerfile
|
37
39
|
- Gemfile
|
38
40
|
- LICENSE.txt
|
39
41
|
- README.md
|
40
42
|
- Rakefile
|
41
43
|
- bin/prodder
|
44
|
+
- compose.yml
|
45
|
+
- entrypoints/entry.sh
|
42
46
|
- features/commit.feature
|
43
47
|
- features/dump.feature
|
44
48
|
- features/init.feature
|
@@ -66,7 +70,7 @@ homepage: https://github.com/enova/prodder
|
|
66
70
|
licenses:
|
67
71
|
- MIT
|
68
72
|
metadata: {}
|
69
|
-
post_install_message:
|
73
|
+
post_install_message:
|
70
74
|
rdoc_options: []
|
71
75
|
require_paths:
|
72
76
|
- lib
|
@@ -81,9 +85,22 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
85
|
- !ruby/object:Gem::Version
|
82
86
|
version: '0'
|
83
87
|
requirements: []
|
84
|
-
rubygems_version: 3.
|
85
|
-
signing_key:
|
88
|
+
rubygems_version: 3.3.26
|
89
|
+
signing_key:
|
86
90
|
specification_version: 4
|
87
91
|
summary: Maintain your Rails apps' structure, seed and quality_checks files using
|
88
92
|
production dumps
|
89
|
-
test_files:
|
93
|
+
test_files:
|
94
|
+
- features/commit.feature
|
95
|
+
- features/dump.feature
|
96
|
+
- features/init.feature
|
97
|
+
- features/lint.feature
|
98
|
+
- features/prodder.feature
|
99
|
+
- features/push.feature
|
100
|
+
- features/step_definitions/git_steps.rb
|
101
|
+
- features/step_definitions/prodder_steps.rb
|
102
|
+
- features/support/blog.git.tgz
|
103
|
+
- features/support/env.rb
|
104
|
+
- features/support/prodder__blog_prod.sql
|
105
|
+
- spec/config_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
data/.travis.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
|
4
|
-
rvm:
|
5
|
-
- 2.5.8
|
6
|
-
- 2.7.2
|
7
|
-
|
8
|
-
env:
|
9
|
-
matrix:
|
10
|
-
- PG_VERSION=11
|
11
|
-
|
12
|
-
before_install:
|
13
|
-
- git config --global user.name "Prodder In Travis-CI"
|
14
|
-
- git config --global user.email "prodder@example.com"
|
15
|
-
# install postgres
|
16
|
-
- sudo apt-get install postgresql-client-$PG_VERSION postgresql-server-dev-$PG_VERSION
|
17
|
-
# setup pg_dump
|
18
|
-
- ls -al /usr/lib/postgresql/
|
19
|
-
- sudo ln -sfn /usr/lib/postgresql/$PG_VERSION/bin/pg_dump /usr/bin/pg_dump
|
20
|
-
# start up the specific version of PG
|
21
|
-
- sudo -E sh -c 'service postgresql stop'
|
22
|
-
- sleep 5s
|
23
|
-
- sudo -E sh -c 'service postgresql start $PG_VERSION'
|
24
|
-
- psql -U postgres -d postgres -c 'select setting from pg_settings where name = $m$server_version$m$;'
|
25
|
-
|
26
|
-
script:
|
27
|
-
- psql --version
|
28
|
-
- pg_lsclusters
|
29
|
-
- psql -U postgres -d postgres -c 'select 1;'
|
30
|
-
- ls -al `which pg_dump`
|
31
|
-
- bundle exec rake spec
|
32
|
-
- bundle exec rake cucumber
|
33
|
-
|
34
|
-
deploy:
|
35
|
-
provider: rubygems
|
36
|
-
api_key:
|
37
|
-
secure: "UhUkPFhEuI1dLPa4skTUdOBcGY2SEkRP3N9jLDQad04DflV+GutcjrfN1iQxWk59gVt3zqird5FS8SdwCFuOn8DAU9ACtg73xiPPWRRTdzma4Qw+4thuOHcdwPBz3762YFTRyH7IbRTAlxaD6qPz6US3BnYAkJU7C8c30rHLX6cZutjLV4FsvWonkzxcjyEUViVEdBM0kzI+tdBnQovpcM67a9AfxxBZITJLIfIcah1qc/RANpLkUFJCwNyH9oARWsGIvpIKcQEJBhsl04tvbNRLpiMCk1e1RS1bjMdbbx/rVm3C7dvAjUznbr3ON9abgoe6QDDYr6kXPJbylmxFUzA7ftBWjz2nNruRncsohx08LaM4ADRJWKB3XbP5BXkwUgE672Fi20+Z78LwWfjrr3iRVm7u9Mt9pZHG6Ih8Jy64Uq3647kdVZu9APPfn1NZETFG7vLAMZUtPXv7HBkujlq23XdYXax1XYYbYsM0LOlnG6ol2y6OrBrxWIqC+E8UmLXf/+/MS4j3v2RAe7jXh6fFlw+5MjLr3HXqZ12CrAChp22NRPp1OY4Hac4zzRwGeVOgewknpOK7qQfVFFaQoQksU6VaenSx+TxcYOZYuQdrQjfbO6c+Q/vvZ1RoPOEwH0AelkrW2eGqQTNVWIbH5vvfhys68SA8ov8gNnIzMtU="
|
38
|
-
gem: prodder
|
39
|
-
on:
|
40
|
-
tags: true
|
41
|
-
repo: enova/prodder
|