activerecord-spanner-adapter 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (282) 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 +49 -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 +55 -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 +66 -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 +171 -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 +130 -0
  56. data/acceptance/cases/transactions/read_write_transactions_test.rb +248 -0
  57. data/acceptance/cases/type/all_types_test.rb +172 -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/json_test.rb +34 -0
  65. data/acceptance/cases/type/numeric_test.rb +27 -0
  66. data/acceptance/cases/type/string_test.rb +79 -0
  67. data/acceptance/cases/type/text_test.rb +30 -0
  68. data/acceptance/cases/type/time_test.rb +87 -0
  69. data/acceptance/models/account.rb +13 -0
  70. data/acceptance/models/address.rb +9 -0
  71. data/acceptance/models/album.rb +12 -0
  72. data/acceptance/models/all_types.rb +8 -0
  73. data/acceptance/models/author.rb +11 -0
  74. data/acceptance/models/club.rb +12 -0
  75. data/acceptance/models/comment.rb +9 -0
  76. data/acceptance/models/customer.rb +9 -0
  77. data/acceptance/models/department.rb +9 -0
  78. data/acceptance/models/firm.rb +10 -0
  79. data/acceptance/models/member.rb +13 -0
  80. data/acceptance/models/member_type.rb +9 -0
  81. data/acceptance/models/membership.rb +10 -0
  82. data/acceptance/models/organization.rb +9 -0
  83. data/acceptance/models/post.rb +10 -0
  84. data/acceptance/models/singer.rb +10 -0
  85. data/acceptance/models/track.rb +20 -0
  86. data/acceptance/models/transaction.rb +9 -0
  87. data/acceptance/schema/schema.rb +147 -0
  88. data/acceptance/test_helper.rb +261 -0
  89. data/activerecord-spanner-adapter.gemspec +32 -17
  90. data/assets/solidus-db.png +0 -0
  91. data/benchmarks/README.md +17 -0
  92. data/benchmarks/Rakefile +14 -0
  93. data/benchmarks/application.rb +308 -0
  94. data/benchmarks/config/database.yml +8 -0
  95. data/benchmarks/config/environment.rb +12 -0
  96. data/benchmarks/db/migrate/01_create_tables.rb +25 -0
  97. data/benchmarks/db/schema.rb +29 -0
  98. data/benchmarks/models/album.rb +9 -0
  99. data/benchmarks/models/singer.rb +9 -0
  100. data/bin/console +6 -7
  101. data/examples/rails/README.md +262 -0
  102. data/examples/snippets/README.md +29 -0
  103. data/examples/snippets/Rakefile +57 -0
  104. data/examples/snippets/array-data-type/README.md +45 -0
  105. data/examples/snippets/array-data-type/Rakefile +13 -0
  106. data/examples/snippets/array-data-type/application.rb +45 -0
  107. data/examples/snippets/array-data-type/config/database.yml +8 -0
  108. data/examples/snippets/array-data-type/db/migrate/01_create_tables.rb +24 -0
  109. data/examples/snippets/array-data-type/db/schema.rb +26 -0
  110. data/examples/snippets/array-data-type/db/seeds.rb +5 -0
  111. data/examples/snippets/array-data-type/models/entity_with_array_types.rb +18 -0
  112. data/examples/snippets/bin/create_emulator_instance.rb +18 -0
  113. data/examples/snippets/bulk-insert/README.md +21 -0
  114. data/examples/snippets/bulk-insert/Rakefile +13 -0
  115. data/examples/snippets/bulk-insert/application.rb +64 -0
  116. data/examples/snippets/bulk-insert/config/database.yml +8 -0
  117. data/examples/snippets/bulk-insert/db/migrate/01_create_tables.rb +21 -0
  118. data/examples/snippets/bulk-insert/db/schema.rb +26 -0
  119. data/examples/snippets/bulk-insert/db/seeds.rb +5 -0
  120. data/examples/snippets/bulk-insert/models/album.rb +9 -0
  121. data/examples/snippets/bulk-insert/models/singer.rb +9 -0
  122. data/examples/snippets/commit-timestamp/README.md +18 -0
  123. data/examples/snippets/commit-timestamp/Rakefile +13 -0
  124. data/examples/snippets/commit-timestamp/application.rb +53 -0
  125. data/examples/snippets/commit-timestamp/config/database.yml +8 -0
  126. data/examples/snippets/commit-timestamp/db/migrate/01_create_tables.rb +26 -0
  127. data/examples/snippets/commit-timestamp/db/schema.rb +29 -0
  128. data/examples/snippets/commit-timestamp/db/seeds.rb +5 -0
  129. data/examples/snippets/commit-timestamp/models/album.rb +9 -0
  130. data/examples/snippets/commit-timestamp/models/singer.rb +9 -0
  131. data/examples/snippets/config/environment.rb +21 -0
  132. data/examples/snippets/create-records/README.md +12 -0
  133. data/examples/snippets/create-records/Rakefile +13 -0
  134. data/examples/snippets/create-records/application.rb +42 -0
  135. data/examples/snippets/create-records/config/database.yml +8 -0
  136. data/examples/snippets/create-records/db/migrate/01_create_tables.rb +21 -0
  137. data/examples/snippets/create-records/db/schema.rb +26 -0
  138. data/examples/snippets/create-records/db/seeds.rb +5 -0
  139. data/examples/snippets/create-records/models/album.rb +9 -0
  140. data/examples/snippets/create-records/models/singer.rb +9 -0
  141. data/examples/snippets/date-data-type/README.md +19 -0
  142. data/examples/snippets/date-data-type/Rakefile +13 -0
  143. data/examples/snippets/date-data-type/application.rb +35 -0
  144. data/examples/snippets/date-data-type/config/database.yml +8 -0
  145. data/examples/snippets/date-data-type/db/migrate/01_create_tables.rb +20 -0
  146. data/examples/snippets/date-data-type/db/schema.rb +21 -0
  147. data/examples/snippets/date-data-type/db/seeds.rb +16 -0
  148. data/examples/snippets/date-data-type/models/singer.rb +8 -0
  149. data/examples/snippets/generated-column/README.md +41 -0
  150. data/examples/snippets/generated-column/Rakefile +13 -0
  151. data/examples/snippets/generated-column/application.rb +37 -0
  152. data/examples/snippets/generated-column/config/database.yml +8 -0
  153. data/examples/snippets/generated-column/db/migrate/01_create_tables.rb +23 -0
  154. data/examples/snippets/generated-column/db/schema.rb +21 -0
  155. data/examples/snippets/generated-column/db/seeds.rb +18 -0
  156. data/examples/snippets/generated-column/models/singer.rb +8 -0
  157. data/examples/snippets/hints/README.md +19 -0
  158. data/examples/snippets/hints/Rakefile +13 -0
  159. data/examples/snippets/hints/application.rb +47 -0
  160. data/examples/snippets/hints/config/database.yml +8 -0
  161. data/examples/snippets/hints/db/migrate/01_create_tables.rb +23 -0
  162. data/examples/snippets/hints/db/schema.rb +28 -0
  163. data/examples/snippets/hints/db/seeds.rb +29 -0
  164. data/examples/snippets/hints/models/album.rb +9 -0
  165. data/examples/snippets/hints/models/singer.rb +9 -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/partitioned-dml/README.md +16 -0
  195. data/examples/snippets/partitioned-dml/Rakefile +13 -0
  196. data/examples/snippets/partitioned-dml/application.rb +48 -0
  197. data/examples/snippets/partitioned-dml/config/database.yml +8 -0
  198. data/examples/snippets/partitioned-dml/db/migrate/01_create_tables.rb +21 -0
  199. data/examples/snippets/partitioned-dml/db/schema.rb +26 -0
  200. data/examples/snippets/partitioned-dml/db/seeds.rb +29 -0
  201. data/examples/snippets/partitioned-dml/models/album.rb +9 -0
  202. data/examples/snippets/partitioned-dml/models/singer.rb +9 -0
  203. data/examples/snippets/quickstart/README.md +26 -0
  204. data/examples/snippets/quickstart/Rakefile +13 -0
  205. data/examples/snippets/quickstart/application.rb +51 -0
  206. data/examples/snippets/quickstart/config/database.yml +8 -0
  207. data/examples/snippets/quickstart/db/migrate/01_create_tables.rb +21 -0
  208. data/examples/snippets/quickstart/db/schema.rb +26 -0
  209. data/examples/snippets/quickstart/db/seeds.rb +24 -0
  210. data/examples/snippets/quickstart/models/album.rb +9 -0
  211. data/examples/snippets/quickstart/models/singer.rb +9 -0
  212. data/examples/snippets/read-only-transactions/README.md +13 -0
  213. data/examples/snippets/read-only-transactions/Rakefile +13 -0
  214. data/examples/snippets/read-only-transactions/application.rb +77 -0
  215. data/examples/snippets/read-only-transactions/config/database.yml +8 -0
  216. data/examples/snippets/read-only-transactions/db/migrate/01_create_tables.rb +21 -0
  217. data/examples/snippets/read-only-transactions/db/schema.rb +26 -0
  218. data/examples/snippets/read-only-transactions/db/seeds.rb +24 -0
  219. data/examples/snippets/read-only-transactions/models/album.rb +9 -0
  220. data/examples/snippets/read-only-transactions/models/singer.rb +9 -0
  221. data/examples/snippets/read-write-transactions/README.md +12 -0
  222. data/examples/snippets/read-write-transactions/Rakefile +13 -0
  223. data/examples/snippets/read-write-transactions/application.rb +39 -0
  224. data/examples/snippets/read-write-transactions/config/database.yml +8 -0
  225. data/examples/snippets/read-write-transactions/db/migrate/01_create_tables.rb +22 -0
  226. data/examples/snippets/read-write-transactions/db/schema.rb +27 -0
  227. data/examples/snippets/read-write-transactions/db/seeds.rb +25 -0
  228. data/examples/snippets/read-write-transactions/models/album.rb +9 -0
  229. data/examples/snippets/read-write-transactions/models/singer.rb +9 -0
  230. data/examples/snippets/stale-reads/README.md +27 -0
  231. data/examples/snippets/stale-reads/Rakefile +13 -0
  232. data/examples/snippets/stale-reads/application.rb +63 -0
  233. data/examples/snippets/stale-reads/config/database.yml +8 -0
  234. data/examples/snippets/stale-reads/db/migrate/01_create_tables.rb +21 -0
  235. data/examples/snippets/stale-reads/db/schema.rb +26 -0
  236. data/examples/snippets/stale-reads/db/seeds.rb +24 -0
  237. data/examples/snippets/stale-reads/models/album.rb +9 -0
  238. data/examples/snippets/stale-reads/models/singer.rb +9 -0
  239. data/examples/snippets/timestamp-data-type/README.md +17 -0
  240. data/examples/snippets/timestamp-data-type/Rakefile +13 -0
  241. data/examples/snippets/timestamp-data-type/application.rb +42 -0
  242. data/examples/snippets/timestamp-data-type/config/database.yml +8 -0
  243. data/examples/snippets/timestamp-data-type/db/migrate/01_create_tables.rb +21 -0
  244. data/examples/snippets/timestamp-data-type/db/schema.rb +21 -0
  245. data/examples/snippets/timestamp-data-type/db/seeds.rb +6 -0
  246. data/examples/snippets/timestamp-data-type/models/meeting.rb +19 -0
  247. data/examples/solidus/README.md +172 -0
  248. data/lib/active_record/connection_adapters/spanner/database_statements.rb +244 -266
  249. data/lib/active_record/connection_adapters/spanner/quoting.rb +42 -50
  250. data/lib/active_record/connection_adapters/spanner/schema_cache.rb +43 -0
  251. data/lib/active_record/connection_adapters/spanner/schema_creation.rb +125 -9
  252. data/lib/active_record/connection_adapters/spanner/schema_definitions.rb +122 -0
  253. data/lib/active_record/connection_adapters/spanner/schema_dumper.rb +19 -0
  254. data/lib/active_record/connection_adapters/spanner/schema_statements.rb +553 -139
  255. data/lib/active_record/connection_adapters/spanner/type_metadata.rb +37 -0
  256. data/lib/active_record/connection_adapters/spanner_adapter.rb +185 -78
  257. data/lib/active_record/tasks/spanner_database_tasks.rb +74 -0
  258. data/lib/active_record/type/spanner/array.rb +32 -0
  259. data/lib/active_record/type/spanner/bytes.rb +26 -0
  260. data/lib/active_record/type/spanner/spanner_active_record_converter.rb +33 -0
  261. data/lib/active_record/type/spanner/time.rb +37 -0
  262. data/lib/activerecord-spanner-adapter.rb +23 -0
  263. data/lib/activerecord_spanner_adapter/base.rb +238 -0
  264. data/lib/activerecord_spanner_adapter/connection.rb +350 -0
  265. data/lib/activerecord_spanner_adapter/errors.rb +13 -0
  266. data/lib/activerecord_spanner_adapter/foreign_key.rb +29 -0
  267. data/lib/activerecord_spanner_adapter/index/column.rb +38 -0
  268. data/lib/activerecord_spanner_adapter/index.rb +80 -0
  269. data/lib/activerecord_spanner_adapter/information_schema.rb +262 -0
  270. data/lib/activerecord_spanner_adapter/primary_key.rb +31 -0
  271. data/lib/activerecord_spanner_adapter/table/column.rb +59 -0
  272. data/lib/activerecord_spanner_adapter/table.rb +61 -0
  273. data/lib/activerecord_spanner_adapter/transaction.rb +154 -0
  274. data/lib/activerecord_spanner_adapter/version.rb +9 -0
  275. data/lib/arel/visitors/spanner.rb +111 -0
  276. data/lib/spanner_client_ext.rb +107 -0
  277. data/renovate.json +5 -0
  278. metadata +405 -34
  279. data/.travis.yml +0 -5
  280. data/lib/active_record/connection_adapters/spanner/client.rb +0 -190
  281. data/lib/active_record/connection_adapters/spanner.rb +0 -10
  282. 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: e91546c93ad037bfaa453c4e80f0f9bd3ce5f6ced1e98cfd74ea92a8495996ec
4
+ data.tar.gz: 1180932c1f3644a0338b856f1b170ed5a4aa2735ac8410071981db28697c7bf4
5
5
  SHA512:
6
- metadata.gz: 25ec93d1aa400524c5feb62efbb0bf1dce21468fdee84c5ba8d701cdeedd55b91880ff27880e46c6a19f5bd6d5791d289458a623a675d1089b1c99e1b892b92c
7
- data.tar.gz: 83cd0c3ecec42157a2f0675c1c77900045c74dee42ba83a44474ce966e0dab83b1b5f8fbfb57a8d9eab60b0bf8ebdac3d1177ba4a81faf2734ebb9e62c20142d
6
+ metadata.gz: cbb029027fc34279f095294df20756d1bcfa2a077b45919d4447d4be8a29f7fb5bbb911896b8a5a3441766af735a0ec3ad38b4dfae2527ef401c1d4e9a39132e
7
+ data.tar.gz: 33a6509c950572f3880dc9d48c34dc35784909b46fc1d1226f2e20c57c77e734c53149f6620be17a8d3e85b4e086624bf545dae5bcc91a671cd1089cad885b36
@@ -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,49 @@
1
+ on:
2
+ push:
3
+ branches:
4
+ - master
5
+ pull_request:
6
+ name: acceptance tests on production
7
+ jobs:
8
+ check-env:
9
+ outputs:
10
+ has-key: ${{ steps.project-id.outputs.defined }}
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - id: project-id
14
+ env:
15
+ GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
16
+ if: "${{ env.GCP_PROJECT_ID != '' }}"
17
+ run: echo "::set-output name=defined::true"
18
+
19
+ test:
20
+ needs: [check-env]
21
+ if: needs.check-env.outputs.has-key == 'true'
22
+ runs-on: ubuntu-latest
23
+
24
+ strategy:
25
+ max-parallel: 4
26
+ matrix:
27
+ ruby: [3.0]
28
+ steps:
29
+ - uses: actions/checkout@v2
30
+ - name: Set up Ruby
31
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby
32
+ # (see https://github.com/ruby/setup-ruby#versioning):
33
+ uses: ruby/setup-ruby@v1
34
+ with:
35
+ bundler-cache: true
36
+ ruby-version: ${{ matrix.ruby }}
37
+ - name: Setup GCloud
38
+ uses: google-github-actions/setup-gcloud@master
39
+ with:
40
+ project_id: ${{ secrets.GCP_PROJECT_ID }}
41
+ service_account_key: ${{ secrets.GCP_SA_KEY }}
42
+ export_default_credentials: true
43
+ - name: Install dependencies
44
+ run: bundle install
45
+ - name: Run acceptance tests on production
46
+ run: bundle exec rake acceptance\[,,,"exclude cases/migration"\]
47
+ env:
48
+ SPANNER_TEST_PROJECT: ${{ secrets.GCP_PROJECT_ID }}
49
+ 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
@@ -0,0 +1,77 @@
1
+ #!/bin/bash
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # This file is called in the early stage of `trampoline_v2.sh` to
18
+ # populate secrets needed for the CI builds.
19
+
20
+ set -eo pipefail
21
+
22
+ function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
23
+ function msg { println "$*" >&2 ;}
24
+ function println { printf '%s\n' "$(now) $*" ;}
25
+
26
+ # Populates requested secrets set in SECRET_MANAGER_KEYS
27
+
28
+ # In Kokoro CI builds, we use the service account attached to the
29
+ # Kokoro VM. This means we need to setup auth on other CI systems.
30
+ # For local run, we just use the gcloud command for retrieving the
31
+ # secrets.
32
+
33
+ if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then
34
+ GCLOUD_COMMANDS=(
35
+ "docker"
36
+ "run"
37
+ "--entrypoint=gcloud"
38
+ "--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR}"
39
+ "gcr.io/google.com/cloudsdktool/cloud-sdk"
40
+ )
41
+ if [[ "${TRAMPOLINE_CI:-}" == "kokoro" ]]; then
42
+ SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
43
+ else
44
+ echo "Authentication for this CI system is not implemented yet."
45
+ exit 2
46
+ # TODO: Determine appropriate SECRET_LOCATION and the GCLOUD_COMMANDS.
47
+ fi
48
+ else
49
+ # For local run, use /dev/shm or temporary directory for
50
+ # KOKORO_GFILE_DIR.
51
+ if [[ -d "/dev/shm" ]]; then
52
+ export KOKORO_GFILE_DIR=/dev/shm
53
+ else
54
+ export KOKORO_GFILE_DIR=$(mktemp -d -t ci-XXXXXXXX)
55
+ fi
56
+ SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
57
+ GCLOUD_COMMANDS=("gcloud")
58
+ fi
59
+
60
+ msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
61
+ mkdir -p ${SECRET_LOCATION}
62
+
63
+ for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
64
+ do
65
+ msg "Retrieving secret ${key}"
66
+ "${GCLOUD_COMMANDS[@]}" \
67
+ secrets versions access latest \
68
+ --project cloud-devrel-kokoro-resources \
69
+ --secret $key > \
70
+ "$SECRET_LOCATION/$key"
71
+ if [[ $? == 0 ]]; then
72
+ msg "Secret written to ${SECRET_LOCATION}/${key}"
73
+ else
74
+ msg "Error retrieving secret ${key}"
75
+ exit 2
76
+ fi
77
+ done
@@ -0,0 +1,33 @@
1
+ # Format: //devtools/kokoro/config/proto/build.proto
2
+
3
+ # Build logs will be here
4
+ action {
5
+ define_artifacts {
6
+ regex: "**/*sponge_log.xml"
7
+ }
8
+ }
9
+
10
+ # Download resources for system tests (service account key, etc.)
11
+ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-ruby"
12
+
13
+ # Download trampoline resources.
14
+ gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
15
+
16
+ # Use the trampoline script to run in docker.
17
+ build_file: "ruby-spanner-activerecord/.kokoro/trampoline_v2.sh"
18
+
19
+ # Configure the docker image for kokoro-trampoline.
20
+ env_vars: {
21
+ key: "TRAMPOLINE_IMAGE"
22
+ value: "gcr.io/cloud-devrel-kokoro-resources/yoshi-ruby/release"
23
+ }
24
+
25
+ env_vars: {
26
+ key: "TRAMPOLINE_BUILD_FILE"
27
+ value: ".kokoro/release.sh"
28
+ }
29
+
30
+ env_vars: {
31
+ key: "SECRET_MANAGER_KEYS"
32
+ value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,docuploader_service_account"
33
+ }
@@ -0,0 +1,15 @@
1
+ #!/bin/bash
2
+
3
+ set -eo pipefail
4
+
5
+ # Install gems in the user directory because the default install directory
6
+ # is in a read-only location.
7
+ export GEM_HOME=$HOME/.gem
8
+ export PATH=$GEM_HOME/bin:$PATH
9
+
10
+ python3 -m pip install git+https://github.com/googleapis/releasetool
11
+ python3 -m pip install gcp-docuploader
12
+ gem install --no-document toys
13
+
14
+ python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script
15
+ toys release perform -v --enable-docs < /dev/null