diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 43b8d78..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,92 +0,0 @@ -version: 2 -jobs: - build: - parallelism: 1 - working_directory: ~/ezcater - docker: - - image: circleci/ruby:2.7.5 - environment: - - PGHOST: 127.0.0.1 - - PGUSER: postgres - - image: circleci/postgres:11.3-alpine - environment: - - POSTGRES_USER: postgres - - POSTGRES_DB: postgres_pub_sub_test - steps: - - checkout - - # Restore bundle cache - - restore_cache: - keys: - - ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "activerecord-postgres_pub_sub.gemspec" }} - - ruby-cache-{{ arch }}-{{ .Branch }}- - - ruby-cache- - - - run: - name: Setup Code Climate test-reporter - command: | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 -o ./cc-test-reporter - chmod +x ./cc-test-reporter - - # Bundle install dependencies - - run: gem install bundler -v 1.17.3 --no-document - - run: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3 - - run: bundle clean --force - - run: bundle exec appraisal install - - # Install Postgres client - - run: sudo apt update && sudo apt install postgresql-client - - # Store bundle cache - - save_cache: - key: ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "activerecord-postgres_pub_sub.gemspec" }} - paths: - - vendor/bundle - - # Run Rubocop - - run: - name: RuboCop - command: bundle exec rubocop - - # Run tests for each appraisal - - run: - name: rails-5.2_pg-1.1 - command: | - bundle exec appraisal rails-5.2_pg-1.1 rspec --format RspecJunitFormatter --format progress - - - run: - name: rails-5.2_pg-1.2 - command: | - bundle exec appraisal rails-5.2_pg-1.2 rspec --format RspecJunitFormatter --format progress - - - run: - name: rails-6.0_pg-1.1 - command: | - bundle exec appraisal rails-6.0_pg-1.1 rspec --format RspecJunitFormatter --format progress - - - run: - name: rails-6.0_pg-1.2 - command: | - bundle exec appraisal rails-6.0_pg-1.2 rspec --format RspecJunitFormatter --format progress - - - run: - name: rails-6.1_pg-1.1 - command: | - bundle exec appraisal rails-6.1_pg-1.1 rspec --format RspecJunitFormatter --format progress - - - run: - name: rails-6.1_pg-1.2 - command: | - bundle exec appraisal rails-6.1_pg-1.2 rspec --format RspecJunitFormatter --format progress - - - run: - name: rails-7.0_pg-1.1 - command: | - bundle exec appraisal rails-7.0_pg-1.1 rspec --format RspecJunitFormatter --format progress - - - run: - name: rails-7.0_pg-1.2 - command: | - ./cc-test-reporter before-build - bundle exec appraisal rails-7.0_pg-1.2 rspec --format RspecJunitFormatter --format progress - ./cc-test-reporter after-build -t simplecov --exit-code $? || echo "Skipping test coverage reporting" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..837ca12 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,84 @@ +name: CI +on: + pull_request: + push: + branches: [ main ] + +env: + branch: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.ref || github.ref_name }} + +jobs: + lint: + name: Lint (Ruby ${{ matrix.ruby }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: [ '2.7' ] # FU: Build against common ruby 3.x minor versions + + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Install Ruby ${{ matrix.ruby }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + + - name: Install dependencies + run: bundle install + + - name: Run Rubocop + run: bundle exec rubocop + + test: + name: Test (Ruby ${{ matrix.ruby }}, activerecord ${{ matrix.activerecord }}, pg ${{ matrix.pg }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + activerecord: [ '6.1', '7.0' ] + pg: [ '1.1', '1.2' ] # FU: Build against common pg 1.x minor versions + ruby: [ '2.7' ] # FU: Build against common ruby 3.x minor versions + timeout-minutes: 10 + needs: + - lint + + env: + PGUSER: postgres + + services: + postgres: + image: postgres:11.3 # FU: Test against newer postgres image + env: + POSTGRES_USER: postgres + POSTGRES_DB: postgres_pub_sub_test + POSTGRES_HOST_AUTH_METHOD: trust + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Checkout the code + uses: actions/checkout@v4 + + - name: Install Ruby ${{ matrix.ruby }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + + - name: Install postgresql-client + run: sudo apt update && sudo apt install postgresql-client + + - name: Install dependencies + run: bundle install + + - name: Install appraisal + run: bundle exec appraisal install + + - name: Appraise rails-${{ matrix.activerecord }}_pg-${{ matrix.pg }} + run: bundle exec appraisal rails-${{ matrix.activerecord }}_pg-${{ matrix.pg }} rspec diff --git a/README.md b/README.md index 7851fff..5444bb0 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ # activerecord-postgres_pub_sub -[![CircleCI](https://circleci.com/gh/ezcater/activerecord-postgres_pub_sub.svg?style=svg)](https://circleci.com/gh/ezcater/activerecord-postgres_pub_sub) - This gem contains support for PostgreSQL LISTEN and NOTIFY functionality: [doc](https://www.postgresql.org/docs/9.6/static/libpq-notify.html). diff --git a/activerecord-postgres_pub_sub.gemspec b/activerecord-postgres_pub_sub.gemspec index 8632cde..6180e6e 100644 --- a/activerecord-postgres_pub_sub.gemspec +++ b/activerecord-postgres_pub_sub.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| raise "RubyGems 2.0 or newer is required to protect against public gem pushes." end - excluded_files = %w(.circleci/config.yml + excluded_files = %w(.github/workflows/ci.yml .github/PULL_REQUEST_TEMPLATE.md .gitignore .rspec diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d821c4b..6e85d1c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -32,11 +32,12 @@ puts "Testing with Postgres version: #{pg_version}" puts "Testing with ActiveRecord #{ActiveRecord::VERSION::STRING}" - `dropdb --if-exists #{DATABASE_NAME} 2> /dev/null` - `createdb #{DATABASE_NAME}` - host = ENV.fetch("PGHOST", "localhost") port = ENV.fetch("PGPORT", 5432) + + `dropdb -h #{host} -p #{port} --if-exists #{DATABASE_NAME} 2> /dev/null` + `createdb -h #{host} -p #{port} #{DATABASE_NAME}` + database_url = "postgres://#{host}:#{port}/#{DATABASE_NAME}" puts "Using database #{database_url}" ActiveRecord::Base.establish_connection(database_url)