prodder 1.8.1 → 1.8.2

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: 5e8921f51e1bb936a99eaccc98d04bcd34ff72acbe20cb5547f6e680f8e4106a
4
- data.tar.gz: 0e47795334cfcd4944d877dd5c24ab72e4fa5b082d66400b5c0a318228ba0f5d
3
+ metadata.gz: e3ab994663f2c4c9e24475f197d4aa5c2cc29fb98f2ee14841fb4f9df4dc680e
4
+ data.tar.gz: 59000cbb6bade96b5ae1e9143897fdf4706c149fa55ead7bc975832587dcebe8
5
5
  SHA512:
6
- metadata.gz: 12817961230a0fd95776ff3bdf4a95b62fb8b961bbf2db9d93413f8cf93c32a9f11c4e036ffd89b0e4e5c0807ef40cf5d342706b0cd7a1f214c1f9c3a840547b
7
- data.tar.gz: 34c918bd1587a1c055ffd76866028a5cd7e7c371c42cec0381e01294af4f308b5478d59f2406a8d5dea73755e5c16cb0d33b2b206e8a450448cceca6b5a2b748
6
+ metadata.gz: c7914656c214ae8f87f23fe15de87a67bc9b471c65454408496639c4632364dccda94cbd8551b101b2989bd5d649fa6f3ff68a49da07fc476921af802f52d982
7
+ data.tar.gz: 2d3485303746abae32e25e57fbad7793a07878a1cdf2be230b6c94d250efaf7de3023b053bfb795539f205421fa386289332816783be4fdb1376cde320ddc732
data/.dockerignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ tmp
@@ -5,7 +5,9 @@ on:
5
5
  push:
6
6
  branches:
7
7
  - main
8
- pull_request:
8
+ pull_request_target:
9
+ branches:
10
+ - main
9
11
 
10
12
  permissions:
11
13
  contents: read
@@ -14,42 +16,54 @@ jobs:
14
16
  test:
15
17
  runs-on: ubuntu-latest
16
18
  strategy:
19
+ fail-fast: false
17
20
  matrix:
18
21
  ruby-version: [2.6, 2.7, 3.0]
19
22
  services:
20
23
  postgres:
21
- image: postgres:12.1-alpine
24
+ image: postgres:13-alpine
22
25
  ports:
23
26
  - 5432:5432
24
27
  env:
25
28
  POSTGRES_USER: postgres
26
29
  POSTGRES_PASSWORD: postgres
27
- options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
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
28
36
  steps:
29
37
  - name: Checkout Project
30
- uses: actions/checkout@v3
31
-
38
+ uses: actions/checkout@v4
32
39
  - name: Set up Ruby
33
40
  uses: ruby/setup-ruby@v1
34
41
  with:
35
42
  ruby-version: ${{ matrix.ruby-version }}
36
43
  bundler-cache: true
37
-
38
44
  - name: Install Library Dependencies
39
- run: sudo apt-get install libpq-dev
40
-
45
+ run: sudo apt update && sudo apt install -y postgresql-client
41
46
  - name: Setup Database
42
47
  run: |
43
- cp config/database.yml.github-actions config/database.yml
44
- env:
45
- RAILS_ENV: test
46
- POSTGRES_USER: postgres
47
- POSTGRES_PASSWORD: postgres
48
-
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
49
56
  - name: Test with RSpec
50
57
  env:
51
- RAILS_ENV: "test"
52
- POSTGRES_USER: postgres
53
- POSTGRES_PASSWORD: postgres
54
- run: |
55
- bundle exec rspec
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 configred to have 3 users in your `#config/database.yml` file and have a `permissions.sql` file present,
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:
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ cmd=("$@")
5
+
6
+ mkdir -p config
7
+ cat <<EOF > config/database.yml
8
+ test:
9
+ adapter: postgresql
10
+ encoding: unicode
11
+ pool: 20
12
+ database: prodder_test
13
+ EOF
14
+
15
+ exec "${cmd[@]}"
data/lib/prodder/pg.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'open3'
2
2
  require 'pg'
3
+ require 'set'
3
4
 
4
5
  module Prodder
5
6
  class PG
@@ -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
- Rails.configuration.database_configuration.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
- Rails.configuration.database_configuration.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'])}`
@@ -362,19 +362,19 @@ namespace :db do
362
362
 
363
363
  def as(user, opts = {}, &block)
364
364
  if File.exist?('db/permissions.sql')
365
- config, config_was = Rails.configuration.database_configuration, ActiveRecord::Base.configurations.deep_dup
366
- in_env = Array(opts[:in]) || config.keys
367
- if config.all? { |env, config_hash| in_env.include?(env) ? config_hash[user] : true }
368
- disconnect
369
- config.each { |env, config_hash| config_hash["username"] = config_hash[user] if in_env.include?(env) }
370
- 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]
371
371
  end
372
372
  else
373
373
  puts "No permissions file (db/permissions.sql) found, running everything in context of user"
374
374
  end
375
375
  yield
376
376
  ensure
377
- ActiveRecord::Base.configurations = config_was if config_was
377
+ ActiveRecord::Base.configurations = original_config if original_config
378
378
  in_env.each { |env| ActiveRecord::Base.establish_connection(env.intern) } if in_env
379
379
  end
380
380
 
@@ -1,3 +1,3 @@
1
1
  module Prodder
2
- VERSION = "1.8.1"
2
+ VERSION = "1.8.2"
3
3
  end
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.8.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: 2023-03-01 00:00:00.000000000 Z
11
+ date: 2024-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deject
@@ -32,14 +32,17 @@ executables:
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - ".dockerignore"
35
36
  - ".github/workflows/ci.yml"
36
37
  - ".gitignore"
38
+ - Dockerfile
37
39
  - Gemfile
38
40
  - LICENSE.txt
39
41
  - README.md
40
42
  - Rakefile
41
43
  - bin/prodder
42
- - config/database.yml.github-actions
44
+ - compose.yml
45
+ - entrypoints/entry.sh
43
46
  - features/commit.feature
44
47
  - features/dump.feature
45
48
  - features/init.feature
@@ -67,7 +70,7 @@ homepage: https://github.com/enova/prodder
67
70
  licenses:
68
71
  - MIT
69
72
  metadata: {}
70
- post_install_message:
73
+ post_install_message:
71
74
  rdoc_options: []
72
75
  require_paths:
73
76
  - lib
@@ -82,8 +85,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
85
  - !ruby/object:Gem::Version
83
86
  version: '0'
84
87
  requirements: []
85
- rubygems_version: 3.0.3.1
86
- signing_key:
88
+ rubygems_version: 3.3.26
89
+ signing_key:
87
90
  specification_version: 4
88
91
  summary: Maintain your Rails apps' structure, seed and quality_checks files using
89
92
  production dumps
@@ -1,8 +0,0 @@
1
- test:
2
- adapter: postgresql
3
- host: localhost
4
- encoding: unicode
5
- database: github-actions
6
- pool: 20
7
- username: <%= ENV["POSTGRES_USER"] %>
8
- password: <%= ENV["POSTGRES_PASSWORD"] %>