activerecord-spanner-adapter 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. checksums.yaml +5 -5
  2. data/.github/CODEOWNERS +7 -0
  3. data/.github/sync-repo-settings.yaml +16 -0
  4. data/.github/workflows/acceptance-tests-on-emulator.yaml +45 -0
  5. data/.github/workflows/acceptance-tests-on-production.yaml +36 -0
  6. data/.github/workflows/ci.yaml +33 -0
  7. data/.github/workflows/nightly-acceptance-tests-on-emulator.yaml +52 -0
  8. data/.github/workflows/nightly-acceptance-tests-on-production.yaml +35 -0
  9. data/.github/workflows/nightly-unit-tests.yaml +40 -0
  10. data/.github/workflows/release-please-label.yml +25 -0
  11. data/.github/workflows/release-please.yml +39 -0
  12. data/.github/workflows/rubocop.yaml +31 -0
  13. data/.gitignore +67 -5
  14. data/.kokoro/populate-secrets.sh +77 -0
  15. data/.kokoro/release.cfg +33 -0
  16. data/.kokoro/release.sh +15 -0
  17. data/.kokoro/trampoline_v2.sh +489 -0
  18. data/.rubocop.yml +46 -0
  19. data/.toys/release.rb +18 -0
  20. data/.trampolinerc +48 -0
  21. data/.yardopts +11 -0
  22. data/CHANGELOG.md +26 -0
  23. data/CODE_OF_CONDUCT.md +40 -0
  24. data/CONTRIBUTING.md +79 -0
  25. data/Gemfile +9 -4
  26. data/LICENSE +6 -6
  27. data/README.md +67 -30
  28. data/Rakefile +79 -3
  29. data/SECURITY.md +7 -0
  30. data/acceptance/cases/associations/has_many_associations_test.rb +119 -0
  31. data/acceptance/cases/associations/has_many_through_associations_test.rb +63 -0
  32. data/acceptance/cases/associations/has_one_associations_test.rb +79 -0
  33. data/acceptance/cases/associations/has_one_through_associations_test.rb +98 -0
  34. data/acceptance/cases/interleaved_associations/has_many_associations_using_interleaved_test.rb +211 -0
  35. data/acceptance/cases/migration/change_schema_test.rb +433 -0
  36. data/acceptance/cases/migration/change_table_test.rb +115 -0
  37. data/acceptance/cases/migration/column_attributes_test.rb +122 -0
  38. data/acceptance/cases/migration/column_positioning_test.rb +48 -0
  39. data/acceptance/cases/migration/columns_test.rb +201 -0
  40. data/acceptance/cases/migration/command_recorder_test.rb +406 -0
  41. data/acceptance/cases/migration/create_join_table_test.rb +216 -0
  42. data/acceptance/cases/migration/ddl_batching_test.rb +80 -0
  43. data/acceptance/cases/migration/foreign_key_test.rb +297 -0
  44. data/acceptance/cases/migration/index_test.rb +211 -0
  45. data/acceptance/cases/migration/references_foreign_key_test.rb +259 -0
  46. data/acceptance/cases/migration/references_index_test.rb +135 -0
  47. data/acceptance/cases/migration/references_statements_test.rb +166 -0
  48. data/acceptance/cases/migration/rename_column_test.rb +96 -0
  49. data/acceptance/cases/models/calculation_query_test.rb +128 -0
  50. data/acceptance/cases/models/generated_column_test.rb +126 -0
  51. data/acceptance/cases/models/mutation_test.rb +122 -0
  52. data/acceptance/cases/models/query_test.rb +147 -0
  53. data/acceptance/cases/sessions/session_not_found_test.rb +121 -0
  54. data/acceptance/cases/transactions/optimistic_locking_test.rb +141 -0
  55. data/acceptance/cases/transactions/read_only_transactions_test.rb +67 -0
  56. data/acceptance/cases/transactions/read_write_transactions_test.rb +248 -0
  57. data/acceptance/cases/type/all_types_test.rb +152 -0
  58. data/acceptance/cases/type/binary_test.rb +59 -0
  59. data/acceptance/cases/type/boolean_test.rb +31 -0
  60. data/acceptance/cases/type/date_test.rb +32 -0
  61. data/acceptance/cases/type/date_time_test.rb +30 -0
  62. data/acceptance/cases/type/float_test.rb +27 -0
  63. data/acceptance/cases/type/integer_test.rb +44 -0
  64. data/acceptance/cases/type/numeric_test.rb +27 -0
  65. data/acceptance/cases/type/string_test.rb +79 -0
  66. data/acceptance/cases/type/text_test.rb +30 -0
  67. data/acceptance/cases/type/time_test.rb +87 -0
  68. data/acceptance/models/account.rb +13 -0
  69. data/acceptance/models/address.rb +9 -0
  70. data/acceptance/models/album.rb +12 -0
  71. data/acceptance/models/all_types.rb +8 -0
  72. data/acceptance/models/author.rb +11 -0
  73. data/acceptance/models/club.rb +12 -0
  74. data/acceptance/models/comment.rb +9 -0
  75. data/acceptance/models/customer.rb +9 -0
  76. data/acceptance/models/department.rb +9 -0
  77. data/acceptance/models/firm.rb +10 -0
  78. data/acceptance/models/member.rb +13 -0
  79. data/acceptance/models/member_type.rb +9 -0
  80. data/acceptance/models/membership.rb +10 -0
  81. data/acceptance/models/organization.rb +9 -0
  82. data/acceptance/models/post.rb +10 -0
  83. data/acceptance/models/singer.rb +10 -0
  84. data/acceptance/models/track.rb +20 -0
  85. data/acceptance/models/transaction.rb +9 -0
  86. data/acceptance/schema/schema.rb +143 -0
  87. data/acceptance/test_helper.rb +260 -0
  88. data/activerecord-spanner-adapter.gemspec +32 -17
  89. data/assets/solidus-db.png +0 -0
  90. data/benchmarks/README.md +17 -0
  91. data/benchmarks/Rakefile +14 -0
  92. data/benchmarks/application.rb +308 -0
  93. data/benchmarks/config/database.yml +8 -0
  94. data/benchmarks/config/environment.rb +12 -0
  95. data/benchmarks/db/migrate/01_create_tables.rb +25 -0
  96. data/benchmarks/db/schema.rb +29 -0
  97. data/benchmarks/models/album.rb +9 -0
  98. data/benchmarks/models/singer.rb +9 -0
  99. data/bin/console +6 -7
  100. data/examples/rails/README.md +262 -0
  101. data/examples/snippets/README.md +29 -0
  102. data/examples/snippets/Rakefile +57 -0
  103. data/examples/snippets/array-data-type/README.md +45 -0
  104. data/examples/snippets/array-data-type/Rakefile +13 -0
  105. data/examples/snippets/array-data-type/application.rb +45 -0
  106. data/examples/snippets/array-data-type/config/database.yml +8 -0
  107. data/examples/snippets/array-data-type/db/migrate/01_create_tables.rb +24 -0
  108. data/examples/snippets/array-data-type/db/schema.rb +26 -0
  109. data/examples/snippets/array-data-type/db/seeds.rb +5 -0
  110. data/examples/snippets/array-data-type/models/entity_with_array_types.rb +18 -0
  111. data/examples/snippets/bin/create_emulator_instance.rb +18 -0
  112. data/examples/snippets/bulk-insert/README.md +21 -0
  113. data/examples/snippets/bulk-insert/Rakefile +13 -0
  114. data/examples/snippets/bulk-insert/application.rb +64 -0
  115. data/examples/snippets/bulk-insert/config/database.yml +8 -0
  116. data/examples/snippets/bulk-insert/db/migrate/01_create_tables.rb +21 -0
  117. data/examples/snippets/bulk-insert/db/schema.rb +26 -0
  118. data/examples/snippets/bulk-insert/db/seeds.rb +5 -0
  119. data/examples/snippets/bulk-insert/models/album.rb +9 -0
  120. data/examples/snippets/bulk-insert/models/singer.rb +9 -0
  121. data/examples/snippets/commit-timestamp/README.md +18 -0
  122. data/examples/snippets/commit-timestamp/Rakefile +13 -0
  123. data/examples/snippets/commit-timestamp/application.rb +53 -0
  124. data/examples/snippets/commit-timestamp/config/database.yml +8 -0
  125. data/examples/snippets/commit-timestamp/db/migrate/01_create_tables.rb +26 -0
  126. data/examples/snippets/commit-timestamp/db/schema.rb +29 -0
  127. data/examples/snippets/commit-timestamp/db/seeds.rb +5 -0
  128. data/examples/snippets/commit-timestamp/models/album.rb +9 -0
  129. data/examples/snippets/commit-timestamp/models/singer.rb +9 -0
  130. data/examples/snippets/config/environment.rb +21 -0
  131. data/examples/snippets/create-records/README.md +12 -0
  132. data/examples/snippets/create-records/Rakefile +13 -0
  133. data/examples/snippets/create-records/application.rb +42 -0
  134. data/examples/snippets/create-records/config/database.yml +8 -0
  135. data/examples/snippets/create-records/db/migrate/01_create_tables.rb +21 -0
  136. data/examples/snippets/create-records/db/schema.rb +26 -0
  137. data/examples/snippets/create-records/db/seeds.rb +5 -0
  138. data/examples/snippets/create-records/models/album.rb +9 -0
  139. data/examples/snippets/create-records/models/singer.rb +9 -0
  140. data/examples/snippets/date-data-type/README.md +19 -0
  141. data/examples/snippets/date-data-type/Rakefile +13 -0
  142. data/examples/snippets/date-data-type/application.rb +35 -0
  143. data/examples/snippets/date-data-type/config/database.yml +8 -0
  144. data/examples/snippets/date-data-type/db/migrate/01_create_tables.rb +20 -0
  145. data/examples/snippets/date-data-type/db/schema.rb +21 -0
  146. data/examples/snippets/date-data-type/db/seeds.rb +16 -0
  147. data/examples/snippets/date-data-type/models/singer.rb +8 -0
  148. data/examples/snippets/generated-column/README.md +41 -0
  149. data/examples/snippets/generated-column/Rakefile +13 -0
  150. data/examples/snippets/generated-column/application.rb +37 -0
  151. data/examples/snippets/generated-column/config/database.yml +8 -0
  152. data/examples/snippets/generated-column/db/migrate/01_create_tables.rb +23 -0
  153. data/examples/snippets/generated-column/db/schema.rb +21 -0
  154. data/examples/snippets/generated-column/db/seeds.rb +18 -0
  155. data/examples/snippets/generated-column/models/singer.rb +8 -0
  156. data/examples/snippets/interleaved-tables/README.md +152 -0
  157. data/examples/snippets/interleaved-tables/Rakefile +13 -0
  158. data/examples/snippets/interleaved-tables/application.rb +109 -0
  159. data/examples/snippets/interleaved-tables/config/database.yml +8 -0
  160. data/examples/snippets/interleaved-tables/db/migrate/01_create_tables.rb +44 -0
  161. data/examples/snippets/interleaved-tables/db/schema.rb +32 -0
  162. data/examples/snippets/interleaved-tables/db/seeds.rb +40 -0
  163. data/examples/snippets/interleaved-tables/models/album.rb +15 -0
  164. data/examples/snippets/interleaved-tables/models/singer.rb +20 -0
  165. data/examples/snippets/interleaved-tables/models/track.rb +25 -0
  166. data/examples/snippets/migrations/README.md +43 -0
  167. data/examples/snippets/migrations/Rakefile +13 -0
  168. data/examples/snippets/migrations/application.rb +26 -0
  169. data/examples/snippets/migrations/config/database.yml +8 -0
  170. data/examples/snippets/migrations/db/migrate/01_create_tables.rb +28 -0
  171. data/examples/snippets/migrations/db/schema.rb +33 -0
  172. data/examples/snippets/migrations/db/seeds.rb +5 -0
  173. data/examples/snippets/migrations/models/album.rb +10 -0
  174. data/examples/snippets/migrations/models/singer.rb +10 -0
  175. data/examples/snippets/migrations/models/track.rb +9 -0
  176. data/examples/snippets/mutations/README.md +34 -0
  177. data/examples/snippets/mutations/Rakefile +13 -0
  178. data/examples/snippets/mutations/application.rb +47 -0
  179. data/examples/snippets/mutations/config/database.yml +8 -0
  180. data/examples/snippets/mutations/db/migrate/01_create_tables.rb +22 -0
  181. data/examples/snippets/mutations/db/schema.rb +27 -0
  182. data/examples/snippets/mutations/db/seeds.rb +25 -0
  183. data/examples/snippets/mutations/models/album.rb +9 -0
  184. data/examples/snippets/mutations/models/singer.rb +9 -0
  185. data/examples/snippets/optimistic-locking/README.md +12 -0
  186. data/examples/snippets/optimistic-locking/Rakefile +13 -0
  187. data/examples/snippets/optimistic-locking/application.rb +48 -0
  188. data/examples/snippets/optimistic-locking/config/database.yml +8 -0
  189. data/examples/snippets/optimistic-locking/db/migrate/01_create_tables.rb +26 -0
  190. data/examples/snippets/optimistic-locking/db/schema.rb +29 -0
  191. data/examples/snippets/optimistic-locking/db/seeds.rb +25 -0
  192. data/examples/snippets/optimistic-locking/models/album.rb +9 -0
  193. data/examples/snippets/optimistic-locking/models/singer.rb +9 -0
  194. data/examples/snippets/quickstart/README.md +26 -0
  195. data/examples/snippets/quickstart/Rakefile +13 -0
  196. data/examples/snippets/quickstart/application.rb +51 -0
  197. data/examples/snippets/quickstart/config/database.yml +8 -0
  198. data/examples/snippets/quickstart/db/migrate/01_create_tables.rb +21 -0
  199. data/examples/snippets/quickstart/db/schema.rb +26 -0
  200. data/examples/snippets/quickstart/db/seeds.rb +24 -0
  201. data/examples/snippets/quickstart/models/album.rb +9 -0
  202. data/examples/snippets/quickstart/models/singer.rb +9 -0
  203. data/examples/snippets/read-only-transactions/README.md +13 -0
  204. data/examples/snippets/read-only-transactions/Rakefile +13 -0
  205. data/examples/snippets/read-only-transactions/application.rb +49 -0
  206. data/examples/snippets/read-only-transactions/config/database.yml +8 -0
  207. data/examples/snippets/read-only-transactions/db/migrate/01_create_tables.rb +21 -0
  208. data/examples/snippets/read-only-transactions/db/schema.rb +26 -0
  209. data/examples/snippets/read-only-transactions/db/seeds.rb +24 -0
  210. data/examples/snippets/read-only-transactions/models/album.rb +9 -0
  211. data/examples/snippets/read-only-transactions/models/singer.rb +9 -0
  212. data/examples/snippets/read-write-transactions/README.md +12 -0
  213. data/examples/snippets/read-write-transactions/Rakefile +13 -0
  214. data/examples/snippets/read-write-transactions/application.rb +39 -0
  215. data/examples/snippets/read-write-transactions/config/database.yml +8 -0
  216. data/examples/snippets/read-write-transactions/db/migrate/01_create_tables.rb +22 -0
  217. data/examples/snippets/read-write-transactions/db/schema.rb +27 -0
  218. data/examples/snippets/read-write-transactions/db/seeds.rb +25 -0
  219. data/examples/snippets/read-write-transactions/models/album.rb +9 -0
  220. data/examples/snippets/read-write-transactions/models/singer.rb +9 -0
  221. data/examples/snippets/timestamp-data-type/README.md +17 -0
  222. data/examples/snippets/timestamp-data-type/Rakefile +13 -0
  223. data/examples/snippets/timestamp-data-type/application.rb +42 -0
  224. data/examples/snippets/timestamp-data-type/config/database.yml +8 -0
  225. data/examples/snippets/timestamp-data-type/db/migrate/01_create_tables.rb +21 -0
  226. data/examples/snippets/timestamp-data-type/db/schema.rb +21 -0
  227. data/examples/snippets/timestamp-data-type/db/seeds.rb +6 -0
  228. data/examples/snippets/timestamp-data-type/models/meeting.rb +19 -0
  229. data/examples/solidus/README.md +172 -0
  230. data/lib/active_record/connection_adapters/spanner/database_statements.rb +224 -269
  231. data/lib/active_record/connection_adapters/spanner/quoting.rb +42 -50
  232. data/lib/active_record/connection_adapters/spanner/schema_cache.rb +43 -0
  233. data/lib/active_record/connection_adapters/spanner/schema_creation.rb +125 -9
  234. data/lib/active_record/connection_adapters/spanner/schema_definitions.rb +122 -0
  235. data/lib/active_record/connection_adapters/spanner/schema_dumper.rb +19 -0
  236. data/lib/active_record/connection_adapters/spanner/schema_statements.rb +553 -139
  237. data/lib/active_record/connection_adapters/spanner/type_metadata.rb +37 -0
  238. data/lib/active_record/connection_adapters/spanner_adapter.rb +182 -78
  239. data/lib/active_record/tasks/spanner_database_tasks.rb +74 -0
  240. data/lib/active_record/type/spanner/array.rb +32 -0
  241. data/lib/active_record/type/spanner/bytes.rb +26 -0
  242. data/lib/active_record/type/spanner/spanner_active_record_converter.rb +32 -0
  243. data/lib/active_record/type/spanner/time.rb +37 -0
  244. data/lib/activerecord-spanner-adapter.rb +23 -0
  245. data/lib/activerecord_spanner_adapter/base.rb +217 -0
  246. data/lib/activerecord_spanner_adapter/connection.rb +324 -0
  247. data/lib/activerecord_spanner_adapter/errors.rb +13 -0
  248. data/lib/activerecord_spanner_adapter/foreign_key.rb +29 -0
  249. data/lib/activerecord_spanner_adapter/index/column.rb +38 -0
  250. data/lib/activerecord_spanner_adapter/index.rb +80 -0
  251. data/lib/activerecord_spanner_adapter/information_schema.rb +261 -0
  252. data/lib/activerecord_spanner_adapter/primary_key.rb +31 -0
  253. data/lib/activerecord_spanner_adapter/table/column.rb +59 -0
  254. data/lib/activerecord_spanner_adapter/table.rb +61 -0
  255. data/lib/activerecord_spanner_adapter/transaction.rb +113 -0
  256. data/lib/activerecord_spanner_adapter/version.rb +9 -0
  257. data/lib/arel/visitors/spanner.rb +35 -0
  258. data/lib/spanner_client_ext.rb +82 -0
  259. data/renovate.json +5 -0
  260. metadata +387 -34
  261. data/.travis.yml +0 -5
  262. data/lib/active_record/connection_adapters/spanner/client.rb +0 -190
  263. data/lib/active_record/connection_adapters/spanner.rb +0 -10
  264. data/lib/activerecord-spanner-adapter/version.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 98b65b0b5292ed6027d2dd1305a9794565438374
4
- data.tar.gz: ff0fc0355000390592dd1c916d8eaedfdb4c24e9
2
+ SHA256:
3
+ metadata.gz: 3761fdcb057da7fcec3150ec38e865bdb61d50eff368634146eefff6fb2bea27
4
+ data.tar.gz: cebbacfbbce4943f0d4cc799dfa2abc6deb352c2069059e6aac869293063eb6c
5
5
  SHA512:
6
- metadata.gz: 25ec93d1aa400524c5feb62efbb0bf1dce21468fdee84c5ba8d701cdeedd55b91880ff27880e46c6a19f5bd6d5791d289458a623a675d1089b1c99e1b892b92c
7
- data.tar.gz: 83cd0c3ecec42157a2f0675c1c77900045c74dee42ba83a44474ce966e0dab83b1b5f8fbfb57a8d9eab60b0bf8ebdac3d1177ba4a81faf2734ebb9e62c20142d
6
+ metadata.gz: 6aeefe0da3b1c627a2e5319b84f7d1519630421d773420197810b3e619e3f766e02ccd67cc89e9daf7ddee14985eb7aec371d1a685a5ff27004a57864f5e7ef4
7
+ data.tar.gz: 0c807717d9d42ee7624a4e0710626718a89f0a51a2e3c968001f3d01587dd13448ac57c5569af3d82d417305bfa63f46cb932cae8d007735f68fde080d4e119e
@@ -0,0 +1,7 @@
1
+ # Code owners file.
2
+ # This file controls who is tagged for review for any given pull request.
3
+ #
4
+ # For syntax help see:
5
+ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
6
+
7
+ * @jiren @skuruppu @dazuma @hengfengli @olavloite @xiangshen-dk
@@ -0,0 +1,16 @@
1
+ rebaseMergeAllowed: true
2
+ squashMergeAllowed: true
3
+ mergeCommitAllowed: false
4
+ branchProtectionRules:
5
+ - pattern: master
6
+ isAdminEnforced: true
7
+ requiredStatusCheckContexts:
8
+ - 'cla/google'
9
+ requiredApprovingReviewCount: 1
10
+ requiresCodeOwnerReviews: true
11
+ requiresStrictStatusChecks: true
12
+ permissionRules:
13
+ - team: yoshi-ruby
14
+ permission: push
15
+ - team: yoshi-ruby-admins
16
+ permission: admin
@@ -0,0 +1,45 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - master
5
+ pull_request:
6
+ name: acceptance tests on emulator
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+
11
+ services:
12
+ emulator:
13
+ image: gcr.io/cloud-spanner-emulator/emulator:latest
14
+ ports:
15
+ - 9010:9010
16
+ - 9020:9020
17
+
18
+ strategy:
19
+ max-parallel: 4
20
+ matrix:
21
+ ruby: [2.6, 2.7, 3.0]
22
+ ar: [6.0.4, 6.1.4]
23
+ # Exclude Ruby 3.0 and ActiveRecord 6.0.x as that combination is not supported.
24
+ exclude:
25
+ - ruby: 3.0
26
+ ar: 6.0.4
27
+ steps:
28
+ - uses: actions/checkout@v2
29
+ - name: Set up Ruby
30
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
31
+ # (see https://github.com/ruby/setup-ruby#versioning):
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ bundler-cache: false
35
+ ruby-version: ${{ matrix.ruby }}
36
+ - name: Set ActiveRecord version
37
+ run: sed -i "s/\"activerecord\", \"~> 6.1.4\"/\"activerecord\", \"${{ matrix.ar }}\"/" activerecord-spanner-adapter.gemspec
38
+ - name: Install dependencies
39
+ run: bundle install
40
+ - name: Run acceptance tests on emulator
41
+ run: bundle exec rake acceptance
42
+ env:
43
+ SPANNER_EMULATOR_HOST: localhost:9010
44
+ SPANNER_TEST_PROJECT: test-project
45
+ SPANNER_TEST_INSTANCE: test-instance
@@ -0,0 +1,36 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - master
5
+ pull_request:
6
+ name: acceptance tests on production
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+
11
+ strategy:
12
+ max-parallel: 4
13
+ matrix:
14
+ ruby: [3.0]
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby
18
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
19
+ # (see https://github.com/ruby/setup-ruby#versioning):
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ bundler-cache: true
23
+ ruby-version: ${{ matrix.ruby }}
24
+ - name: Setup GCloud
25
+ uses: google-github-actions/setup-gcloud@master
26
+ with:
27
+ project_id: ${{ secrets.GCP_PROJECT_ID }}
28
+ service_account_key: ${{ secrets.GCP_SA_KEY }}
29
+ export_default_credentials: true
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run acceptance tests on production
33
+ run: bundle exec rake acceptance\[,,,"exclude cases/migration"\]
34
+ env:
35
+ SPANNER_TEST_PROJECT: ${{ secrets.GCP_PROJECT_ID }}
36
+ SPANNER_TEST_INSTANCE: ruby-activerecord-test
@@ -0,0 +1,33 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - master
5
+ pull_request:
6
+ name: ci
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ max-parallel: 4
12
+ matrix:
13
+ ruby: [2.6, 2.7, 3.0]
14
+ ar: [6.0.4, 6.1.4]
15
+ # Exclude Ruby 3.0 and ActiveRecord 6.0.x as that combination is not supported.
16
+ exclude:
17
+ - ruby: 3.0
18
+ ar: 6.0.4
19
+ steps:
20
+ - uses: actions/checkout@v2
21
+ - name: Set up Ruby
22
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
23
+ # (see https://github.com/ruby/setup-ruby#versioning):
24
+ uses: ruby/setup-ruby@v1
25
+ with:
26
+ bundler-cache: false
27
+ ruby-version: ${{ matrix.ruby }}
28
+ - name: Set ActiveRecord version
29
+ run: sed -i "s/\"activerecord\", \"~> 6.1.4\"/\"activerecord\", \"${{ matrix.ar }}\"/" activerecord-spanner-adapter.gemspec
30
+ - name: Install dependencies
31
+ run: bundle install
32
+ - name: Run tests
33
+ run: bundle exec rake test
@@ -0,0 +1,52 @@
1
+ on:
2
+ schedule:
3
+ # 06:00 UTC
4
+ - cron: '0 6 * * *'
5
+ name: nightly acceptance tests on emulator
6
+ jobs:
7
+ test:
8
+ runs-on: ubuntu-latest
9
+
10
+ services:
11
+ emulator:
12
+ image: gcr.io/cloud-spanner-emulator/emulator:latest
13
+ ports:
14
+ - 9010:9010
15
+ - 9020:9020
16
+
17
+ strategy:
18
+ max-parallel: 4
19
+ matrix:
20
+ # Run acceptance tests all supported combinations of Ruby and ActiveRecord.
21
+ ruby: [2.5, 2.6, 2.7, 3.0]
22
+ ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.0, 6.1.1, 6.1.2.1, 6.1.3.2, 6.1.4]
23
+ # Exclude Ruby 3.0 and ActiveRecord 6.0.x as that combination is not supported.
24
+ exclude:
25
+ - ruby: 3.0
26
+ ar: 6.0.0
27
+ - ruby: 3.0
28
+ ar: 6.0.1
29
+ - ruby: 3.0
30
+ ar: 6.0.2.2
31
+ - ruby: 3.0
32
+ ar: 6.0.3.7
33
+ - ruby: 3.0
34
+ ar: 6.0.4
35
+ steps:
36
+ - uses: actions/checkout@v2
37
+ - name: Set up Ruby
38
+ uses: ruby/setup-ruby@v1
39
+ with:
40
+ # Disable caching as we are overriding the ActiveRecord below.
41
+ bundler-cache: false
42
+ ruby-version: ${{ matrix.ruby }}
43
+ - name: Set ActiveRecord version
44
+ run: sed -i "s/\"activerecord\", \"~> 6.1.4\"/\"activerecord\", \"${{ matrix.ar }}\"/" activerecord-spanner-adapter.gemspec
45
+ - name: Install dependencies
46
+ run: bundle install
47
+ - name: Run acceptance tests on emulator
48
+ run: bundle exec rake acceptance
49
+ env:
50
+ SPANNER_EMULATOR_HOST: localhost:9010
51
+ SPANNER_TEST_PROJECT: test-project
52
+ SPANNER_TEST_INSTANCE: test-instance
@@ -0,0 +1,35 @@
1
+ on:
2
+ schedule:
3
+ # 02:00 UTC
4
+ - cron: '0 2 * * *'
5
+ name: nightly acceptance tests on production
6
+ jobs:
7
+ test:
8
+ runs-on: ubuntu-latest
9
+
10
+ strategy:
11
+ max-parallel: 4
12
+ matrix:
13
+ ruby: [3.0]
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Set up Ruby
17
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
18
+ # (see https://github.com/ruby/setup-ruby#versioning):
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ bundler-cache: true
22
+ ruby-version: ${{ matrix.ruby }}
23
+ - name: Setup GCloud
24
+ uses: google-github-actions/setup-gcloud@master
25
+ with:
26
+ project_id: ${{ secrets.GCP_PROJECT_ID }}
27
+ service_account_key: ${{ secrets.GCP_SA_KEY }}
28
+ export_default_credentials: true
29
+ - name: Install dependencies
30
+ run: bundle install
31
+ - name: Run acceptance tests on production
32
+ run: bundle exec rake acceptance
33
+ env:
34
+ SPANNER_TEST_PROJECT: ${{ secrets.GCP_PROJECT_ID }}
35
+ SPANNER_TEST_INSTANCE: ruby-activerecord-test
@@ -0,0 +1,40 @@
1
+ on:
2
+ schedule:
3
+ # 05:30 UTC
4
+ - cron: '30 5 * * *'
5
+ name: nightly-unit-tests
6
+ jobs:
7
+ test:
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ max-parallel: 4
11
+ matrix:
12
+ # Run unit tests all supported combinations of Ruby and ActiveRecord.
13
+ ruby: [2.5, 2.6, 2.7, 3.0]
14
+ ar: [6.0.0, 6.0.1, 6.0.2.2, 6.0.3.7, 6.0.4, 6.1.0, 6.1.1, 6.1.2.1, 6.1.3.2, 6.1.4]
15
+ # Exclude Ruby 3.0 and ActiveRecord 6.0.x as that combination is not supported.
16
+ exclude:
17
+ - ruby: 3.0
18
+ ar: 6.0.0
19
+ - ruby: 3.0
20
+ ar: 6.0.1
21
+ - ruby: 3.0
22
+ ar: 6.0.2.2
23
+ - ruby: 3.0
24
+ ar: 6.0.3.7
25
+ - ruby: 3.0
26
+ ar: 6.0.4
27
+ steps:
28
+ - uses: actions/checkout@v2
29
+ - name: Set up Ruby
30
+ uses: ruby/setup-ruby@v1
31
+ with:
32
+ # Disable caching as we are overriding the ActiveRecord below.
33
+ bundler-cache: false
34
+ ruby-version: ${{ matrix.ruby }}
35
+ - name: Set ActiveRecord version
36
+ run: sed -i "s/\"activerecord\", \"~> 6.1.4\"/\"activerecord\", \"${{ matrix.ar }}\"/" activerecord-spanner-adapter.gemspec
37
+ - name: Install dependencies
38
+ run: bundle install
39
+ - name: Run tests
40
+ run: bundle exec rake test
@@ -0,0 +1,25 @@
1
+ name: release-please-label
2
+ on:
3
+ pull_request_target:
4
+ branches:
5
+ - master
6
+ types:
7
+ - opened
8
+ jobs:
9
+ release-please-label:
10
+ if: "${{ github.event.sender.login == 'yoshi-code-bot' && startsWith(github.event.pull_request.title, 'chore: release ') }}"
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: ReleaseLabel
14
+ uses: actions/github-script@v4
15
+ with:
16
+ github-token: ${{secrets.YOSHI_APPROVER_TOKEN}}
17
+ script: |
18
+ core.info('Labeling release');
19
+ await github.issues.addLabels({
20
+ owner: context.repo.owner,
21
+ repo: context.repo.repo,
22
+ issue_number: context.payload.pull_request.number,
23
+ labels: ['autorelease: pending']
24
+ });
25
+ core.info('Labeled');
@@ -0,0 +1,39 @@
1
+ name: Release-Please
2
+ on:
3
+ schedule:
4
+ - cron: '27 8 * * *'
5
+ workflow_dispatch:
6
+ inputs:
7
+ gem:
8
+ description: "Name of single gem to release. Leave blank to check all gems."
9
+ required: false
10
+ args:
11
+ description: "Extra command line arguments."
12
+ required: false
13
+
14
+ jobs:
15
+ release-please:
16
+ if: ${{ github.repository == 'googleapis/ruby-spanner-activerecord' }}
17
+ runs-on: ubuntu-latest
18
+ env:
19
+ GITHUB_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }}
20
+ RELEASE_PLEASE_DISABLE: ${{ secrets.RELEASE_PLEASE_DISABLE }}
21
+ steps:
22
+ - name: Checkout repo
23
+ uses: actions/checkout@v2
24
+ - name: Install Ruby 2.7
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: "2.7"
28
+ - name: Install NodeJS 12.x
29
+ uses: actions/setup-node@v2
30
+ with:
31
+ node-version: "12.x"
32
+ - name: Install tools
33
+ run: "gem install --no-document toys && npm install release-please"
34
+ - name: execute
35
+ run: |
36
+ toys release please -v --fork \
37
+ --github-event-name=${{ github.event_name }} \
38
+ --version-file=lib/activerecord_spanner_adapter/version.rb \
39
+ ${{ github.event.inputs.args }} -- ${{ github.event.inputs.gem }}
@@ -0,0 +1,31 @@
1
+ name: rubocop
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, synchronize]
6
+ push:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ timeout-minutes: 10
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: setup ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: '2.5'
20
+ - name: cache gems
21
+ uses: actions/cache@v1
22
+ with:
23
+ path: vendor/bundle
24
+ key: ${{ runner.os }}-rubocop-${{ hashFiles('**/Gemfile.lock') }}
25
+ restore-keys: ${{ runner.os }}-rubocop-
26
+ - name: install gems
27
+ run: |
28
+ bundle config set path vendor/bundle
29
+ bundle install --jobs 4 --retry 3
30
+ - name: exec rubocop
31
+ run: bundle exec rubocop --parallel
data/.gitignore CHANGED
@@ -1,9 +1,71 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
1
+ *.gem
2
+ *.rbc
3
+ /.config
5
4
  /coverage/
6
- /doc/
5
+ /InstalledFiles
7
6
  /pkg/
8
7
  /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
9
11
  /tmp/
12
+
13
+ # Node-related
14
+ /node_modules/
15
+ /package-lock.json
16
+
17
+ # Used by dotenv library to load environment variables.
18
+ # .env
19
+
20
+ # Ignore Byebug command history file.
21
+ .byebug_history
22
+
23
+ ## Specific to RubyMotion:
24
+ .dat*
25
+ .repl_history
26
+ build/
27
+ *.bridgesupport
28
+ build-iPhoneOS/
29
+ build-iPhoneSimulator/
30
+
31
+ ## Specific to RubyMotion (use of CocoaPods):
32
+ #
33
+ # We recommend against adding the Pods directory to your .gitignore. However
34
+ # you should judge for yourself, the pros and cons are mentioned at:
35
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
36
+ #
37
+ # vendor/Pods/
38
+
39
+ # Ignore RubyMine project files
40
+ .idea
41
+
42
+ ## Documentation cache and generated files:
43
+ /.yardoc/
44
+ /_yardoc/
45
+ /doc/
46
+ /rdoc/
47
+
48
+ ## Environment normalization:
49
+ /.bundle/
50
+ /vendor/bundle
51
+ /lib/bundler/man/
52
+
53
+ # for a library or gem, you might want to ignore these files since the code is
54
+ # intended to run in multiple environments; otherwise, check them in:
55
+ Gemfile.lock
56
+ .ruby-version
57
+ .ruby-gemset
58
+
59
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
60
+ .rvmrc
61
+
62
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
63
+ # .rubocop-https?--*
64
+
65
+ # Extra
66
+ .DS_Store
67
+ .DS_STORE
68
+ *.diff
69
+ *.swp
70
+ *.env*
71
+ byebug_history