pronto-rails_migrations 0.1.0 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/build_release_pipeline.yaml +51 -0
- data/.ruby-version +1 -0
- data/Gemfile +0 -2
- data/README.md +2 -22
- data/Rakefile +5 -0
- data/lib/pronto/rails_migrations.rb +55 -13
- data/lib/pronto/version.rb +5 -0
- data/pronto-rails_migrations.gemspec +7 -6
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5cefbfc63cd234afd1eb5341b765f25b716d95e4b219abd8cada9591bdf5d885
|
4
|
+
data.tar.gz: 76f016c3ddc9f11e8d18a13f4056babdcbb65a734290e4399e765711bfb02697
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a9c17485cc28c461c0a3d9be9050c34c39e3a4b9d61eac3fd24980458f4deb3c26af69ad32efdecb62418c4fb389232149cfdf515dad17d383f39b6f873e547
|
7
|
+
data.tar.gz: 9233b1af3c14348186ebd2fdeffde3805fe011a65ce8df4894c639770fb895ba66f3bc2c0b1ff0c1a9f3dee0cb066d5854854df4be4db91ac36f285ff45972c6
|
@@ -0,0 +1,51 @@
|
|
1
|
+
name: Build and release ruby gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
branches: [ master ]
|
6
|
+
push:
|
7
|
+
workflow_dispatch:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build-release-pipeline:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
container: ruby:2.7.2
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- name: Setup
|
16
|
+
run: |
|
17
|
+
apt-get update -y && apt-get install -y --no-install-recommends cmake=3.13.4-1
|
18
|
+
gem install bundler
|
19
|
+
bundle install
|
20
|
+
|
21
|
+
- name: Build
|
22
|
+
id: build
|
23
|
+
if: success() && github.ref == 'refs/heads/master'
|
24
|
+
run: |
|
25
|
+
bundle exec rake build
|
26
|
+
echo "::set-output name=gem_version::v$(bundle exec rake version)"
|
27
|
+
|
28
|
+
- name: Release
|
29
|
+
if: success() && github.ref == 'refs/heads/master'
|
30
|
+
run: |
|
31
|
+
mkdir -p $HOME/.gem
|
32
|
+
touch $HOME/.gem/credentials
|
33
|
+
chmod 600 $HOME/.gem/credentials
|
34
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
35
|
+
gem push pkg/*
|
36
|
+
env:
|
37
|
+
GEM_HOST_API_KEY: "${{ secrets.RUBYGEMS_AUTH_TOKEN }}"
|
38
|
+
|
39
|
+
- name: Tag repo with new gem version
|
40
|
+
if: success() && github.ref == 'refs/heads/master'
|
41
|
+
uses: actions/github-script@v3
|
42
|
+
with:
|
43
|
+
github-token: ${{ github.token }}
|
44
|
+
script: |
|
45
|
+
github.git.createRef({
|
46
|
+
owner: context.repo.owner,
|
47
|
+
repo: context.repo.repo,
|
48
|
+
ref: "refs/tags/${{ steps.build.outputs.gem_version }}",
|
49
|
+
sha: context.sha
|
50
|
+
})
|
51
|
+
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.2
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,39 +1,19 @@
|
|
1
1
|
# Pronto::RailsMigrations
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This pronto runner warns when migrations are run and application code is changed at the same time.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
10
8
|
|
11
9
|
```ruby
|
12
|
-
gem 'pronto-rails_migrations'
|
10
|
+
gem 'pronto-rails_migrations', require: false
|
13
11
|
```
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
17
15
|
$ bundle
|
18
16
|
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install pronto-rails_migrations
|
22
|
-
|
23
|
-
## Usage
|
24
|
-
|
25
|
-
TODO: Write usage instructions here
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pronto-rails_migrations.
|
36
|
-
|
37
17
|
## License
|
38
18
|
|
39
19
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
module Pronto
|
2
2
|
class RailsMigrations < Runner
|
3
3
|
def run
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
else
|
16
|
-
[]
|
4
|
+
return [] unless migration_patches?
|
5
|
+
|
6
|
+
messages = []
|
7
|
+
|
8
|
+
if other_patches?
|
9
|
+
patch = migration_patches.first
|
10
|
+
messages << message(
|
11
|
+
patch,
|
12
|
+
'Run migrations in a separate PR from application code changes.'
|
13
|
+
)
|
17
14
|
end
|
15
|
+
|
16
|
+
messages + bad_structure_sql_messages
|
18
17
|
end
|
19
18
|
|
20
19
|
private
|
@@ -31,6 +30,49 @@ module Pronto
|
|
31
30
|
@patches.reject { |patch| migration_patch?(patch) }.any?
|
32
31
|
end
|
33
32
|
|
33
|
+
def bad_structure_sql_messages
|
34
|
+
patch = structure_sql_patches.first
|
35
|
+
return [] unless patch
|
36
|
+
|
37
|
+
structure_sql = File.read(patch.new_file_full_path)
|
38
|
+
inserts = structure_sql.split("\n").grep(/\('\d+'\)/)
|
39
|
+
unordered_inserts = (inserts.sort != inserts)
|
40
|
+
|
41
|
+
*all_but_tail, tail = inserts
|
42
|
+
bad_semicolons = all_but_tail.any? { |line| line.end_with?(';') } || !tail.end_with?(';')
|
43
|
+
|
44
|
+
bad_ending = structure_sql[-4, 4] !~ /[^\n]\n\n\n/
|
45
|
+
|
46
|
+
messages = []
|
47
|
+
|
48
|
+
if unordered_inserts
|
49
|
+
messages << message(
|
50
|
+
patch,
|
51
|
+
'`schema_migrations` insert values are not ordered by timestamp.'
|
52
|
+
)
|
53
|
+
end
|
54
|
+
if bad_semicolons
|
55
|
+
messages << message(
|
56
|
+
patch,
|
57
|
+
'`schema_migrations` inserts must end with comma (`,`), ' \
|
58
|
+
'last insert must end with semicolon (`;`).'
|
59
|
+
)
|
60
|
+
end
|
61
|
+
messages << message(patch, '`db/structure.sql` must end with 2 empty lines.') if bad_ending
|
62
|
+
|
63
|
+
messages
|
64
|
+
end
|
65
|
+
|
66
|
+
def message(patch, text)
|
67
|
+
path = patch.delta.new_file[:path]
|
68
|
+
line = patch.added_lines.first
|
69
|
+
Message.new(path, line, :warning, text, nil, self.class)
|
70
|
+
end
|
71
|
+
|
72
|
+
def structure_sql_patches
|
73
|
+
@patches.select { |patch| patch.new_file_full_path.to_s =~ /structure\.sql/ }
|
74
|
+
end
|
75
|
+
|
34
76
|
def migration_patch?(patch)
|
35
77
|
path = patch.new_file_full_path.to_s
|
36
78
|
/db.(schema.rb|structure.sql|migrate)/ =~ path
|
@@ -1,12 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pronto/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |spec|
|
6
7
|
spec.name = "pronto-rails_migrations"
|
7
|
-
spec.version =
|
8
|
-
spec.authors = ["
|
9
|
-
spec.email = ["
|
8
|
+
spec.version = Pronto::RailsMigrations::VERSION
|
9
|
+
spec.authors = ["Vinted"]
|
10
|
+
spec.email = ["backend@vinted.com"]
|
10
11
|
|
11
12
|
spec.summary = %q{Validate migration and application code change seperation}
|
12
13
|
spec.description = %q{This pronto runner warns when migrations are run and application code is changed at the same time}
|
@@ -20,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
20
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
22
|
spec.require_paths = ["lib"]
|
22
23
|
|
23
|
-
spec.add_dependency('pronto', '
|
24
|
+
spec.add_dependency('pronto', '>= 0.10.0')
|
24
25
|
|
25
|
-
spec.add_development_dependency "bundler"
|
26
|
-
spec.add_development_dependency "rake", "~>
|
26
|
+
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
27
28
|
end
|
metadata
CHANGED
@@ -1,66 +1,68 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pronto-rails_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Vinted
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pronto
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.10.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '12.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '12.0'
|
55
55
|
description: This pronto runner warns when migrations are run and application code
|
56
56
|
is changed at the same time
|
57
57
|
email:
|
58
|
-
-
|
58
|
+
- backend@vinted.com
|
59
59
|
executables: []
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".github/workflows/build_release_pipeline.yaml"
|
63
64
|
- ".gitignore"
|
65
|
+
- ".ruby-version"
|
64
66
|
- Gemfile
|
65
67
|
- LICENSE.txt
|
66
68
|
- README.md
|
@@ -68,6 +70,7 @@ files:
|
|
68
70
|
- bin/console
|
69
71
|
- bin/setup
|
70
72
|
- lib/pronto/rails_migrations.rb
|
73
|
+
- lib/pronto/version.rb
|
71
74
|
- pronto-rails_migrations.gemspec
|
72
75
|
homepage: https://github.com/tomasv/pronto-rails_migrations
|
73
76
|
licenses:
|
@@ -88,8 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
91
|
- !ruby/object:Gem::Version
|
89
92
|
version: '0'
|
90
93
|
requirements: []
|
91
|
-
|
92
|
-
rubygems_version: 2.6.11
|
94
|
+
rubygems_version: 3.1.4
|
93
95
|
signing_key:
|
94
96
|
specification_version: 4
|
95
97
|
summary: Validate migration and application code change seperation
|