From dd9df1756675028860142db13d2d1332613fe5e1 Mon Sep 17 00:00:00 2001 From: pawurb Date: Sat, 19 Aug 2023 18:58:17 +0200 Subject: [PATCH] Use GH actions for CI --- .circleci/config.yml | 30 ------------------------- .github/workflows/ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++ README.md | 2 +- 3 files changed, 49 insertions(+), 31 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/ci.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 7416056..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,30 +0,0 @@ -version: 2 -jobs: - test: - docker: - - image: circleci/ruby:2.6.5 - environment: - DATABASE_URL: postgresql://postgres:secret@localhost:5432/activerecord-analyze-test - - image: cimg/postgres:12.10 - environment: - POSTGRES_USER: postgres - POSTGRES_DB: activerecord-analyze-test - POSTGRES_PASSWORD: secret - parallelism: 1 - steps: - - checkout - - run: gem update --system - - run: gem install bundler - - run: bundle install --path vendor/bundle - - run: sudo apt-get update --allow-releaseinfo-change - - run: sudo apt install postgresql-client-11 - - run: dockerize -wait tcp://localhost:5432 -timeout 1m - - run: - name: Run specs - command: | - bundle exec rspec spec/ -workflows: - version: 2 - test: - jobs: - - test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..72d9bac --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +name: Ruby CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby-version: ['3.2', '3.1', '3.0', '2.7', '2.6'] + steps: + - uses: actions/checkout@v3 + - name: Run PostgreSQL + run: | + docker run --env POSTGRES_USER=postgres \ + --env POSTGRES_DB=activerecord-analyze-test \ + --env POSTGRES_PASSWORD=secret \ + -d -p 5432:5432 postgres:12.10-alpine \ + postgres -c shared_preload_libraries=pg_stat_statements + sleep 10 + - name: Set up Ruby ${{ matrix.ruby-version }} + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + - name: Setup dependencies + run: | + gem update --system + gem install bundler + sudo apt-get update --allow-releaseinfo-change + sudo apt install postgresql-client + sudo apt install libpq-dev + bundle config set --local path 'vendor/bundle' + bundle install + sleep 10 + - name: Run tests + env: + POSTGRES_HOST: localhost + POSTGRES_USER: postgres + POSTGRES_DB: activerecord-analyze-test + POSTGRES_PASSWORD: secret + DATABASE_URL: postgresql://postgres:secret@localhost:5432/activerecord-analyze-test + run: | + bundle exec rspec spec/ diff --git a/README.md b/README.md index f5e42e5..1c5f815 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ActiveRecord Analyze [![Gem Version](https://badge.fury.io/rb/activerecord-analyze.svg)](https://badge.fury.io/rb/activerecord-analyze) [![CircleCI](https://circleci.com/gh/pawurb/activerecord-analyze.svg?style=svg)](https://circleci.com/gh/pawurb/activerecord-analyze) +# ActiveRecord Analyze [![Gem Version](https://badge.fury.io/rb/activerecord-analyze.svg)](https://badge.fury.io/rb/activerecord-analyze) [![GH Actions](https://github.com/pawurb/activerecord-analyze/actions/workflows/ci.yml/badge.svg)](https://github.com/pawurb/activerecord-analyze/actions) This gem adds an `analyze` method to Active Record query objects. It executes `EXPLAIN ANALYZE` on a query SQL.