From 06b31929d0d87d163532485aca0f9daff2cfeb14 Mon Sep 17 00:00:00 2001 From: Adam Hutchison Date: Mon, 25 Nov 2024 18:49:40 -0700 Subject: [PATCH 1/3] Update main workflow Add jobs for each driver to the main workflow, remove the old ruby workflow (that never worked), along with the TravisCI config (since it's no longer used). Also remove the Appraisals file since we're pinned to Rails 6.1. --- .github/workflows/main.yml | 103 ++++++++++++++++++++++++++++++++++--- .github/workflows/ruby.yml | 60 --------------------- .travis.yml | 15 ------ Appraisals | 17 ------ 4 files changed, 96 insertions(+), 99 deletions(-) delete mode 100644 .github/workflows/ruby.yml delete mode 100644 .travis.yml delete mode 100644 Appraisals diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f09d2e8..11b9075 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,17 +1,12 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. # This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake # For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby - -name: CI +name: build on: push: branches: [main] pull_request: - branches: [main] + branches: "*" jobs: style: @@ -24,3 +19,97 @@ jobs: ruby-version: "2.7" bundler-cache: true - run: bundle exec standardrb --format github + + test-mysql: + name: Tests (MySQL) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby-version: [2.7, jruby-9.4] + + services: + mysql: + image: mysql:5.7 + ports: + - 3306 + env: + JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M" + MYSQL_USER: root + MYSQL_PASSWORD: root + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Setup database + run: | + sudo service mysql start + - name: Run tests + run: | + bundle exec rake test:mysql2 + + test-pgsql: + name: Tests (Postgres) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby-version: [2.7, jruby-9.4] + + services: + postgres: + image: postgres:11 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_HOST_AUTH_METHOD: trust + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + env: + JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M" + PGHOST: localhost + PGPORT: 5432 + PGUSER: postgres + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Setup database + env: + PGPASSWORD: postgres + run: | + createdb spectacles_test + - name: Run tests + run: | + bundle exec rake test:postgresql + + test-sqlite: + name: Tests (SQLite) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby-version: [2.7, jruby-9.4] + + env: + JRUBY_OPTS: "-J-Xms64M -J-Xmx1024M" + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Run tests + run: | + bundle exec rake test:sqlite3 diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml deleted file mode 100644 index 51e7310..0000000 --- a/.github/workflows/ruby.yml +++ /dev/null @@ -1,60 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# GitHub recommends pinning actions to a commit SHA. -# To get a newer version, you will need to update the SHA. -# You can also reference a tag or branch, but the action may change without warning. - -name: Ruby CI - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - test_jruby_93: - runs-on: ubuntu-latest - - strategy: - matrix: - ruby-version: ['jruby-9.3','jruby-9.4','2.7','3.0','3.1'] - rails-version: ['rails-61'] - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 - with: - ruby-version: ${{ matrix.ruby-version }} - - name: Install dependencies - run: bundle install - - name: Generate gemfiles - run: bundle exec appraisal clean && bundle exec appraisal generate - - name: Install from appraisal gemfile - run: bundle exec appraisal ${{ matrix.rails-version }} bundle install --jobs=2 --retry=3 - - name: Run tests - run: bundle exec appraisal ${{ matrix.rails-version }} bundle exec rake - test: - runs-on: ubuntu-latest - - strategy: - matrix: - ruby-version: ['jruby-9.4','3.0','3.1'] - rails-version: ['rails-61','rails-70'] - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby ${{ matrix.ruby-version }} - uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1 - with: - ruby-version: ${{ matrix.ruby-version }} - - name: Install dependencies - run: bundle install - - name: Generate gemfiles - run: bundle exec appraisal clean && bundle exec appraisal generate - - name: Install from appraisal gemfile - run: bundle exec appraisal ${{ matrix.rails-version }} bundle install --jobs=2 --retry=3 - - name: Run tests - run: bundle exec appraisal ${{ matrix.rails-version }} bundle exec rake diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 342cfde..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: ruby -jdk: - - openjdk8 -rvm: - - 2.2 - - 2.3 - - 2.4 - - 2.5 - - 2.6 - - 2.7 - - jruby -cache: bundler -services: - - mysql - - postgresql diff --git a/Appraisals b/Appraisals deleted file mode 100644 index da8f080..0000000 --- a/Appraisals +++ /dev/null @@ -1,17 +0,0 @@ -appraise "rails-61" do - gem "activerecord", "~> 6.1", "< 6.2" - gem "protobuf-activerecord", ">= 6.1" - platforms :jruby do - gem "activerecord-jdbcpostgresql-adapter", ">= 61", "< 62" - gem "activerecord-jdbcsqlite3-adapter", ">= 61", "< 62" - end -end - -appraise "rails-70" do - gem "activerecord", "~> 7.0", "< 7.1" - gem "protobuf-activerecord", ">= 7.0" - platforms :jruby do - gem "activerecord-jdbcpostgresql-adapter", ">= 70", "< 72" - gem "activerecord-jdbcsqlite3-adapter", ">= 70", "< 72" - end -end From bac3b8c486b0ec80a39aa24176614a3915c58aae Mon Sep 17 00:00:00 2001 From: Adam Hutchison Date: Mon, 25 Nov 2024 19:30:54 -0700 Subject: [PATCH 2/3] Filter information_schema, pg_catalog from views Dumping views was failing because it was including views from the internal information_schema and pg_catalog schemas. Filter them to ensure we only get views we defined. https://neon.tech/postgresql/postgresql-views/postgresql-list-views --- lib/spectacles/schema_statements/postgresql_adapter.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/spectacles/schema_statements/postgresql_adapter.rb b/lib/spectacles/schema_statements/postgresql_adapter.rb index ea707b9..b95a47d 100644 --- a/lib/spectacles/schema_statements/postgresql_adapter.rb +++ b/lib/spectacles/schema_statements/postgresql_adapter.rb @@ -11,6 +11,7 @@ def views(name = nil) # :nodoc: FROM information_schema.views AS t INNER JOIN pg_class AS c ON c.relname = t.table_name AND c.relnamespace = to_regnamespace(t.table_schema)::oid WHERE t.table_schema = ANY(current_schemas(true)) + AND table_schema NOT IN ('information_schema', 'pg_catalog') AND pg_catalog.pg_get_userbyid(c.relowner) = #{quote(database_username)} SQL From d3b702061c06d688a822bcc54660674a4b39e020 Mon Sep 17 00:00:00 2001 From: Adam Hutchison Date: Mon, 25 Nov 2024 20:26:35 -0700 Subject: [PATCH 3/3] Allow public key retrieval for MySQL in JRuby Not sure why this is required for GitHub actions, but it is... --- specs/adapters/mysql2_adapter_spec.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/specs/adapters/mysql2_adapter_spec.rb b/specs/adapters/mysql2_adapter_spec.rb index d7a9b82..08d23ea 100644 --- a/specs/adapters/mysql2_adapter_spec.rb +++ b/specs/adapters/mysql2_adapter_spec.rb @@ -8,6 +8,11 @@ password: ENV["MYSQL_PASSWORD"] } + if defined? JRUBY_VERSION + config[:properties] ||= {} + config[:properties]["allowPublicKeyRetrieval"] = true + end + configure_database(config) recreate_database("spectacles_test") load_schema