activerecord-refined 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +17 -0
  3. data/README.md +111 -815
  4. data/activerecord-refined.gemspec +36 -17
  5. data/docs/conditions.md +206 -0
  6. data/docs/ctes.md +65 -0
  7. data/docs/expressions.md +125 -0
  8. data/docs/functions.md +219 -0
  9. data/docs/grouping.md +55 -0
  10. data/docs/joins.md +73 -0
  11. data/docs/json.md +230 -0
  12. data/docs/ordering.md +55 -0
  13. data/docs/time_zones.md +30 -0
  14. data/docs/windows.md +41 -0
  15. data/docs/writing.md +33 -0
  16. data/examples/aggregations.rb +31 -11
  17. data/examples/complex_joins.rb +12 -10
  18. data/examples/ctes.rb +22 -20
  19. data/examples/expressions.rb +110 -45
  20. data/examples/json.rb +77 -38
  21. data/examples/postgresql.rb +64 -53
  22. data/examples/predicates.rb +35 -33
  23. data/examples/subqueries.rb +20 -18
  24. data/examples/windows.rb +23 -21
  25. data/examples/writes.rb +26 -24
  26. data/lib/active_record/refined/ast.rb +1117 -373
  27. data/lib/active_record/refined/dialect/mariadb.rb +25 -0
  28. data/lib/active_record/refined/dialect/mysql.rb +18 -0
  29. data/lib/active_record/refined/dialect/mysql_compat.rb +67 -0
  30. data/lib/active_record/refined/dialect/oracle.rb +110 -0
  31. data/lib/active_record/refined/dialect/postgresql.rb +120 -0
  32. data/lib/active_record/refined/dialect/sql_server.rb +115 -0
  33. data/lib/active_record/refined/dialect/sqlite.rb +57 -0
  34. data/lib/active_record/refined/dialect.rb +340 -0
  35. data/lib/active_record/refined.rb +877 -307
  36. data/lib/activerecord-refined/version.rb +3 -1
  37. data/lib/activerecord-refined.rb +9 -5
  38. metadata +186 -15
  39. data/.github/workflows/push_gem.yml +0 -45
  40. data/.github/workflows/sandbox.yml +0 -295
  41. data/.github/workflows/test.yml +0 -90
  42. data/.gitignore +0 -19
  43. data/Gemfile +0 -12
  44. data/Rakefile +0 -25
  45. data/benchmark/query_building.rb +0 -129
  46. data/test/test_block_syntax.rb +0 -2493
  47. data/test/test_helper.rb +0 -221
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Activerecord
2
4
  module Refined
3
- VERSION = '0.8.1'
5
+ VERSION = "0.10.0"
4
6
  end
5
7
  end
@@ -1,8 +1,12 @@
1
- require 'activerecord-refined/version'
2
- require 'active_record'
3
- require 'active_record/relation'
4
- require 'active_record/refined/ast'
5
- require 'active_record/refined'
1
+ # frozen_string_literal: true
2
+
3
+ require "activerecord-refined/version"
4
+ require "active_record"
5
+ require "bigdecimal"
6
+ require "active_record/relation"
7
+ require "active_record/refined/ast"
8
+ require "active_record/refined/dialect"
9
+ require "active_record/refined"
6
10
 
7
11
  ActiveRecord::QueryMethods.prepend ActiveRecord::Refined::QueryMethods
8
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-refined
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugo Maeda
@@ -89,6 +89,166 @@ dependencies:
89
89
  - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: "0"
92
+ - !ruby/object:Gem::Dependency
93
+ name: benchmark-ips
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ -
97
+ - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: "0"
100
+ type: :development
101
+ prerelease: false
102
+ version_requirements: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ -
105
+ - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: "0"
108
+ - !ruby/object:Gem::Dependency
109
+ name: memory_profiler
110
+ requirement: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ -
113
+ - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ -
121
+ - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: "0"
124
+ - !ruby/object:Gem::Dependency
125
+ name: rubocop
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ -
129
+ - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: "0"
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ -
137
+ - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: "0"
140
+ - !ruby/object:Gem::Dependency
141
+ name: rubocop-minitest
142
+ requirement: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ -
145
+ - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: "0"
148
+ type: :development
149
+ prerelease: false
150
+ version_requirements: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ -
153
+ - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: "0"
156
+ - !ruby/object:Gem::Dependency
157
+ name: rubocop-packaging
158
+ requirement: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ -
161
+ - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: "0"
164
+ type: :development
165
+ prerelease: false
166
+ version_requirements: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ -
169
+ - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: "0"
172
+ - !ruby/object:Gem::Dependency
173
+ name: rubocop-performance
174
+ requirement: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ -
177
+ - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: "0"
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ -
185
+ - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: "0"
188
+ - !ruby/object:Gem::Dependency
189
+ name: rubocop-rails
190
+ requirement: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ -
193
+ - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: "0"
196
+ type: :development
197
+ prerelease: false
198
+ version_requirements: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ -
201
+ - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: "0"
204
+ - !ruby/object:Gem::Dependency
205
+ name: rubocop-md
206
+ requirement: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ -
209
+ - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: "0"
212
+ type: :development
213
+ prerelease: false
214
+ version_requirements: !ruby/object:Gem::Requirement
215
+ requirements:
216
+ -
217
+ - ">="
218
+ - !ruby/object:Gem::Version
219
+ version: "0"
220
+ - !ruby/object:Gem::Dependency
221
+ name: yard
222
+ requirement: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ -
225
+ - ">="
226
+ - !ruby/object:Gem::Version
227
+ version: "0"
228
+ type: :development
229
+ prerelease: false
230
+ version_requirements: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ -
233
+ - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: "0"
236
+ - !ruby/object:Gem::Dependency
237
+ name: yard-markdown-relative-links
238
+ requirement: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ -
241
+ - ">="
242
+ - !ruby/object:Gem::Version
243
+ version: "0"
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ -
249
+ - ">="
250
+ - !ruby/object:Gem::Version
251
+ version: "0"
92
252
  description: Adding clean and powerful query syntax on Active Record using refinements
93
253
  email:
94
254
  - shugo@ruby-lang.org
@@ -96,16 +256,21 @@ executables: []
96
256
  extensions: []
97
257
  extra_rdoc_files: []
98
258
  files:
99
- - .github/workflows/push_gem.yml
100
- - .github/workflows/sandbox.yml
101
- - .github/workflows/test.yml
102
- - .gitignore
103
- - Gemfile
259
+ - .yardopts
104
260
  - LICENSE.txt
105
261
  - README.md
106
- - Rakefile
107
262
  - activerecord-refined.gemspec
108
- - benchmark/query_building.rb
263
+ - docs/conditions.md
264
+ - docs/ctes.md
265
+ - docs/expressions.md
266
+ - docs/functions.md
267
+ - docs/grouping.md
268
+ - docs/joins.md
269
+ - docs/json.md
270
+ - docs/ordering.md
271
+ - docs/time_zones.md
272
+ - docs/windows.md
273
+ - docs/writing.md
109
274
  - examples/aggregations.rb
110
275
  - examples/complex_joins.rb
111
276
  - examples/ctes.rb
@@ -118,13 +283,21 @@ files:
118
283
  - examples/writes.rb
119
284
  - lib/active_record/refined.rb
120
285
  - lib/active_record/refined/ast.rb
286
+ - lib/active_record/refined/dialect.rb
287
+ - lib/active_record/refined/dialect/mariadb.rb
288
+ - lib/active_record/refined/dialect/mysql.rb
289
+ - lib/active_record/refined/dialect/mysql_compat.rb
290
+ - lib/active_record/refined/dialect/oracle.rb
291
+ - lib/active_record/refined/dialect/postgresql.rb
292
+ - lib/active_record/refined/dialect/sql_server.rb
293
+ - lib/active_record/refined/dialect/sqlite.rb
121
294
  - lib/activerecord-refined.rb
122
295
  - lib/activerecord-refined/version.rb
123
- - test/test_block_syntax.rb
124
- - test/test_helper.rb
125
296
  homepage: "https://github.com/shugo/activerecord-refined"
126
- licenses: []
127
- metadata: {}
297
+ licenses:
298
+ - MIT
299
+ metadata:
300
+ documentation_uri: "https://rubydoc.info/gems/activerecord-refined"
128
301
  rdoc_options: []
129
302
  require_paths:
130
303
  - lib
@@ -144,6 +317,4 @@ requirements: []
144
317
  rubygems_version: 4.1.0.dev
145
318
  specification_version: 4
146
319
  summary: Write Active Record queries as Ruby expressions
147
- test_files:
148
- - test/test_block_syntax.rb
149
- - test/test_helper.rb
320
+ test_files: []
@@ -1,45 +0,0 @@
1
- name: push gem
2
-
3
- on:
4
- push:
5
- tags:
6
- - "v*"
7
-
8
- jobs:
9
- push:
10
- if: github.repository == 'shugo/activerecord-refined'
11
- runs-on: ubuntu-latest
12
-
13
- environment:
14
- name: release
15
- url: https://rubygems.org/gems/activerecord-refined
16
-
17
- permissions:
18
- # release-gem pushes the tag, and needs id-token to identify itself to
19
- # RubyGems.org instead of an API key.
20
- contents: write
21
- id-token: write
22
-
23
- env:
24
- # Nothing here loads pg or mysql2, and building them needs client
25
- # libraries the runner would have to install first.
26
- BUNDLE_WITHOUT: db
27
-
28
- steps:
29
- - uses: actions/checkout@v5
30
- with:
31
- # release-gem sets up its own short-lived git credentials.
32
- persist-credentials: false
33
-
34
- - uses: ruby/setup-ruby@v1
35
- with:
36
- # Not `ruby`: the gemspec requires 4.1.0.dev for Proc#refined, so
37
- # bundler refuses to resolve on a released Ruby.
38
- ruby-version: head
39
- bundler-cache: true
40
-
41
- # Runs `rake release`, which builds the gem and pushes it. The tag it
42
- # would create already exists here, so that step is skipped.
43
- - uses: rubygems/release-gem@v1
44
- with:
45
- attestations: false
@@ -1,295 +0,0 @@
1
- name: sandbox
2
-
3
- on:
4
- push:
5
- branches: [master]
6
- pull_request:
7
- workflow_dispatch:
8
-
9
- concurrency:
10
- group: sandbox-${{ github.ref }}
11
- cancel-in-progress: true
12
-
13
- jobs:
14
- build:
15
- runs-on: ubuntu-latest
16
- defaults:
17
- run:
18
- working-directory: sandbox
19
-
20
- steps:
21
- - uses: actions/checkout@v7
22
-
23
- # The host Ruby cannot be 4.1: ruby_wasm's native extension depends on
24
- # rb-sys, which does not build against Ruby 4.1's headers. rbwasm is
25
- # only a build tool -- the Ruby it produces is the one that matters.
26
- - uses: ruby/setup-ruby@v1
27
- with:
28
- ruby-version: '4.0'
29
- bundler-cache: false
30
- working-directory: sandbox
31
-
32
- - uses: actions/setup-node@v7
33
- with:
34
- node-version: '24'
35
-
36
- # What the binary is made of: the gems with C extensions, the scripts
37
- # that drive the build -- RUBY_REV and the toolchain versions are pinned
38
- # in them -- the staged extension, and the host Ruby. Not the gem's own
39
- # lib and not the page, neither of which the binary contains; those are
40
- # files the page fetches at startup.
41
- #
42
- # Naming the build after this rather than after the binary is what makes
43
- # the URL stable. The build is not reproducible to the byte -- the same
44
- # tree twice over came out 1 KB apart, mtimes riding along in the packed
45
- # filesystem -- so a hash of the output would change on every deploy and
46
- # give every visitor 12 MB to fetch again for nothing.
47
- - name: Identify the build
48
- id: build
49
- run: |
50
- hash="${{ hashFiles('sandbox/.ruby-version', 'sandbox/Gemfile.lock', 'sandbox/bin/build-wasm', 'sandbox/bin/rbwasm-build.rb', 'sandbox/bin/install-wasi-sdk.rb', 'sandbox/ext/**') }}"
51
-
52
- # hashFiles gives back an empty string when it matches nothing, and
53
- # an empty hash would quietly name every build alike -- and hand out
54
- # whichever binary happened to be uploaded first, for good.
55
- if [ -z "$hash" ]; then
56
- echo "::error::hashFiles matched none of the build inputs" >&2
57
- exit 1
58
- fi
59
-
60
- echo "hash=$hash" >> "$GITHUB_OUTPUT"
61
- echo "key=ruby-${hash:0:16}.wasm" >> "$GITHUB_OUTPUT"
62
- echo "this build is ruby-${hash:0:16}.wasm"
63
-
64
- # The binary for these inputs may already be in the bucket from an
65
- # earlier deploy, in which case there is nothing to build: 12 MB comes
66
- # down in a few seconds where a build takes two minutes warm and sixteen
67
- # cold. The examples are still checked against it below, which is what
68
- # the deploy is really for.
69
- #
70
- # Anything at all going wrong here -- no credentials, as on a fork, a
71
- # network failure, a half-written file -- falls through to building.
72
- - name: Fetch this build from R2 if it is there
73
- id: prebuilt
74
- if: vars.R2_PUBLIC_URL != ''
75
- env:
76
- AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
77
- AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
78
- AWS_DEFAULT_REGION: auto
79
- AWS_REQUEST_CHECKSUM_CALCULATION: when_required
80
- AWS_RESPONSE_CHECKSUM_VALIDATION: when_required
81
- ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
82
- BUCKET: ${{ vars.R2_BUCKET }}
83
- KEY: ${{ steps.build.outputs.key }}
84
- run: |
85
- if aws s3api get-object \
86
- --endpoint-url "$ENDPOINT" \
87
- --bucket "$BUCKET" \
88
- --key "$KEY" \
89
- /tmp/ruby.wasm.gz \
90
- --no-cli-pager > /dev/null 2>&1 &&
91
- gunzip -c /tmp/ruby.wasm.gz > ruby.wasm
92
- then
93
- echo "found=true" >> "$GITHUB_OUTPUT"
94
- echo "took $KEY from the bucket; not building"
95
- ls -l ruby.wasm
96
- else
97
- rm -f ruby.wasm
98
- echo "$KEY is not in the bucket; building it"
99
- fi
100
-
101
- # The Ruby checkout and the build tree have to be cached together. make
102
- # decides by mtime, so restoring objects next to a freshly cloned Ruby
103
- # would rebuild everything. Keyed on the same inputs as the binary, so
104
- # the two cannot drift apart.
105
- #
106
- # restore-keys is what keeps this worth caching -- a key change would
107
- # otherwise mean a cold 16-minute build rather than two minutes -- but it
108
- # also means a bad tree outlives the key that produced it, since the
109
- # prefix still matches. Editing a file in the key does not clear it;
110
- # deleting the cache does. bin/build-wasm rejects a ruby.wasm built from
111
- # such a tree, so it fails the run rather than shipping.
112
- - name: Restore the WASM build tree
113
- if: steps.prebuilt.outputs.found != 'true'
114
- uses: actions/cache@v6
115
- with:
116
- path: sandbox/build
117
- key: wasm-${{ runner.os }}-${{ steps.build.outputs.hash }}
118
- restore-keys: wasm-${{ runner.os }}-
119
-
120
- - run: bundle install --jobs 4
121
- - run: npm ci
122
-
123
- - name: Build ruby.wasm
124
- if: steps.prebuilt.outputs.found != 'true'
125
- run: ./bin/build-wasm
126
-
127
- - name: Assemble the Ruby files served to the page
128
- run: ./bin/prepare-rb
129
-
130
- # Runs every example through the same WASI shim the page uses. The
131
- # larger stack is needed to compile Active Record's relation.rb; see the
132
- # note in sandbox/README.md.
133
- - name: Check the examples
134
- run: node --stack-size=4000 check-examples.mjs
135
-
136
- # ruby.wasm is 40 MB and nearly all of the bandwidth this page uses, so
137
- # it is served from R2 -- egress there is free -- and only the page
138
- # itself from Pages.
139
- #
140
- # Only when it was built here: found in the bucket, it is already up.
141
- # The object is therefore written once and never rewritten, which is what
142
- # the immutable caching claims. R2 serves what it is given and does not
143
- # compress, hence gzip with the encoding recorded on the object: 40 MB
144
- # becomes 12 MB on the wire.
145
- #
146
- # Without the secrets configured the upload is skipped and ruby.wasm
147
- # rides along in the Pages artifact as before, which keeps forks working.
148
- # Uploaded over R2's S3-compatible API rather than with wrangler, so that
149
- # the token can be an Object Read & Write one scoped to this bucket.
150
- # Those permissions exist only on the S3 API: wrangler goes through
151
- # Cloudflare's REST API, which answers 403 to them and wants Admin Read &
152
- # Write -- a token that can create and delete every bucket in the
153
- # account, which is not what a public repository's CI should hold.
154
- - name: Upload ruby.wasm to R2
155
- id: r2
156
- if: >-
157
- github.ref == 'refs/heads/master' && vars.R2_PUBLIC_URL != ''
158
- && steps.prebuilt.outputs.found != 'true'
159
- env:
160
- KEY: ${{ steps.build.outputs.key }}
161
- AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
162
- AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
163
- AWS_DEFAULT_REGION: auto
164
- # R2 sends no checksum headers back, which newer AWS CLIs insist on.
165
- AWS_REQUEST_CHECKSUM_CALCULATION: when_required
166
- AWS_RESPONSE_CHECKSUM_VALIDATION: when_required
167
- ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
168
- BUCKET: ${{ vars.R2_BUCKET }}
169
- # How many builds to keep, the newest included. A page loaded just
170
- # before a deploy goes on finding its binary, and a bad build can be
171
- # rolled back by hand; further back is 12 MB apiece for nothing.
172
- KEEP: 3
173
- run: |
174
- gzip -9 -c ruby.wasm > /tmp/ruby.wasm.gz
175
-
176
- aws s3api put-object \
177
- --endpoint-url "$ENDPOINT" \
178
- --bucket "$BUCKET" \
179
- --key "$KEY" \
180
- --body /tmp/ruby.wasm.gz \
181
- --content-type application/wasm \
182
- --content-encoding gzip \
183
- --cache-control "public, max-age=31536000, immutable" \
184
- --no-cli-pager
185
-
186
- echo "uploaded=true" >> "$GITHUB_OUTPUT"
187
-
188
- # Distinct keys have nothing to remove them, so the oldest go here.
189
- # Ordered by age rather than by name, since a key says which inputs
190
- # built it but not which came first; the timestamps are UTC ISO 8601,
191
- # so sorting them as text sorts them by time. `head -n -KEEP` is
192
- # every line but the last KEEP, and prints nothing until there are
193
- # more.
194
- #
195
- # The listing is written out before it is sorted, so that what the if
196
- # tests is the listing: a pipeline would report the sort, which
197
- # succeeds on no input either way. A failure is said rather than
198
- # raised, since the binary is already up and a stale object left
199
- # behind is no reason to hold back the deploy that needs the new one.
200
- if aws s3api list-objects-v2 \
201
- --endpoint-url "$ENDPOINT" \
202
- --bucket "$BUCKET" \
203
- --prefix ruby- \
204
- --query "Contents[].[LastModified,Key]" \
205
- --output text --no-cli-pager > /tmp/builds
206
- then
207
- sort /tmp/builds | head -n "-$KEEP" | cut -f2 | while read -r stale; do
208
- # The one just uploaded is never stale, whatever the listing says
209
- # of its age: it is the binary the page about to be deployed asks
210
- # for. Whatever else is under the prefix is not ours to delete.
211
- case "$stale" in
212
- "$KEY") echo "keeping $stale, which is this build"; continue ;;
213
- ruby-*.wasm) ;;
214
- *) echo "leaving $stale alone"; continue ;;
215
- esac
216
- echo "removing $stale"
217
- aws s3api delete-object \
218
- --endpoint-url "$ENDPOINT" \
219
- --bucket "$BUCKET" \
220
- --key "$stale" \
221
- --no-cli-pager ||
222
- echo "::warning::could not remove $stale"
223
- done
224
- else
225
- echo "::warning::could not list $BUCKET; older builds were left in place"
226
- fi
227
-
228
- # The preload in the head is what the page fetches the binary by, and it
229
- # ships pointing at the local build. Naming R2 there rather than in a
230
- # file the page has to read first is worth a round trip on every visit:
231
- # the browser can start on the 12 MB while it is still parsing the head,
232
- # instead of after the scripts have loaded and asked where to look.
233
- #
234
- # Done whether the binary went up in this run or was already there. A
235
- # checkout with no deployment behind it keeps the line as written, and
236
- # the artifact carries the ruby.wasm beside it.
237
- - name: Point the page at R2
238
- id: r2url
239
- if: steps.prebuilt.outputs.found == 'true' || steps.r2.outputs.uploaded == 'true'
240
- env:
241
- URL: ${{ vars.R2_PUBLIC_URL }}/${{ steps.build.outputs.key }}
242
- run: |
243
- before=$(grep -c 'id="ruby-wasm"' index.html)
244
- if [ "$before" != 1 ]; then
245
- echo "::error::expected one preload link in index.html, found $before" >&2
246
- exit 1
247
- fi
248
-
249
- sed -i "s|\(<link id=\"ruby-wasm\"[^>]*href=\)\"[^\"]*\"|\1\"$URL\"|" index.html
250
- grep '<link id="ruby-wasm"' index.html
251
-
252
- if ! grep -q "href=\"$URL\"" index.html; then
253
- echo "::error::the preload link was not rewritten" >&2
254
- exit 1
255
- fi
256
- echo "served=true" >> "$GITHUB_OUTPUT"
257
-
258
- - uses: actions/upload-artifact@v7
259
- with:
260
- name: sandbox
261
- path: |
262
- sandbox/index.html
263
- sandbox/boot.rb
264
- sandbox/examples.js
265
- sandbox/pglite-bridge.mjs
266
- sandbox/manifest.json
267
- ${{ steps.r2url.outputs.served != 'true' && 'sandbox/ruby.wasm' || '' }}
268
- sandbox/rb
269
- sandbox/assets
270
- if-no-files-found: ignore
271
- retention-days: 7
272
-
273
- deploy:
274
- if: github.ref == 'refs/heads/master'
275
- needs: build
276
- runs-on: ubuntu-latest
277
- permissions:
278
- pages: write
279
- id-token: write
280
- environment:
281
- name: github-pages
282
- url: ${{ steps.deploy.outputs.page_url }}
283
-
284
- steps:
285
- - uses: actions/download-artifact@v8
286
- with:
287
- name: sandbox
288
- path: site
289
-
290
- - uses: actions/configure-pages@v6
291
- - uses: actions/upload-pages-artifact@v5
292
- with:
293
- path: site
294
- - id: deploy
295
- uses: actions/deploy-pages@v5
@@ -1,90 +0,0 @@
1
- name: test
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
- pull_request:
8
-
9
- jobs:
10
- sqlite:
11
- runs-on: ubuntu-latest
12
- env:
13
- # Nothing here loads pg or mysql2, so skip building the extensions.
14
- BUNDLE_WITHOUT: db
15
- steps:
16
- - uses: actions/checkout@v5
17
- - uses: ruby/setup-ruby@v1
18
- with:
19
- # Proc#refined has not been released yet, so master is the only
20
- # Ruby that can run this.
21
- ruby-version: head
22
- bundler-cache: true
23
- - run: bundle exec rake test
24
-
25
- postgresql:
26
- runs-on: ubuntu-latest
27
- env:
28
- ADAPTER: postgresql
29
- DB_USERNAME: postgres
30
- DB_PASSWORD: postgres
31
- services:
32
- postgres:
33
- image: postgres:16
34
- env:
35
- POSTGRES_PASSWORD: postgres
36
- ports:
37
- - 5432:5432
38
- options: >-
39
- --health-cmd pg_isready
40
- --health-interval 10s
41
- --health-timeout 5s
42
- --health-retries 5
43
- steps:
44
- - uses: actions/checkout@v5
45
- - uses: ruby/setup-ruby@v1
46
- with:
47
- ruby-version: head
48
- bundler-cache: true
49
- - run: bundle exec rake test
50
-
51
- # Both answer to the mysql2 adapter and they do not agree: MariaDB's json
52
- # column is a checked longtext where MySQL's is a type of its own, and
53
- # MariaDB casts to integer where MySQL knows only signed. Each has passed
54
- # while the other failed, so both run.
55
- mysql:
56
- name: mysql (${{ matrix.image }})
57
- runs-on: ubuntu-latest
58
- strategy:
59
- fail-fast: false
60
- matrix:
61
- include:
62
- - image: mysql:8
63
- health: mysqladmin ping -proot
64
- - image: mariadb:11
65
- health: healthcheck.sh --connect --innodb_initialized
66
- env:
67
- ADAPTER: mysql2
68
- # The suite creates its own database, which MYSQL_USER would not be
69
- # granted; root is the account that can.
70
- DB_USERNAME: root
71
- DB_PASSWORD: root
72
- services:
73
- mysql:
74
- image: ${{ matrix.image }}
75
- env:
76
- MYSQL_ROOT_PASSWORD: root
77
- ports:
78
- - 3306:3306
79
- options: >-
80
- --health-cmd "${{ matrix.health }}"
81
- --health-interval 10s
82
- --health-timeout 5s
83
- --health-retries 5
84
- steps:
85
- - uses: actions/checkout@v5
86
- - uses: ruby/setup-ruby@v1
87
- with:
88
- ruby-version: head
89
- bundler-cache: true
90
- - run: bundle exec rake test