Skip to content

Commit

Permalink
matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
BuonOmo committed Feb 18, 2024
1 parent 6ac23db commit 7d06e99
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
crdb: [v23.2.0]
# https://www.cockroachlabs.com/docs/releases/release-support-policy
crdb: [v22.2, v23.1, v23.2]
ruby: [head]
name: Test (crdb=${{ matrix.crdb }} ruby=${{ matrix.ruby }})
steps:
Expand All @@ -54,7 +56,12 @@ jobs:
- name: Install and Start Cockroachdb
run: |
# Download CockroachDB
wget -qO- https://binaries.cockroachdb.com/cockroach-${{ matrix.crdb }}.linux-amd64.tgz | tar xvz
readonly full_version_url=$(
wget -qO- https://www.cockroachlabs.com/docs/releases/${{ matrix.crdb }} |
grep -Eo 'https://binaries.cockroachdb.com/cockroach-v${{ matrix.crdb }}.\d+.linux-amd64.tgz' |
head -1
)
wget -qO- "$full_version_url" | tar xvz
export PATH=./cockroach-${{ matrix.crdb }}.linux-amd64/:$PATH
readonly urlfile=cockroach-url
Expand Down
2 changes: 1 addition & 1 deletion bin/start-cockroachdb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pid_file="$root_dir/tmp/cockroach.pid"
log_file="$root_dir/tmp/cockroachdb.log"

mkdir -p "$root_dir/tmp"
[[ -f "$pid_file" ]] && kill -9 $(cat "$pid_file")
[[ -f "$pid_file" ]] && kill -9 $(cat "$pid_file") || true
rm -f "$pid_file"

if ! (( ${+commands[cockroach]} )); then
Expand Down
12 changes: 12 additions & 0 deletions lib/active_record/connection_adapters/cockroachdb_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ def max_transaction_retries
@max_transaction_retries ||= @config.fetch(:max_transaction_retries, 3)
end

def get_database_version
major, minor, patch = query_value("SHOW crdb_version").match(/v(\d+).(\d+).(\d+)/)[1..].map(&:to_i)
major * 100 * 100 + minor * 100 + patch
end
undef :postgresql_version
alias :cockroachdb_version :database_version

def supports_datetime_with_precision?
# https://github.com/cockroachdb/cockroach/pull/111400
database_version >= 23_01_13
end

def supports_ddl_transactions?
false
end
Expand Down

0 comments on commit 7d06e99

Please sign in to comment.