From ee49995f4c3d17ca2bbd2d01f7892e3e680f93f7 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sun, 14 Apr 2024 21:33:12 +1000 Subject: [PATCH 01/23] push generated code --- .github/workflows/master.yml | 41 ++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 7766fb35..78caa666 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -4,26 +4,39 @@ on: push: branches: - master - pull_request: jobs: build: runs-on: ubuntu-latest - name: Ruby ${{ matrix.ruby }} + name: Ruby ${{ matrix.ruby }} with ${{ matrix.database }} strategy: matrix: ruby: - '3.3.0' + include: + - database: 'PostgreSQL' + db_image: 'postgres:latest' + db_env: + POSTGRES_USER: outboxer_developer + POSTGRES_PASSWORD: outboxer_password + POSTGRES_DB: outboxer_test + - database: 'MySQL' + db_image: 'mysql:latest' + db_env: + MYSQL_ROOT_PASSWORD: password + MYSQL_DATABASE: outboxer_test + - database: 'MariaDB' + db_image: 'mariadb:latest' + db_env: + MARIADB_ROOT_PASSWORD: password + MARIADB_DATABASE: outboxer_test services: - postgres: - image: postgres:latest - env: - POSTGRES_USER: outboxer_developer - POSTGRES_PASSWORD: outboxer_password - POSTGRES_DB: outboxer_test - ports: ['5432:5432'] - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + db: + image: ${{ matrix.db_image }} + env: ${{ matrix.db_env }} + ports: ['3306:3306'] + options: --health-cmd "mysqladmin ping -h localhost" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v3 - name: Set up Ruby @@ -31,11 +44,11 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - - name: Check PostgreSQL + - name: Check Database run: | - sudo apt-get -qq install -y postgresql-client - export PGPASSWORD=outboxer_password - psql -h localhost -U outboxer_developer -d outboxer_test -c 'SELECT version();' + sudo apt-get -qq install -y mysql-client + export MYSQL_PWD=${{ matrix.db_env.MYSQL_ROOT_PASSWORD || matrix.db_env.MARIADB_ROOT_PASSWORD }} + mysql -h 127.0.0.1 -u root -e "SHOW DATABASES;" - name: Run Database Migrations run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run the default task From e78d78e2607da22cbb60b352734311bda9ca6635 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Mon, 15 Apr 2024 20:48:48 +1000 Subject: [PATCH 02/23] add db specific config --- .github/workflows/master.yml | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 78caa666..a652b488 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -21,22 +21,28 @@ jobs: POSTGRES_USER: outboxer_developer POSTGRES_PASSWORD: outboxer_password POSTGRES_DB: outboxer_test + db_port: ['5432:5432'] + health_cmd: 'pg_isready -U outboxer_developer' - database: 'MySQL' db_image: 'mysql:latest' db_env: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: outboxer_test + db_port: ['3306:3306'] + health_cmd: 'mysqladmin ping -h localhost' - database: 'MariaDB' db_image: 'mariadb:latest' db_env: MARIADB_ROOT_PASSWORD: password MARIADB_DATABASE: outboxer_test + db_port: ['3306:3306'] + health_cmd: 'mysqladmin ping -h localhost' services: db: image: ${{ matrix.db_image }} env: ${{ matrix.db_env }} - ports: ['3306:3306'] - options: --health-cmd "mysqladmin ping -h localhost" --health-interval 10s --health-timeout 5s --health-retries 5 + ports: ${{ matrix.db_port }} + options: --health-cmd "${{ matrix.health_cmd }}" --health-interval 10s --health-timeout 5s --health-retries 5 steps: - uses: actions/checkout@v3 - name: Set up Ruby @@ -46,9 +52,23 @@ jobs: bundler-cache: true - name: Check Database run: | - sudo apt-get -qq install -y mysql-client - export MYSQL_PWD=${{ matrix.db_env.MYSQL_ROOT_PASSWORD || matrix.db_env.MARIADB_ROOT_PASSWORD }} - mysql -h 127.0.0.1 -u root -e "SHOW DATABASES;" + case "${{ matrix.database }}" in + PostgreSQL) + sudo apt-get -qq install -y postgresql-client + export PGPASSWORD=$DB_PASSWORD + psql -h localhost -U $DB_USER -d $DB_NAME -c 'SELECT version();' + ;; + MySQL) + sudo apt-get -qq install -y mysql-client + export MYSQL_PWD=$DB_PASSWORD + mysql -h 127.0.0.1 -u $DB_USER --password=$DB_PASSWORD -D $DB_NAME -e "SHOW DATABASES;" + ;; + MariaDB) + sudo apt-get -qq install -y mariadb-client + export MYSQL_PWD=$DB_PASSWORD + mysql -h 127.0.0.1 -u $DB_USER --password=$DB_PASSWORD -D $DB_NAME -e "SHOW DATABASES;" + ;; + esac - name: Run Database Migrations run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run the default task From 2a8b26b2239e7b15da9ac5f3f5b6a9f511ae4963 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:06:44 +1000 Subject: [PATCH 03/23] comment non psql --- .github/workflows/master.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index a652b488..2a249bdf 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -23,20 +23,6 @@ jobs: POSTGRES_DB: outboxer_test db_port: ['5432:5432'] health_cmd: 'pg_isready -U outboxer_developer' - - database: 'MySQL' - db_image: 'mysql:latest' - db_env: - MYSQL_ROOT_PASSWORD: password - MYSQL_DATABASE: outboxer_test - db_port: ['3306:3306'] - health_cmd: 'mysqladmin ping -h localhost' - - database: 'MariaDB' - db_image: 'mariadb:latest' - db_env: - MARIADB_ROOT_PASSWORD: password - MARIADB_DATABASE: outboxer_test - db_port: ['3306:3306'] - health_cmd: 'mysqladmin ping -h localhost' services: db: image: ${{ matrix.db_image }} From de7fd2747ffd622612e9985e86014fb0272b0d5a Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:11:00 +1000 Subject: [PATCH 04/23] try again --- .github/workflows/master.yml | 72 +++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 2a249bdf..e89b1875 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -4,31 +4,44 @@ on: push: branches: - master + pull_request: jobs: build: runs-on: ubuntu-latest - name: Ruby ${{ matrix.ruby }} with ${{ matrix.database }} + name: Ruby ${{ matrix.ruby }} strategy: matrix: ruby: - '3.3.0' - include: - - database: 'PostgreSQL' - db_image: 'postgres:latest' - db_env: - POSTGRES_USER: outboxer_developer - POSTGRES_PASSWORD: outboxer_password - POSTGRES_DB: outboxer_test - db_port: ['5432:5432'] - health_cmd: 'pg_isready -U outboxer_developer' + database: + - postgres + - mysql services: - db: - image: ${{ matrix.db_image }} - env: ${{ matrix.db_env }} - ports: ${{ matrix.db_port }} - options: --health-cmd "${{ matrix.health_cmd }}" --health-interval 10s --health-timeout 5s --health-retries 5 + postgres: + image: postgres:latest + env: + POSTGRES_USER: outboxer_developer + POSTGRES_PASSWORD: outboxer_password + POSTGRES_DB: outboxer_test + ports: ['5432:5432'] + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + if: matrix.database == 'postgres' + mysql: + image: mysql:latest + env: + MYSQL_ROOT_PASSWORD: outboxer_password + MYSQL_DATABASE: outboxer_test + MYSQL_USER: outboxer_developer + MYSQL_PASSWORD: outboxer_password + ports: ['3306:3306'] + options: >- + --health-cmd='mysqladmin ping' + --health-interval=10s + --health-timeout=5s + --health-retries=5 + if: matrix.database == 'mysql' steps: - uses: actions/checkout@v3 - name: Set up Ruby @@ -38,24 +51,17 @@ jobs: bundler-cache: true - name: Check Database run: | - case "${{ matrix.database }}" in - PostgreSQL) - sudo apt-get -qq install -y postgresql-client - export PGPASSWORD=$DB_PASSWORD - psql -h localhost -U $DB_USER -d $DB_NAME -c 'SELECT version();' - ;; - MySQL) - sudo apt-get -qq install -y mysql-client - export MYSQL_PWD=$DB_PASSWORD - mysql -h 127.0.0.1 -u $DB_USER --password=$DB_PASSWORD -D $DB_NAME -e "SHOW DATABASES;" - ;; - MariaDB) - sudo apt-get -qq install -y mariadb-client - export MYSQL_PWD=$DB_PASSWORD - mysql -h 127.0.0.1 -u $DB_USER --password=$DB_PASSWORD -D $DB_NAME -e "SHOW DATABASES;" - ;; - esac + if [ "${{ matrix.database }}" == "postgres" ]; then + sudo apt-get -qq install -y postgresql-client + export PGPASSWORD=outboxer_password + psql -h localhost -U outboxer_developer -d outboxer_test -c 'SELECT version();' + else + sudo apt-get -qq install -y mysql-client + export MYSQL_PWD=outboxer_password + mysql -h localhost -u outboxer_developer outboxer_test -e 'SELECT VERSION();' + fi - name: Run Database Migrations - run: RAILS_ENV=test bin/rake outboxer:db:migrate + run: | + RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run the default task run: RAILS_ENV=test bin/rspec spec From 5c6667c3e9c3a15cce27b588c90013de325962c8 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:21:16 +1000 Subject: [PATCH 05/23] try again --- .github/workflows/master.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index e89b1875..0438b2c5 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -10,7 +10,7 @@ on: jobs: build: runs-on: ubuntu-latest - name: Ruby ${{ matrix.ruby }} + name: Ruby ${{ matrix.ruby }} with ${{ matrix.database }} strategy: matrix: ruby: @@ -25,9 +25,10 @@ jobs: POSTGRES_USER: outboxer_developer POSTGRES_PASSWORD: outboxer_password POSTGRES_DB: outboxer_test - ports: ['5432:5432'] + ports: + - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - if: matrix.database == 'postgres' + if: ${{ matrix.database == 'postgres' }} mysql: image: mysql:latest env: @@ -35,13 +36,14 @@ jobs: MYSQL_DATABASE: outboxer_test MYSQL_USER: outboxer_developer MYSQL_PASSWORD: outboxer_password - ports: ['3306:3306'] + ports: + - 3306:3306 options: >- --health-cmd='mysqladmin ping' --health-interval=10s --health-timeout=5s --health-retries=5 - if: matrix.database == 'mysql' + if: ${{ matrix.database == 'mysql' }} steps: - uses: actions/checkout@v3 - name: Set up Ruby @@ -55,13 +57,17 @@ jobs: sudo apt-get -qq install -y postgresql-client export PGPASSWORD=outboxer_password psql -h localhost -U outboxer_developer -d outboxer_test -c 'SELECT version();' - else + elif [ "${{ matrix.database }}" == "mysql" ]; then sudo apt-get -qq install -y mysql-client export MYSQL_PWD=outboxer_password mysql -h localhost -u outboxer_developer outboxer_test -e 'SELECT VERSION();' fi - name: Run Database Migrations run: | - RAILS_ENV=test bin/rake outboxer:db:migrate - - name: Run the default task + if [ "${{ matrix.database }}" == "postgres" ]; then + RAILS_ENV=test bin/rake db:migrate + elif [ "${{ matrix.database }}" == "mysql" ]; then + RAILS_ENV=test bin/rake db:migrate + fi + - name: Run Tests run: RAILS_ENV=test bin/rspec spec From 491d582f1b15128f428e14c12ecceaf9dc3867e0 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:23:11 +1000 Subject: [PATCH 06/23] try again --- .github/workflows/master.yml | 56 ++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 0438b2c5..9156cf29 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -4,20 +4,16 @@ on: push: branches: - master - pull_request: jobs: - build: + postgres: runs-on: ubuntu-latest - name: Ruby ${{ matrix.ruby }} with ${{ matrix.database }} + name: Ruby ${{ matrix.ruby }} with PostgreSQL strategy: matrix: ruby: - '3.3.0' - database: - - postgres - - mysql services: postgres: image: postgres:latest @@ -28,7 +24,31 @@ jobs: ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - if: ${{ matrix.database == 'postgres' }} + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Check PostgreSQL + run: | + sudo apt-get -qq install -y postgresql-client + export PGPASSWORD=outboxer_password + psql -h localhost -U outboxer_developer -d outboxer_test -c 'SELECT version();' + - name: Run Database Migrations + run: RAILS_ENV=test bin/rake db:migrate + - name: Run Tests + run: RAILS_ENV=test bin/rspec spec + + mysql: + runs-on: ubuntu-latest + name: Ruby ${{ matrix.ruby }} with MySQL + strategy: + matrix: + ruby: + - '3.3.0' + services: mysql: image: mysql:latest env: @@ -43,7 +63,6 @@ jobs: --health-interval=10s --health-timeout=5s --health-retries=5 - if: ${{ matrix.database == 'mysql' }} steps: - uses: actions/checkout@v3 - name: Set up Ruby @@ -51,23 +70,12 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - - name: Check Database + - name: Check MySQL run: | - if [ "${{ matrix.database }}" == "postgres" ]; then - sudo apt-get -qq install -y postgresql-client - export PGPASSWORD=outboxer_password - psql -h localhost -U outboxer_developer -d outboxer_test -c 'SELECT version();' - elif [ "${{ matrix.database }}" == "mysql" ]; then - sudo apt-get -qq install -y mysql-client - export MYSQL_PWD=outboxer_password - mysql -h localhost -u outboxer_developer outboxer_test -e 'SELECT VERSION();' - fi + sudo apt-get -qq install -y mysql-client + export MYSQL_PWD=outboxer_password + mysql -h localhost -u outboxer_developer outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations - run: | - if [ "${{ matrix.database }}" == "postgres" ]; then - RAILS_ENV=test bin/rake db:migrate - elif [ "${{ matrix.database }}" == "mysql" ]; then - RAILS_ENV=test bin/rake db:migrate - fi + run: RAILS_ENV=test bin/rake db:migrate - name: Run Tests run: RAILS_ENV=test bin/rspec spec From 044d6d547744d4bb8c48041efd3ca89537924b08 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:28:02 +1000 Subject: [PATCH 07/23] retry --- .github/workflows/master.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 9156cf29..6c051ff6 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -37,7 +37,7 @@ jobs: export PGPASSWORD=outboxer_password psql -h localhost -U outboxer_developer -d outboxer_test -c 'SELECT version();' - name: Run Database Migrations - run: RAILS_ENV=test bin/rake db:migrate + run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run Tests run: RAILS_ENV=test bin/rspec spec @@ -59,7 +59,7 @@ jobs: ports: - 3306:3306 options: >- - --health-cmd='mysqladmin ping' + --health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=5s --health-retries=5 @@ -76,6 +76,6 @@ jobs: export MYSQL_PWD=outboxer_password mysql -h localhost -u outboxer_developer outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations - run: RAILS_ENV=test bin/rake db:migrate + run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run Tests run: RAILS_ENV=test bin/rspec spec From ce9eaa89ebe33c776fc57e941263b6c8da31b7f2 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:31:48 +1000 Subject: [PATCH 08/23] retry --- .github/workflows/master.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 6c051ff6..fa16a351 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -74,7 +74,8 @@ jobs: run: | sudo apt-get -qq install -y mysql-client export MYSQL_PWD=outboxer_password - mysql -h localhost -u outboxer_developer outboxer_test -e 'SELECT VERSION();' + mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' + - name: Run Database Migrations run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run Tests From aadd13bed02f3fde5d7857f4b764c68416ee7bb2 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:33:51 +1000 Subject: [PATCH 09/23] retry --- .github/workflows/master.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index fa16a351..ffd83d47 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -57,7 +57,7 @@ jobs: MYSQL_USER: outboxer_developer MYSQL_PASSWORD: outboxer_password ports: - - 3306:3306 + - 5432:5432 options: >- --health-cmd="mysqladmin ping --silent" --health-interval=10s @@ -74,8 +74,7 @@ jobs: run: | sudo apt-get -qq install -y mysql-client export MYSQL_PWD=outboxer_password - mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - + mysql -h 127.0.0.1 -P 5432 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run Tests From 3a087799c1a14bd6211f9009a7b17f69d24c8655 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:35:37 +1000 Subject: [PATCH 10/23] retry --- .github/workflows/master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index ffd83d47..6bbe051f 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -74,7 +74,7 @@ jobs: run: | sudo apt-get -qq install -y mysql-client export MYSQL_PWD=outboxer_password - mysql -h 127.0.0.1 -P 5432 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' + mysql -h localhost -P 5432 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run Tests From 5b145a1c15c7029cc79d0e21bd93fbb3b98f0b53 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:43:09 +1000 Subject: [PATCH 11/23] update --- .github/workflows/master.yml | 8 ++++++-- config/database.yml | 12 ++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 6bbe051f..066863b7 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -18,6 +18,8 @@ jobs: postgres: image: postgres:latest env: + DATABASE_ADAPTER: postgresql + DATABASE_PORT: 5432 POSTGRES_USER: outboxer_developer POSTGRES_PASSWORD: outboxer_password POSTGRES_DB: outboxer_test @@ -52,12 +54,14 @@ jobs: mysql: image: mysql:latest env: + DATABASE_ADAPTER: mysql2 + DATABASE_PORT: 3306 MYSQL_ROOT_PASSWORD: outboxer_password MYSQL_DATABASE: outboxer_test MYSQL_USER: outboxer_developer MYSQL_PASSWORD: outboxer_password ports: - - 5432:5432 + - 3306:3306 options: >- --health-cmd="mysqladmin ping --silent" --health-interval=10s @@ -74,7 +78,7 @@ jobs: run: | sudo apt-get -qq install -y mysql-client export MYSQL_PWD=outboxer_password - mysql -h localhost -P 5432 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' + mysql -h localhost -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run Tests diff --git a/config/database.yml b/config/database.yml index 345bd188..6ee53806 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,19 +1,19 @@ development: - adapter: postgresql + adapter: <%= ENV.fetch('DATABASE_ADAPTER') { postgresql } %> encoding: unicode host: localhost - port: 5432 + port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %> username: outboxer_developer password: outboxer_password database: outboxer_development - pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 26 } %> + pool: <%= ENV.fetch('DATABASE_POOL') { 5 } %> test: - adapter: postgresql + adapter: <%= ENV.fetch('DATABASE_ADAPTER') { postgresql } %> encoding: unicode host: localhost - port: 5432 + port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %> username: outboxer_developer password: outboxer_password database: outboxer_test - pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 26 } %> + pool: <%= ENV.fetch('DATABASE_POOL') { 5 } %> From 5c832d4b7e70d2a8c0cb7e2c955e4a106fb4ad71 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 04:59:33 +1000 Subject: [PATCH 12/23] push up --- Gemfile | 2 +- config/database.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 052f995c..9cf6f02c 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ gem "rubocop", "~> 1.55" gem "yard", "~> 0.9.34" -gem "pg", "~> 1.5" +gem 'mysql2', '~> 0.5.6' gem "activerecord", "~> 7.1", ">= 7.1.2" gem "sidekiq", "~> 7.2" diff --git a/config/database.yml b/config/database.yml index 6ee53806..cde24933 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,5 +1,5 @@ development: - adapter: <%= ENV.fetch('DATABASE_ADAPTER') { postgresql } %> + adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %> encoding: unicode host: localhost port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %> @@ -9,7 +9,7 @@ development: pool: <%= ENV.fetch('DATABASE_POOL') { 5 } %> test: - adapter: <%= ENV.fetch('DATABASE_ADAPTER') { postgresql } %> + adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %> encoding: unicode host: localhost port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %> From 99df38f8fad84585708a3f8d4c9e7a810ea5d514 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 05:03:51 +1000 Subject: [PATCH 13/23] add mysql gem --- Gemfile | 1 + Gemfile.lock | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 9cf6f02c..d1168d1b 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem "rubocop", "~> 1.55" gem "yard", "~> 0.9.34" +gem "pg", "~> 1.5" gem 'mysql2', '~> 0.5.6' gem "activerecord", "~> 7.1", ">= 7.1.2" diff --git a/Gemfile.lock b/Gemfile.lock index f9a03fc4..0ea36c40 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,6 +75,7 @@ GEM method_source (1.0.0) minitest (5.20.0) mutex_m (0.2.0) + mysql2 (0.5.6) nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) nokogiri (1.16.2-x86_64-darwin) @@ -85,7 +86,7 @@ GEM parser (3.2.2.3) ast (~> 2.4.1) racc - pg (1.5.3) + pg (1.5.6) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -162,6 +163,7 @@ DEPENDENCIES database_cleaner (~> 2.0, >= 2.0.2) factory_bot (~> 6.4, >= 6.4.6) foreman (~> 0.87.2) + mysql2 (~> 0.5.6) outboxer! pg (~> 1.5) pry-byebug (~> 3.10) From 8d213d5680449c1e55008e05b37979e4751c0331 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 05:06:23 +1000 Subject: [PATCH 14/23] try http --- .github/workflows/master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 066863b7..4eeed4a2 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -78,7 +78,7 @@ jobs: run: | sudo apt-get -qq install -y mysql-client export MYSQL_PWD=outboxer_password - mysql -h localhost -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' + mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations run: RAILS_ENV=test bin/rake outboxer:db:migrate - name: Run Tests From 6ff33792fad87515b4713c2660e312128ca6eaf9 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 05:27:27 +1000 Subject: [PATCH 15/23] fix bugs --- .github/workflows/master.yml | 4 ++-- config/database.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 4eeed4a2..fca64cc0 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -80,6 +80,6 @@ jobs: export MYSQL_PWD=outboxer_password mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations - run: RAILS_ENV=test bin/rake outboxer:db:migrate + run: RAILS_ENV=test DATABASE_PORT=3306 bin/rake outboxer:db:migrate - name: Run Tests - run: RAILS_ENV=test bin/rspec spec + run: RAILS_ENV=test DATABASE_PORT=3306 bin/rspec spec diff --git a/config/database.yml b/config/database.yml index cde24933..fb0cc2f2 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,6 +1,6 @@ development: adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %> - encoding: unicode + encoding: utf8 host: localhost port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %> username: outboxer_developer @@ -10,7 +10,7 @@ development: test: adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %> - encoding: unicode + encoding: utf8 host: localhost port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %> username: outboxer_developer From 6abd76d5e2d44a42b764953c938bce99cd9374ff Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 05:30:15 +1000 Subject: [PATCH 16/23] fix database adapter --- .github/workflows/master.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index fca64cc0..0656ce54 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -80,6 +80,6 @@ jobs: export MYSQL_PWD=outboxer_password mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations - run: RAILS_ENV=test DATABASE_PORT=3306 bin/rake outboxer:db:migrate + run: RAILS_ENV=test DATABASE_PORT=3306 DATABASE_ADAPTER=mysql2 bin/rake outboxer:db:migrate - name: Run Tests - run: RAILS_ENV=test DATABASE_PORT=3306 bin/rspec spec + run: RAILS_ENV=test DATABASE_PORT=3306 DATABASE_ADAPTER=mysql2 bin/rspec spec From ba2a7f176938c336609c59e4b16b568d139ce12c Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 05:34:51 +1000 Subject: [PATCH 17/23] add DATABASE_HOST --- .github/workflows/master.yml | 4 ++-- config/database.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 0656ce54..869c1cf5 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -80,6 +80,6 @@ jobs: export MYSQL_PWD=outboxer_password mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations - run: RAILS_ENV=test DATABASE_PORT=3306 DATABASE_ADAPTER=mysql2 bin/rake outboxer:db:migrate + run: RAILS_ENV=test DATABASE_PORT=3306 DATABASE_ADAPTER=mysql2 DATABASE_HOST=127.0.0.1 bin/rake outboxer:db:migrate - name: Run Tests - run: RAILS_ENV=test DATABASE_PORT=3306 DATABASE_ADAPTER=mysql2 bin/rspec spec + run: RAILS_ENV=test DATABASE_PORT=3306 DATABASE_ADAPTER=mysql2 DATABASE_HOST=127.0.0.1 bin/rspec spec diff --git a/config/database.yml b/config/database.yml index fb0cc2f2..6a8c6a97 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,7 +1,7 @@ development: adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %> encoding: utf8 - host: localhost + host: <%= ENV.fetch('DATABASE_HOST') { 'localhost' } %> port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %> username: outboxer_developer password: outboxer_password @@ -11,7 +11,7 @@ development: test: adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %> encoding: utf8 - host: localhost + host: <%= ENV.fetch('DATABASE_HOST') { 'localhost' } %> port: <%= ENV.fetch('DATABASE_PORT') { 5432 } %> username: outboxer_developer password: outboxer_password From e706feac6b2dac4a91305639c351faa0d85f629e Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 05:42:29 +1000 Subject: [PATCH 18/23] fix bug inreset pk --- spec/spec_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 57ff2444..f697f712 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -31,7 +31,9 @@ DatabaseCleaner.clean ActiveRecord::Base.connection.tables.each do |table| - ActiveRecord::Base.connection.reset_pk_sequence!(table) + if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' + ActiveRecord::Base.connection.reset_pk_sequence!(table) + end end rescue ActiveRecord::DatabaseConnectionError, ActiveRecord::ConnectionNotEstablished, From f745ea4ab2e1e22e71f3402049e1339a1747f56d Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 05:46:20 +1000 Subject: [PATCH 19/23] use env --- .github/workflows/master.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 869c1cf5..da8065ac 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -80,6 +80,16 @@ jobs: export MYSQL_PWD=outboxer_password mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - name: Run Database Migrations - run: RAILS_ENV=test DATABASE_PORT=3306 DATABASE_ADAPTER=mysql2 DATABASE_HOST=127.0.0.1 bin/rake outboxer:db:migrate + env: + RAILS_ENV: test + DATABASE_PORT: 3306 + DATABASE_ADAPTER: mysql2 + DATABASE_HOST: 127.0.0.1 + run: bin/rake outboxer:db:migrate - name: Run Tests - run: RAILS_ENV=test DATABASE_PORT=3306 DATABASE_ADAPTER=mysql2 DATABASE_HOST=127.0.0.1 bin/rspec spec + env: + RAILS_ENV: test + DATABASE_PORT: 3306 + DATABASE_ADAPTER: mysql2 + DATABASE_HOST: 127.0.0.1 + run: bin/rspec spec From 51974ea789a9cd40d3b54734747817362d7483e8 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 06:06:42 +1000 Subject: [PATCH 20/23] fix rake tasks for mysql --- .github/workflows/master.yml | 9 ++++++--- tasks/database.rake | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index da8065ac..1c344e71 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -82,14 +82,17 @@ jobs: - name: Run Database Migrations env: RAILS_ENV: test - DATABASE_PORT: 3306 DATABASE_ADAPTER: mysql2 DATABASE_HOST: 127.0.0.1 - run: bin/rake outboxer:db:migrate + DATABASE_PORT: 3306 + DATABASE_NAME_DEFAULT: 'mysql' + run: | + bin/rake outboxer:db:create + bin/rake outboxer:db:migrate - name: Run Tests env: RAILS_ENV: test - DATABASE_PORT: 3306 DATABASE_ADAPTER: mysql2 + DATABASE_PORT: 3306 DATABASE_HOST: 127.0.0.1 run: bin/rspec spec diff --git a/tasks/database.rake b/tasks/database.rake index a3cb3784..4b412a4b 100644 --- a/tasks/database.rake +++ b/tasks/database.rake @@ -7,18 +7,20 @@ namespace :outboxer do namespace :db do task :drop do environment = ENV['RAILS_ENV'] || 'development' + database_name = ENV['DATABASE_NAME_DEFAULT'] || 'postgres' db_config = Outboxer::Database.config(environment: environment) - ActiveRecord::Base.establish_connection(db_config.merge('database' => 'postgres')) + ActiveRecord::Base.establish_connection(db_config.merge('database' => database_name)) ActiveRecord::Base.connection.drop_database(db_config['database']) ActiveRecord::Base.connection.disconnect! end task :create do environment = ENV['RAILS_ENV'] || 'development' + database_name = ENV['DATABASE_NAME_DEFAULT'] || 'postgres' db_config = Outboxer::Database.config(environment: environment) - ActiveRecord::Base.establish_connection(db_config.merge('database' => 'postgres')) + ActiveRecord::Base.establish_connection(db_config.merge('database' => database_name)) ActiveRecord::Base.connection.create_database(db_config['database']) ActiveRecord::Base.connection.disconnect! end From 641010c2a9897129ebab184b46946e684ae0f8a7 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 06:14:19 +1000 Subject: [PATCH 21/23] fix build --- .github/workflows/master.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 1c344e71..0fc653a1 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -85,7 +85,7 @@ jobs: DATABASE_ADAPTER: mysql2 DATABASE_HOST: 127.0.0.1 DATABASE_PORT: 3306 - DATABASE_NAME_DEFAULT: 'mysql' + DATABASE_NAME_DEFAULT: 'postgres' run: | bin/rake outboxer:db:create bin/rake outboxer:db:migrate From 62302ed48b5308a3d2f27b93e7bbbcf111103a3d Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 06:17:20 +1000 Subject: [PATCH 22/23] dump database --- .github/workflows/master.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 0fc653a1..fc79f0b0 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -79,6 +79,7 @@ jobs: sudo apt-get -qq install -y mysql-client export MYSQL_PWD=outboxer_password mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' + mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SHOW DATABASES;' - name: Run Database Migrations env: RAILS_ENV: test From d9cf5fe9982759db0933cab37a77e121ab07c6e0 Mon Sep 17 00:00:00 2001 From: bedrock-adam Date: Sat, 20 Apr 2024 06:21:44 +1000 Subject: [PATCH 23/23] pass build --- .github/workflows/master.yml | 3 --- tasks/database.rake | 6 ++---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index fc79f0b0..39a0338a 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -79,16 +79,13 @@ jobs: sudo apt-get -qq install -y mysql-client export MYSQL_PWD=outboxer_password mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SELECT VERSION();' - mysql -h 127.0.0.1 -P 3306 -u outboxer_developer -poutboxer_password outboxer_test -e 'SHOW DATABASES;' - name: Run Database Migrations env: RAILS_ENV: test DATABASE_ADAPTER: mysql2 DATABASE_HOST: 127.0.0.1 DATABASE_PORT: 3306 - DATABASE_NAME_DEFAULT: 'postgres' run: | - bin/rake outboxer:db:create bin/rake outboxer:db:migrate - name: Run Tests env: diff --git a/tasks/database.rake b/tasks/database.rake index 4b412a4b..a3cb3784 100644 --- a/tasks/database.rake +++ b/tasks/database.rake @@ -7,20 +7,18 @@ namespace :outboxer do namespace :db do task :drop do environment = ENV['RAILS_ENV'] || 'development' - database_name = ENV['DATABASE_NAME_DEFAULT'] || 'postgres' db_config = Outboxer::Database.config(environment: environment) - ActiveRecord::Base.establish_connection(db_config.merge('database' => database_name)) + ActiveRecord::Base.establish_connection(db_config.merge('database' => 'postgres')) ActiveRecord::Base.connection.drop_database(db_config['database']) ActiveRecord::Base.connection.disconnect! end task :create do environment = ENV['RAILS_ENV'] || 'development' - database_name = ENV['DATABASE_NAME_DEFAULT'] || 'postgres' db_config = Outboxer::Database.config(environment: environment) - ActiveRecord::Base.establish_connection(db_config.merge('database' => database_name)) + ActiveRecord::Base.establish_connection(db_config.merge('database' => 'postgres')) ActiveRecord::Base.connection.create_database(db_config['database']) ActiveRecord::Base.connection.disconnect! end