diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 233ce45..30b9501 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: COVERAGE: "${{matrix.coverage}}" COVERAGE_TOKEN: "${{secrets.CODACY_PROJECT_TOKEN}}" APT_DEPS: libpq-dev libmysqlclient-dev libsqlite3-dev + DATABASE_URL: "postgres://runner:@localhost:5432/rom_factory" steps: - name: Checkout uses: actions/checkout@v1 diff --git a/.postgres.env b/.postgres.env new file mode 100644 index 0000000..0bafc02 --- /dev/null +++ b/.postgres.env @@ -0,0 +1,4 @@ +POSTGRES_USER="rom" +POSTGRES_PASSWORD="password" +POSTGRES_DATABASE="rom_factory" +POSTGRES_HOST_AUTH_METHOD="trust" diff --git a/Gemfile b/Gemfile index 19b6111..97a3264 100644 --- a/Gemfile +++ b/Gemfile @@ -10,11 +10,13 @@ gem "faker", "~> 3.0" gem "rspec", "~> 3.0" +gem "dotenv" + git "https://github.com/rom-rb/rom.git", branch: "release-5.3" do - gem "rom-core" + gem "rom" gem "rom-changeset" + gem "rom-core" gem "rom-repository" - gem "rom" end group :test do diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..38edacf --- /dev/null +++ b/compose.yml @@ -0,0 +1,7 @@ +--- +services: + db: + image: postgres + ports: + - 5432 + env_file: .postgres.env diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b169824..3e60e74 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true require_relative "support/coverage" +require "dotenv" +Dotenv.load(".postgres.env", ".env") require "pathname" SPEC_ROOT = root = Pathname(__FILE__).dirname @@ -18,10 +20,16 @@ end DB_URI = ENV.fetch("DATABASE_URL") do + auth = ENV.values_at("POSTGRES_USER", "POSTGRES_PASSWORD").join(":") + address = `docker compose port db 5432 2> /dev/null`.strip + address = [auth, address].join("@") if address + + address ||= "localhost" + if defined? JRUBY_VERSION - "jdbc:postgresql://localhost/rom_factory" + "jdbc:postgresql://#{address}" else - "postgres://localhost/rom_factory" + "postgres://#{address}" end end