Skip to content

Commit 1fa0da7

Browse files
committed
feat(ci): follow rails more closely
- Add a `RAILS_TAG` environment variable to specify the Rails reference to test against. - Update CI workflows to dynamically determine supported CockroachDB versions from the official CockroachDB docs. - Weekly run CI.
1 parent 27ebc9e commit 1fa0da7

File tree

4 files changed

+59
-33
lines changed

4 files changed

+59
-33
lines changed

.github/workflows/ci.yml

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ on:
99
# Triggers the workflow on pull request events.
1010
pull_request:
1111
types: [opened, reopened, synchronize]
12-
12+
schedule:
13+
- cron: 12 13 * * 1 # Weekly
1314
# Allows you to run this workflow manually from the Actions tab
1415
workflow_dispatch:
1516

@@ -19,7 +20,58 @@ concurrency:
1920
cancel-in-progress: true
2021

2122
jobs:
22-
# Since the name of the matrix job depends on the version, we define another job with a more stable name.
23+
orchestrate:
24+
runs-on: ubuntu-latest
25+
name: Prepare Tests
26+
outputs:
27+
supported_crdbs: ${{ steps.crdb.outputs.crdbs }}
28+
latest_crdb: ${{ steps.crdb.outputs.latest }}
29+
steps:
30+
- id: crdb
31+
name: Determine Supported CockroachDB Versions
32+
shell: ruby -rcsv -rjson -rnet/http -ruri -e {0}
33+
run: |
34+
puts "hey"
35+
36+
test:
37+
runs-on: ubuntu-latest
38+
needs: orchestrate
39+
continue-on-error: ${{ matrix.experimental }}
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
# https://www.cockroachlabs.com/docs/releases/release-support-policy
44+
crdb: ${{ fromJSON(needs.orchestrate.outputs.supported_crdbs) }}
45+
ruby: ["3.4"]
46+
rails: ["8-1-stable"]
47+
experimental: [false]
48+
include:
49+
- crdb: ${{ fromJSON(needs.orchestrate.outputs.latest_crdb) }}
50+
ruby: "3.4"
51+
rails: "main"
52+
experimental: true
53+
name: Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }} rails=${{ matrix.rails }})
54+
steps:
55+
- name: Set Up Actions
56+
uses: actions/checkout@v4
57+
- uses: ./.github/actions/test-runner
58+
id: test
59+
with:
60+
crdb: ${{ matrix.crdb }}
61+
ruby: ${{ matrix.ruby }}
62+
env:
63+
RAILS_TAG: ${{ matrix.rails }}
64+
JSON_REPORTER: "report.json"
65+
- name: Upload Report
66+
if: ${{ failure() && steps.test.conclusion == 'failure' }}
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: report-${{ matrix.crdb }}-${{ matrix.ruby }}
70+
path: report.json
71+
# Since the name of the matrix job depends on the
72+
# version, we define another job with a more stable
73+
# name. We also aggregate failed tests to display
74+
# in the Github Summary.
2375
test_results:
2476
if: ${{ always() }}
2577
runs-on: ubuntu-latest
@@ -92,29 +144,3 @@ jobs:
92144
echo '```json' >>$GITHUB_STEP_SUMMARY
93145
jq --slurp --compact-output '.' reports/*/report.json >>$GITHUB_STEP_SUMMARY
94146
echo '```' >>$GITHUB_STEP_SUMMARY
95-
96-
test:
97-
runs-on: ubuntu-latest
98-
strategy:
99-
fail-fast: false
100-
matrix:
101-
# https://www.cockroachlabs.com/docs/releases/release-support-policy
102-
crdb: [v24.3, v25.1, v25.2, v25.3]
103-
ruby: ["3.4"]
104-
name: Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }})
105-
steps:
106-
- name: Set Up Actions
107-
uses: actions/checkout@v4
108-
- uses: ./.github/actions/test-runner
109-
id: test
110-
with:
111-
crdb: ${{ matrix.crdb }}
112-
ruby: ${{ matrix.ruby }}
113-
env:
114-
JSON_REPORTER: "report.json"
115-
- name: Upload Report
116-
if: ${{ failure() && steps.test.conclusion == 'failure' }}
117-
uses: actions/upload-artifact@v4
118-
with:
119-
name: report-${{ matrix.crdb }}-${{ matrix.ruby }}
120-
path: report.json

.github/workflows/flaky.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ jobs:
2828
name: Prepare Matrix
2929
steps:
3030
- id: generate-matrix
31+
name: Generate Test Matrix
3132
run: |
3233
crdb=$(jq --raw-input --compact-output 'split(" ")' <<<"${{ github.event.inputs.crdb }}")
3334
ruby=$(jq --raw-input --compact-output 'split(" ")' <<<"${{ github.event.inputs.ruby }}")
3435
crdb_len=$(wc -w <<<"${{ github.event.inputs.crdb }}")
3536
ruby_len=$(wc -w <<<"${{ github.event.inputs.ruby }}")
3637
(( seeds_count = ${{github.event.inputs.max}} / ( crdb_len * ruby_len ) ))
3738
seeds=$(shuf --input-range=1-65535 --head-count=$seeds_count | jq --slurp --compact-output)
38-
echo $seeds
3939
echo "crdb=$crdb" >> $GITHUB_OUTPUT
4040
echo "ruby=$ruby" >> $GITHUB_OUTPUT
4141
echo "seeds=$seeds" >> $GITHUB_OUTPUT
@@ -64,7 +64,7 @@ jobs:
6464
ruby: ${{ matrix.ruby }}
6565
TESTOPTS: --fail-fast
6666
env:
67-
JSON_REPORTER: "report.json"
67+
JSON_REPORTER: 'report.json'
6868
SEED: ${{ matrix.seed }}
6969
- name: Upload Report
7070
if: ${{ failure() && steps.test.conclusion == 'failure' }}

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module RailsTag
2020
def gemspec_requirement
2121
File
2222
.foreach(File.expand_path("activerecord-cockroachdb-adapter.gemspec", __dir__), chomp: true)
23-
.find { _1[/add_dependency\s.activerecord.,\s.(.*)./] }
23+
.find { _1[/add_dependency\s.activerecord.,\s["'](.*?)["']/] }
2424

2525
Gem::Requirement.new(Regexp.last_match(1))
2626
end
@@ -46,7 +46,7 @@ group :development, :test do
4646
# We need to load the gem from git to have access to activerecord's test files.
4747
# You can use `path: "some/local/rails"` if you want to test the gem against
4848
# a specific rails codebase.
49-
gem "rails", github: "rails/rails", tag: RailsTag.call
49+
gem "rails", github: "rails/rails", ref: ENV.fetch("RAILS_TAG", RailsTag.call)
5050

5151
# Needed for the test suite
5252
gem "msgpack", ">= 1.7.0"

activerecord-cockroachdb-adapter.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
1414
spec.description = "Allows the use of CockroachDB as a backend for ActiveRecord and Rails apps."
1515
spec.homepage = "https://github.com/cockroachdb/activerecord-cockroachdb-adapter"
1616

17-
spec.add_dependency "activerecord", "~> 8.1.0"
17+
spec.add_dependency "activerecord", "~> 8.1.0" unless ENV.key?("RAILS_TAG")
1818
spec.add_dependency "pg", "~> 1.5"
1919
spec.add_dependency "rgeo-activerecord", "~> 8.1.0"
2020

0 commit comments

Comments
 (0)