Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI specs for CockroachDB #924

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
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
40 changes: 39 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Lint
run: ./bin/ameba

specs:
specs__postgresql:
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -77,3 +77,41 @@ jobs:
env:
BACKUP_DATABASE_URL: postgres://lucky:developer@localhost:5432/sample_backup
DATABASE_URL: postgres://lucky:developer@localhost:5432/avram_dev
specs__cocroachdb:
strategy:
fail-fast: false
matrix:
cockroachdb_version: [22.2.2]
crystal_version: [1.6.2]
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v2
- uses: crystal-lang/install-crystal@v1
with:
crystal: ${{matrix.crystal_version}}
- name: Install shards
run: shards install
- name: Install CockroachDB
run: |
sudo apt -y install tar wget
sudo mkdir -p /usr/local/lib/cockroach
wget https://binaries.cockroachdb.com/cockroach-v${{matrix.cockroachdb_version}}.linux-amd64.tgz
tar -xzf cockroach-v${{matrix.cockroachdb_version}}.linux-amd64.tgz
sudo cp -f cockroach-v${{matrix.cockroachdb_version}}.linux-amd64/cockroach /usr/local/bin/
sudo chmod +x /usr/local/bin/cockroach
sudo cp -rf cockroach-v${{matrix.cockroachdb_version}}.linux-amd64/lib/* /usr/local/lib/cockroach/
working-directory: /tmp
- name: Start CockroachDB
run: cockroach start-single-node --insecure --listen-addr=localhost:36257 --sql-addr=localhost:26257 --background
- name: Run integration test
run: ./script/integration_test
env:
DATABASE_TYPE: cockroachdb
DATABASE_URL: postgres://root@localhost:26257/avram_dev?sslmode=disable
- name: Run tests
run: crystal spec
env:
BACKUP_DATABASE_URL: postgres://root@localhost:26257/sample_backup?sslmode=disable
DATABASE_TYPE: cockroachdb
DATABASE_URL: postgres://root@localhost:26257/avram_dev?sslmode=disable
6 changes: 6 additions & 0 deletions config/database.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
database_name = "avram_dev"

module DbType
def self.cockroachdb?
ENV["DATABASE_TYPE"]? == "cockroachdb"
end
end

class TestDatabase < Avram::Database
end

Expand Down
4 changes: 2 additions & 2 deletions db/migrations/20180612221318_create_businesses.cr
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class CreateBusinesses::V20180612221318 < Avram::Migrator::Migration::V1
add_belongs_to business : Business, on_delete: :cascade
end

enable_extension "citext"
enable_extension "citext" unless DbType.cockroachdb?

create :email_addresses do
primary_key id : Int64
add_timestamps
add address : String, case_sensitive: false
add address : String, case_sensitive: DbType.cockroachdb?
add_belongs_to business : Business?, on_delete: :cascade
end
end
Expand Down