travis-backup-for-v3 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.travis.yml +36 -0
  4. data/Gemfile +6 -0
  5. data/Gemfile.lock +215 -0
  6. data/README.md +100 -0
  7. data/Rakefile +18 -0
  8. data/bin/bundle +114 -0
  9. data/bin/console +8 -0
  10. data/bin/rails +5 -0
  11. data/bin/rake +7 -0
  12. data/bin/setup +36 -0
  13. data/bin/spring +14 -0
  14. data/bin/travis_backup_for_v3 +7 -0
  15. data/bin/yarn +17 -0
  16. data/config/application.rb +22 -0
  17. data/config/boot.rb +4 -0
  18. data/config/cable.yml +10 -0
  19. data/config/credentials.yml.enc +1 -0
  20. data/config/database.yml +23 -0
  21. data/config/environment.rb +5 -0
  22. data/config/environments/development.rb +76 -0
  23. data/config/environments/production.rb +120 -0
  24. data/config/environments/test.rb +60 -0
  25. data/config/initializers/application_controller_renderer.rb +8 -0
  26. data/config/initializers/assets.rb +14 -0
  27. data/config/initializers/backtrace_silencers.rb +8 -0
  28. data/config/initializers/content_security_policy.rb +30 -0
  29. data/config/initializers/cookies_serializer.rb +5 -0
  30. data/config/initializers/filter_parameter_logging.rb +6 -0
  31. data/config/initializers/inflections.rb +16 -0
  32. data/config/initializers/mime_types.rb +4 -0
  33. data/config/initializers/permissions_policy.rb +11 -0
  34. data/config/initializers/wrap_parameters.rb +14 -0
  35. data/config/locales/en.yml +33 -0
  36. data/config/puma.rb +43 -0
  37. data/config/routes.rb +3 -0
  38. data/config/settings.yml +7 -0
  39. data/config/spring.rb +6 -0
  40. data/config.ru +5 -0
  41. data/db/schema.sql +5417 -0
  42. data/dump/.keep +0 -0
  43. data/lib/backup/remove_specified/remove_heavy_data.rb +99 -0
  44. data/lib/backup/remove_specified/remove_with_all_dependencies.rb +51 -0
  45. data/lib/backup/remove_specified/shared.rb +20 -0
  46. data/lib/backup/remove_specified.rb +68 -0
  47. data/lib/backup/save_file.rb +43 -0
  48. data/lib/backup/save_id_hash_to_file.rb +33 -0
  49. data/lib/backup/save_nullified_rels_to_file.rb +29 -0
  50. data/lib/config.rb +198 -0
  51. data/lib/db_helper.rb +27 -0
  52. data/lib/dry_run_reporter.rb +47 -0
  53. data/lib/id_hash.rb +97 -0
  54. data/lib/ids_of_all_dependencies.rb +330 -0
  55. data/lib/model.rb +86 -0
  56. data/lib/models/abuse.rb +8 -0
  57. data/lib/models/beta_migration_request.rb +8 -0
  58. data/lib/models/branch.rb +18 -0
  59. data/lib/models/broadcast.rb +7 -0
  60. data/lib/models/build.rb +36 -0
  61. data/lib/models/build_config.rb +9 -0
  62. data/lib/models/cancellation.rb +8 -0
  63. data/lib/models/commit.rb +16 -0
  64. data/lib/models/cron.rb +7 -0
  65. data/lib/models/deleted_build.rb +37 -0
  66. data/lib/models/deleted_build_config.rb +10 -0
  67. data/lib/models/deleted_commit.rb +17 -0
  68. data/lib/models/deleted_job.rb +15 -0
  69. data/lib/models/deleted_job_config.rb +10 -0
  70. data/lib/models/deleted_pull_request.rb +12 -0
  71. data/lib/models/deleted_request.rb +26 -0
  72. data/lib/models/deleted_request_config.rb +10 -0
  73. data/lib/models/deleted_request_payload.rb +8 -0
  74. data/lib/models/deleted_request_raw_config.rb +10 -0
  75. data/lib/models/deleted_request_raw_configuration.rb +9 -0
  76. data/lib/models/deleted_request_yaml_config.rb +10 -0
  77. data/lib/models/deleted_ssl_key.rb +8 -0
  78. data/lib/models/deleted_stage.rb +10 -0
  79. data/lib/models/deleted_tag.rb +15 -0
  80. data/lib/models/email.rb +7 -0
  81. data/lib/models/email_unsubscribe.rb +8 -0
  82. data/lib/models/installation.rb +7 -0
  83. data/lib/models/invoice.rb +7 -0
  84. data/lib/models/job.rb +16 -0
  85. data/lib/models/job_config.rb +9 -0
  86. data/lib/models/job_version.rb +7 -0
  87. data/lib/models/membership.rb +8 -0
  88. data/lib/models/message.rb +7 -0
  89. data/lib/models/organization.rb +26 -0
  90. data/lib/models/owner_group.rb +7 -0
  91. data/lib/models/permission.rb +8 -0
  92. data/lib/models/pull_request.rb +11 -0
  93. data/lib/models/queueable_job.rb +7 -0
  94. data/lib/models/repo_count.rb +8 -0
  95. data/lib/models/repository.rb +39 -0
  96. data/lib/models/request.rb +25 -0
  97. data/lib/models/request_config.rb +9 -0
  98. data/lib/models/request_payload.rb +7 -0
  99. data/lib/models/request_raw_config.rb +9 -0
  100. data/lib/models/request_raw_configuration.rb +8 -0
  101. data/lib/models/request_yaml_config.rb +9 -0
  102. data/lib/models/ssl_key.rb +7 -0
  103. data/lib/models/stage.rb +9 -0
  104. data/lib/models/star.rb +8 -0
  105. data/lib/models/subscription.rb +9 -0
  106. data/lib/models/tag.rb +14 -0
  107. data/lib/models/token.rb +7 -0
  108. data/lib/models/trial.rb +8 -0
  109. data/lib/models/trial_allowance.rb +8 -0
  110. data/lib/models/user.rb +34 -0
  111. data/lib/models/user_beta_feature.rb +7 -0
  112. data/lib/models/user_utm_param.rb +7 -0
  113. data/lib/models.rb +58 -0
  114. data/lib/nullify_dependencies.rb +42 -0
  115. data/lib/travis-backup.rb +33 -0
  116. data/log/.keep +0 -0
  117. data/package.json +11 -0
  118. data/tmp/.keep +0 -0
  119. data/travis-backup-for-v3.gemspec +30 -0
  120. data/vendor/.keep +0 -0
  121. data/workspace.code-workspace +8 -0
  122. metadata +366 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c3fe0e536c1a109fb799ac8f5f66f1682733fc2e23a3a6f41139db81b4e56994
4
+ data.tar.gz: 6179311474e9df23ab9f04936621f917803af5f5d584c36545bc4fe1cd6a394c
5
+ SHA512:
6
+ metadata.gz: 1584e4ad9062f6827fe76f352b1d1042b4cf36bc16f5f67edb751a6d72efea1dbd802cf824ca05ad5fbebd8dd40eecd1662495602ed4acb2829b12473e092f1c
7
+ data.tar.gz: d3b475c84985217a86564597169093c39e85f782b0316c0f9631881e561d69216a829c364a7e19892626fd8295338d354e16f353e30036eb18f818fc83e12c54
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ tmp/*
2
+ log/*
3
+ dump/*
4
+ !tmp/.keep
5
+ !log/.keep
6
+ !dump/.keep
7
+ *.gem
8
+ .byebug_history
data/.travis.yml ADDED
@@ -0,0 +1,36 @@
1
+ rvm: 2.7.2
2
+ cache: bundler
3
+
4
+ services:
5
+ - redis
6
+
7
+ env:
8
+ global:
9
+ - PATH=/snap/bin:$PATH
10
+
11
+ jobs:
12
+ include:
13
+ - stage: "testing time"
14
+ script: bundle exec rspec --tag ~slow
15
+
16
+ dist: xenial
17
+
18
+ before_install:
19
+ - gem install bundler
20
+ - sudo apt-get install -yq --no-install-suggests --no-install-recommends postgresql-common
21
+ - sudo service postgresql stop
22
+ - sudo apt install -yq --no-install-suggests --no-install-recommends postgresql-11 postgresql-client-11
23
+ - sed -e 's/^port.*/port = 5432/' /etc/postgresql/11/main/postgresql.conf > postgresql.conf
24
+ - sudo chown postgres postgresql.conf
25
+ - sudo mv postgresql.conf /etc/postgresql/11/main
26
+ - sudo cp /etc/postgresql/{10,11}/main/pg_hba.conf
27
+ - sudo service postgresql start 11
28
+
29
+ before_script:
30
+ - psql --version
31
+ - psql -c 'CREATE DATABASE travis_test;' -U postgres
32
+ - psql -t -c "SELECT 1 FROM pg_roles WHERE rolname='travis'" -U postgres | grep 1 || psql -c 'CREATE ROLE travis SUPERUSER LOGIN CREATEDB;' -U postgres
33
+ - psql -f db/schema.sql -v ON_ERROR_STOP=1 travis_test
34
+ - psql -c 'CREATE DATABASE travis_test_destination;' -U postgres
35
+ - psql -t -c "SELECT 1 FROM pg_roles WHERE rolname='travis'" -U postgres | grep 1 || psql -c 'CREATE ROLE travis SUPERUSER LOGIN CREATEDB;' -U postgres
36
+ - psql -f db/schema.sql -v ON_ERROR_STOP=1 travis_test_destination
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
+
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,215 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ travis-backup-for-v3 (0.1.0)
5
+ activerecord
6
+ bootsnap
7
+ pg
8
+ pry
9
+ rails
10
+ tzinfo-data
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actioncable (6.1.4.1)
16
+ actionpack (= 6.1.4.1)
17
+ activesupport (= 6.1.4.1)
18
+ nio4r (~> 2.0)
19
+ websocket-driver (>= 0.6.1)
20
+ actionmailbox (6.1.4.1)
21
+ actionpack (= 6.1.4.1)
22
+ activejob (= 6.1.4.1)
23
+ activerecord (= 6.1.4.1)
24
+ activestorage (= 6.1.4.1)
25
+ activesupport (= 6.1.4.1)
26
+ mail (>= 2.7.1)
27
+ actionmailer (6.1.4.1)
28
+ actionpack (= 6.1.4.1)
29
+ actionview (= 6.1.4.1)
30
+ activejob (= 6.1.4.1)
31
+ activesupport (= 6.1.4.1)
32
+ mail (~> 2.5, >= 2.5.4)
33
+ rails-dom-testing (~> 2.0)
34
+ actionpack (6.1.4.1)
35
+ actionview (= 6.1.4.1)
36
+ activesupport (= 6.1.4.1)
37
+ rack (~> 2.0, >= 2.0.9)
38
+ rack-test (>= 0.6.3)
39
+ rails-dom-testing (~> 2.0)
40
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
41
+ actiontext (6.1.4.1)
42
+ actionpack (= 6.1.4.1)
43
+ activerecord (= 6.1.4.1)
44
+ activestorage (= 6.1.4.1)
45
+ activesupport (= 6.1.4.1)
46
+ nokogiri (>= 1.8.5)
47
+ actionview (6.1.4.1)
48
+ activesupport (= 6.1.4.1)
49
+ builder (~> 3.1)
50
+ erubi (~> 1.4)
51
+ rails-dom-testing (~> 2.0)
52
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
53
+ activejob (6.1.4.1)
54
+ activesupport (= 6.1.4.1)
55
+ globalid (>= 0.3.6)
56
+ activemodel (6.1.4.1)
57
+ activesupport (= 6.1.4.1)
58
+ activerecord (6.1.4.1)
59
+ activemodel (= 6.1.4.1)
60
+ activesupport (= 6.1.4.1)
61
+ activestorage (6.1.4.1)
62
+ actionpack (= 6.1.4.1)
63
+ activejob (= 6.1.4.1)
64
+ activerecord (= 6.1.4.1)
65
+ activesupport (= 6.1.4.1)
66
+ marcel (~> 1.0.0)
67
+ mini_mime (>= 1.1.0)
68
+ activesupport (6.1.4.1)
69
+ concurrent-ruby (~> 1.0, >= 1.0.2)
70
+ i18n (>= 1.6, < 2)
71
+ minitest (>= 5.1)
72
+ tzinfo (~> 2.0)
73
+ zeitwerk (~> 2.3)
74
+ ast (2.4.2)
75
+ bootsnap (1.9.1)
76
+ msgpack (~> 1.0)
77
+ brakeman (5.1.2)
78
+ builder (3.2.4)
79
+ byebug (11.1.3)
80
+ coderay (1.1.3)
81
+ concurrent-ruby (1.1.9)
82
+ crass (1.0.6)
83
+ database_cleaner-active_record (2.0.1)
84
+ activerecord (>= 5.a)
85
+ database_cleaner-core (~> 2.0.0)
86
+ database_cleaner-core (2.0.1)
87
+ diff-lcs (1.4.4)
88
+ erubi (1.10.0)
89
+ factory_bot (6.2.0)
90
+ activesupport (>= 5.0.0)
91
+ ffi (1.15.4)
92
+ globalid (0.5.2)
93
+ activesupport (>= 5.0)
94
+ i18n (1.8.11)
95
+ concurrent-ruby (~> 1.0)
96
+ jaro_winkler (1.5.4)
97
+ listen (3.7.0)
98
+ rb-fsevent (~> 0.10, >= 0.10.3)
99
+ rb-inotify (~> 0.9, >= 0.9.10)
100
+ loofah (2.12.0)
101
+ crass (~> 1.0.2)
102
+ nokogiri (>= 1.5.9)
103
+ mail (2.7.1)
104
+ mini_mime (>= 0.1.1)
105
+ marcel (1.0.2)
106
+ method_source (1.0.0)
107
+ mini_mime (1.1.2)
108
+ minitest (5.14.4)
109
+ msgpack (1.4.2)
110
+ nio4r (2.5.8)
111
+ nokogiri (1.12.5-x86_64-linux)
112
+ racc (~> 1.4)
113
+ parallel (1.21.0)
114
+ parser (3.0.2.0)
115
+ ast (~> 2.4.1)
116
+ pg (1.2.3)
117
+ pry (0.14.1)
118
+ coderay (~> 1.1)
119
+ method_source (~> 1.0)
120
+ racc (1.6.0)
121
+ rack (2.2.3)
122
+ rack-test (1.1.0)
123
+ rack (>= 1.0, < 3)
124
+ rails (6.1.4.1)
125
+ actioncable (= 6.1.4.1)
126
+ actionmailbox (= 6.1.4.1)
127
+ actionmailer (= 6.1.4.1)
128
+ actionpack (= 6.1.4.1)
129
+ actiontext (= 6.1.4.1)
130
+ actionview (= 6.1.4.1)
131
+ activejob (= 6.1.4.1)
132
+ activemodel (= 6.1.4.1)
133
+ activerecord (= 6.1.4.1)
134
+ activestorage (= 6.1.4.1)
135
+ activesupport (= 6.1.4.1)
136
+ bundler (>= 1.15.0)
137
+ railties (= 6.1.4.1)
138
+ sprockets-rails (>= 2.0.0)
139
+ rails-dom-testing (2.0.3)
140
+ activesupport (>= 4.2.0)
141
+ nokogiri (>= 1.6)
142
+ rails-html-sanitizer (1.4.2)
143
+ loofah (~> 2.3)
144
+ railties (6.1.4.1)
145
+ actionpack (= 6.1.4.1)
146
+ activesupport (= 6.1.4.1)
147
+ method_source
148
+ rake (>= 0.13)
149
+ thor (~> 1.0)
150
+ rainbow (3.0.0)
151
+ rake (13.0.6)
152
+ rb-fsevent (0.11.0)
153
+ rb-inotify (0.10.1)
154
+ ffi (~> 1.0)
155
+ rspec-core (3.10.1)
156
+ rspec-support (~> 3.10.0)
157
+ rspec-expectations (3.10.1)
158
+ diff-lcs (>= 1.2.0, < 2.0)
159
+ rspec-support (~> 3.10.0)
160
+ rspec-mocks (3.10.2)
161
+ diff-lcs (>= 1.2.0, < 2.0)
162
+ rspec-support (~> 3.10.0)
163
+ rspec-rails (5.0.2)
164
+ actionpack (>= 5.2)
165
+ activesupport (>= 5.2)
166
+ railties (>= 5.2)
167
+ rspec-core (~> 3.10)
168
+ rspec-expectations (~> 3.10)
169
+ rspec-mocks (~> 3.10)
170
+ rspec-support (~> 3.10)
171
+ rspec-support (3.10.3)
172
+ rubocop (0.75.1)
173
+ jaro_winkler (~> 1.5.1)
174
+ parallel (~> 1.10)
175
+ parser (>= 2.6)
176
+ rainbow (>= 2.2.2, < 4.0)
177
+ ruby-progressbar (~> 1.7)
178
+ unicode-display_width (>= 1.4.0, < 1.7)
179
+ rubocop-rspec (1.41.0)
180
+ rubocop (>= 0.68.1)
181
+ ruby-progressbar (1.11.0)
182
+ sprockets (4.0.2)
183
+ concurrent-ruby (~> 1.0)
184
+ rack (> 1, < 3)
185
+ sprockets-rails (3.2.2)
186
+ actionpack (>= 4.0)
187
+ activesupport (>= 4.0)
188
+ sprockets (>= 3.0.0)
189
+ thor (1.1.0)
190
+ tzinfo (2.0.4)
191
+ concurrent-ruby (~> 1.0)
192
+ tzinfo-data (1.2021.5)
193
+ tzinfo (>= 1.0.0)
194
+ unicode-display_width (1.6.1)
195
+ websocket-driver (0.7.5)
196
+ websocket-extensions (>= 0.1.0)
197
+ websocket-extensions (0.1.5)
198
+ zeitwerk (2.5.1)
199
+
200
+ PLATFORMS
201
+ x86_64-linux
202
+
203
+ DEPENDENCIES
204
+ brakeman
205
+ byebug
206
+ database_cleaner-active_record
207
+ factory_bot
208
+ listen
209
+ rspec-rails
210
+ rubocop (~> 0.75.1)
211
+ rubocop-rspec
212
+ travis-backup-for-v3!
213
+
214
+ BUNDLED WITH
215
+ 2.3.10
data/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # README
2
+
3
+ *travis-backup-for-v3* is an application that helps with housekeeping and backup for Travis CI database v3.0. It removes requests and builds with their dependencies, as long as they are older than given threshold says.
4
+
5
+ ### Installation and run
6
+
7
+ You can install the gem using
8
+
9
+ `gem install travis-backup-for-v3`
10
+
11
+ Next you can run it like:
12
+
13
+ ```
14
+ travis_backup_for_v3 'postgres://user:pass@localhost:5432/my_db' --threshold 6
15
+ ```
16
+
17
+ All arguments:
18
+
19
+ ```
20
+ first argument, no flag # database url
21
+ -b, --backup # when not present, removes data without saving it to file
22
+ -d, --dry_run # only prints in console what data will be backuped and deleted
23
+ -l, --limit LIMIT # builds limit for one backup file
24
+ -t, --threshold MONTHS # number of months from now - data younger than this time won't be backuped
25
+ -f, --files_location PATH # path of the folder in which backup files will be placed
26
+ -u, --user_id ID # run only for given user
27
+ -o, --org_id ID # run only for given organization
28
+ -r, --repo_id ID # run only for given repository
29
+ ```
30
+
31
+ Or inside your app:
32
+
33
+ ```
34
+ require 'travis-backup'
35
+
36
+ backup = Backup.new(
37
+ if_backup: true,
38
+ limit: 500,
39
+ threshold: 12,
40
+ files_location: './my_folder/dump',
41
+ database_url: 'postgresql://postgres:pass@localhost:5432/my_db'
42
+ )
43
+ backup.run
44
+ ```
45
+
46
+ You can also run backup only for given user, organisation or repository:
47
+
48
+ ```
49
+ backup.run(user_id: 1)
50
+ # or
51
+ backup.run(org_id: 1)
52
+ # or
53
+ backup.run(repo_id: 1)
54
+ ```
55
+
56
+ #### Special modes
57
+
58
+ Using `--dry_run` flag you can check which data would be removed by gem, but without removing them actually. Instead of that reports will be printed on standard output. This flag can be also combined with special modes.
59
+
60
+ ### Configuration options
61
+
62
+ Despite of command line arguments, one of the ways you can configure your export is a file `config/settings.yml` that you can place in your app's main directory. The gem expects properties in the following format:
63
+
64
+ ```
65
+ backup:
66
+ if_backup: true # when false, removes data without saving it to file
67
+ dry_run: false # when true, only prints in console what data should be backuped and deleted
68
+ limit: 1000 # builds limit for one backup file
69
+ threshold: 6 # number of months from now - data younger than this time won't be backuped
70
+ files_location: './dump' # path of the folder in which backup files will be placed
71
+ user_id: 1 # run only for given user
72
+ org_id: 1 # run only for given organization
73
+ repo_id: 1 # run only for given repository
74
+ ```
75
+
76
+ You can also set these properties using env vars corresponding to them: `IF_BACKUP`, `BACKUP_DRY_RUN`, `BACKUP_LIMIT`, `BACKUP_THRESHOLD`, `BACKUP_FILES_LOCATION`, `BACKUP_USER_ID`, `BACKUP_ORG_ID`, `BACKUP_REPO_ID`.
77
+
78
+ You should also specify your database url. You can do this the standard way in `config/database.yml` file, setting the `database_url` hash argument while creating `Backup` instance or using the `DATABASE_URL` env var. Your database should be consistent with the Travis 3.0 database schema.
79
+
80
+ ### How to run the test suite
81
+
82
+ You can run the test after cloning this repository. Next you should call
83
+
84
+ ```
85
+ bundle install
86
+ ```
87
+
88
+ and
89
+
90
+ ```
91
+ bundle exec rspec
92
+ ```
93
+
94
+ To make tests working properly you should also ensure database connection string for empty test database. You can set it as `DATABASE_URL` environment variable or in `config/database.yml`.
95
+
96
+ **Warning: this database will be cleaned during tests, so ensure that it includes no important data.**
97
+
98
+ ### Ruby version
99
+
100
+ 2.7.2
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ namespace :backup do
2
+ desc 'Backup all daily outdated build/job'
3
+ task :cron do
4
+ $: << 'lib'
5
+ require 'travis-backup'
6
+
7
+ Backup.new.run
8
+ end
9
+ end
10
+
11
+ namespace :spec do
12
+ desc 'Run all specs'
13
+ task :all do
14
+ sh 'bundle exec rspec spec'
15
+ end
16
+ end
17
+
18
+ task :default => :'backup:cron'
data/bin/bundle ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
data/bin/console ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << 'lib'
4
+
5
+ require 'pry'
6
+ require 'backup'
7
+
8
+ Pry.start
data/bin/rails ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ load File.expand_path("spring", __dir__)
3
+ APP_PATH = File.expand_path('../config/application', __dir__)
4
+ require_relative "../config/boot"
5
+ require "rails/commands"
data/bin/rake ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.expand_path('spring', __dir__)
4
+ require_relative '../config/boot'
5
+ require 'rake'
6
+
7
+ Rake.application.run
data/bin/setup ADDED
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path('..', __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # Install JavaScript dependencies
21
+ system! 'bin/yarn'
22
+
23
+ # puts "\n== Copying sample files =="
24
+ # unless File.exist?('config/database.yml')
25
+ # FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
26
+ # end
27
+
28
+ puts "\n== Preparing database =="
29
+ system! 'bin/rails db:prepare'
30
+
31
+ puts "\n== Removing old logs and tempfiles =="
32
+ system! 'bin/rails log:clear tmp:clear'
33
+
34
+ puts "\n== Restarting application server =="
35
+ system! 'bin/rails restart'
36
+ end
data/bin/spring ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
3
+ gem "bundler"
4
+ require "bundler"
5
+
6
+ # Load Spring without loading other gems in the Gemfile, for speed.
7
+ Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring|
8
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
9
+ gem "spring", spring.version
10
+ require "spring/binstub"
11
+ rescue Gem::LoadError
12
+ # Ignore when Spring is not installed.
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << 'lib'
4
+
5
+ require 'travis-backup'
6
+
7
+ Backup.new.run
data/bin/yarn ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
+ yarn = ENV["PATH"].split(File::PATH_SEPARATOR).
5
+ select { |dir| File.expand_path(dir) != __dir__ }.
6
+ product(["yarn", "yarn.exe"]).
7
+ map { |dir, file| File.expand_path(file, dir) }.
8
+ find { |file| File.executable?(file) }
9
+
10
+ if yarn
11
+ exec yarn, *ARGV
12
+ else
13
+ $stderr.puts "Yarn executable was not detected in the system."
14
+ $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
15
+ exit 1
16
+ end
17
+ end
@@ -0,0 +1,22 @@
1
+ require_relative "boot"
2
+
3
+ require "rails/all"
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module TravisBackup
10
+ class Application < Rails::Application
11
+ # Initialize configuration defaults for originally generated Rails version.
12
+ config.load_defaults 6.1
13
+
14
+ # Configuration for the application, engines, and railties goes here.
15
+ #
16
+ # These settings can be overridden in specific environments using the files
17
+ # in config/environments, which are processed later.
18
+ #
19
+ # config.time_zone = "Central Time (US & Canada)"
20
+ # config.eager_load_paths << Rails.root.join("extras")
21
+ end
22
+ end
data/config/boot.rb ADDED
@@ -0,0 +1,4 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
data/config/cable.yml ADDED
@@ -0,0 +1,10 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: test
6
+
7
+ production:
8
+ adapter: redis
9
+ url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
10
+ channel_prefix: travis_backup_production
@@ -0,0 +1 @@
1
+ 24dfgnJ9aVvwjfMuInl76lpfL4Z8BT8rkBPsDsfIJblJmFrn86bwzS5HEAlzMK4CCPnNgWzpufrzIHHZf4yiX8P3Dr1TAh8z4+eZARLyqrGiLVFpLaXdc0dooKUDWmZdrNRaEwqcp8+rJlHgzXOiy1YqI4d4suM+NiQSM7JH2vH/niFvUv1ZHq1RzRdWX7szSvAYJfjsob0pqCYCbygi+HTKGKORlfBPdr4wLAIUa4E6QyHeoCrSjtPluM03bY5/buWYobBg4OvQj+cKwy2IQuoeAI3qwbhgMbEdREDLjPsucUHxlGe3RnDHio5kWxbtx+WSLOINvIZPXHDfJkd4PGGtFRQEg3nLkJFheYWq4QP1B1x/7QeOBjesNiUoVR9URUTMC9l8ncLCd1/C2fWDOHVunfDaoCMQHeqd--KWXndRYrcgkATOo8--TN86MzhWrQZ5yUPomGzDSg==
@@ -0,0 +1,23 @@
1
+ default: &default
2
+ adapter: postgresql
3
+ encoding: unicode
4
+ pool: 5
5
+ min_messages: warning
6
+ url: 'postgresql://localhost/travis_production'
7
+ eager_load: true
8
+
9
+ production:
10
+ <<: *default
11
+
12
+ development:
13
+ <<: *default
14
+ url: 'postgresql://localhost/travis_development'
15
+ eager_load: false
16
+
17
+ test:
18
+ <<: *default
19
+ url: 'postgresql://localhost/travis_test'
20
+ eager_load: false
21
+ destination:
22
+ url: 'postgresql://localhost/travis_test_destination'
23
+ eager_load: false
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!