Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 73 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ on:
# Triggers the workflow on pull request events.
pull_request:
types: [opened, reopened, synchronize]

schedule:
- cron: 12 13 * * 1 # Weekly
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

Expand All @@ -19,7 +20,77 @@ concurrency:
cancel-in-progress: true

jobs:
# Since the name of the matrix job depends on the version, we define another job with a more stable name.
orchestrate:
runs-on: ubuntu-latest
name: Prepare Tests
outputs:
supported_crdbs: ${{ steps.crdb.outputs.crdbs }}
latest_crdb: ${{ steps.crdb.outputs.latest }}
steps:
- id: crdb
name: Determine Supported CockroachDB Versions
shell: ruby -rcsv -rjson -rnet/http -ruri {0}
run: |
p ENV["GITHUB_OUTPUT"]
link = "https://raw.githubusercontent.com/cockroachdb/docs/7c75d7596ae144c30f341b5b337b5775088f29df/src/current/_data/versions.csv"

uri = URI.parse(link)
data = Net::HTTP.get(uri)
csv = CSV.parse(data, headers: true)

versions = csv.filter_map do |row|
support = row["asst_supp_exp_date"]
support = row["maint_supp_exp_date"] if support == "N/A"

row["major_version"] if Date.parse(support) >= Date.today
end
p versions

File.write(ENV["GITHUB_OUTPUT"], "crdbs=#{JSON.generate(versions)}\n", mode: ?a)
File.write(ENV["GITHUB_OUTPUT"], "latest=#{JSON.generate(versions.max)}\n", mode: ?a)


puts File.read(ENV["GITHUB_OUTPUT"])

test:
runs-on: ubuntu-latest
needs: orchestrate
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
# https://www.cockroachlabs.com/docs/releases/release-support-policy
crdb: ${{ fromJSON(needs.orchestrate.outputs.supported_crdbs) }}
ruby: ["3.4"]
rails: ["8-1-stable"]
experimental: [false]
include:
- crdb: ${{ fromJSON(needs.orchestrate.outputs.latest_crdb) }}
ruby: "3.4"
rails: "main"
experimental: true
name: Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }} rails=${{ matrix.rails }})
steps:
- name: Set Up Actions
uses: actions/checkout@v4
- uses: ./.github/actions/test-runner
id: test
with:
crdb: ${{ matrix.crdb }}
ruby: ${{ matrix.ruby }}
env:
RAILS_TAG: ${{ matrix.rails }}
JSON_REPORTER: "report.json"
- name: Upload Report
if: ${{ failure() && steps.test.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: report-${{ matrix.crdb }}-${{ matrix.ruby }}
path: report.json
# Since the name of the matrix job depends on the
# version, we define another job with a more stable
# name. We also aggregate failed tests to display
# in the Github Summary.
test_results:
if: ${{ always() }}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -92,29 +163,3 @@ jobs:
echo '```json' >>$GITHUB_STEP_SUMMARY
jq --slurp --compact-output '.' reports/*/report.json >>$GITHUB_STEP_SUMMARY
echo '```' >>$GITHUB_STEP_SUMMARY

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# https://www.cockroachlabs.com/docs/releases/release-support-policy
crdb: [v24.3, v25.1, v25.2, v25.3]
ruby: ["3.4"]
name: Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }})
steps:
- name: Set Up Actions
uses: actions/checkout@v4
- uses: ./.github/actions/test-runner
id: test
with:
crdb: ${{ matrix.crdb }}
ruby: ${{ matrix.ruby }}
env:
JSON_REPORTER: "report.json"
- name: Upload Report
if: ${{ failure() && steps.test.conclusion == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: report-${{ matrix.crdb }}-${{ matrix.ruby }}
path: report.json
4 changes: 2 additions & 2 deletions .github/workflows/flaky.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ jobs:
name: Prepare Matrix
steps:
- id: generate-matrix
name: Generate Test Matrix
run: |
crdb=$(jq --raw-input --compact-output 'split(" ")' <<<"${{ github.event.inputs.crdb }}")
ruby=$(jq --raw-input --compact-output 'split(" ")' <<<"${{ github.event.inputs.ruby }}")
crdb_len=$(wc -w <<<"${{ github.event.inputs.crdb }}")
ruby_len=$(wc -w <<<"${{ github.event.inputs.ruby }}")
(( seeds_count = ${{github.event.inputs.max}} / ( crdb_len * ruby_len ) ))
seeds=$(shuf --input-range=1-65535 --head-count=$seeds_count | jq --slurp --compact-output)
echo $seeds
echo "crdb=$crdb" >> $GITHUB_OUTPUT
echo "ruby=$ruby" >> $GITHUB_OUTPUT
echo "seeds=$seeds" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
ruby: ${{ matrix.ruby }}
TESTOPTS: --fail-fast
env:
JSON_REPORTER: "report.json"
JSON_REPORTER: 'report.json'
SEED: ${{ matrix.seed }}
- name: Upload Report
if: ${{ failure() && steps.test.conclusion == 'failure' }}
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module RailsTag
def gemspec_requirement
File
.foreach(File.expand_path("activerecord-cockroachdb-adapter.gemspec", __dir__), chomp: true)
.find { _1[/add_dependency\s.activerecord.,\s.(.*)./] }
.find { _1[/add_dependency\s.activerecord.,\s["'](.*?)["']/] }

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

# Needed for the test suite
gem "msgpack", ">= 1.7.0"
Expand Down
2 changes: 1 addition & 1 deletion activerecord-cockroachdb-adapter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
spec.description = "Allows the use of CockroachDB as a backend for ActiveRecord and Rails apps."
spec.homepage = "https://github.com/cockroachdb/activerecord-cockroachdb-adapter"

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

Expand Down