From 574187e3fadb81558580bf713139090a7b502dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fr=C4=B1=20=C3=96zkan?= Date: Fri, 9 Jun 2023 02:44:20 +0300 Subject: [PATCH] Update ci --- .github/workflows/ci.yml | 111 ++++++++++++++++-------------- .github/workflows/rubyonrails.yml | 77 --------------------- 2 files changed, 61 insertions(+), 127 deletions(-) delete mode 100644 .github/workflows/rubyonrails.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fec56d4..ac3d37a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,64 +1,75 @@ -name: CI +# 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 install a prebuilt Ruby version, install dependencies, and +# run tests and linters. +name: "CI" on: - push: - branches: [ master ] + branches: [ "master" ] pull_request: - branches: [ master ] - + branches: [ "master" ] jobs: test: runs-on: ubuntu-latest - - services: + services: + redis: + # Docker Hub image + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 postgres: - image: postgres:12 + image: postgres:11-alpine + ports: + - "5432:5432" env: - POSTGRES_PASSWORD: postgres - ports: ['5432:5432'] - + POSTGRES_DB: rails_test + POSTGRES_USER: rails + POSTGRES_PASSWORD: password + env: + RAILS_ENV: test + DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" steps: - - uses: actions/checkout@v2 - - name: Setup ruby - uses: ruby/setup-ruby@v1 + - name: Checkout code + uses: actions/checkout@v3 + # Add or replace dependency steps here + - name: Install Ruby and gems + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 with: - ruby-version: 3.1.0 bundler-cache: true - - - name: Install Dependencies - run: | - sudo apt install -yqq libpq-dev - gem install bundler - - - name: Install Gems - run: | - bundle install - - - name: Setup database - env: - PG_DATABASE: postgres - PG_HOST: localhost - PG_USER: postgres - PG_PASSWORD: password - RAILS_ENV: test - WITH_COVERAGE: true - DISABLE_SPRING: 1 - run: | - bundle exec rails db:prepare - bundle exec rake test - - - name: Build and test with rspec + - name: Connect to Redis + # Runs a script that creates a Redis client, populates + # the client with data, and retrieves data env: - PG_DATABASE: postgres - PG_HOST: localhost - PG_USER: postgres - PG_PASSWORD: password - RAILS_ENV: test - run: | - bundle exec rspec spec + # The hostname used to communicate with the Redis service container + REDIS_HOST: redis + # The default Redis port + REDIS_PORT: 6379 + # Add or replace database setup steps here + - name: Set up database schema + run: bin/rails db:schema:load + # Add or replace test runners here + - name: Run tests + run: bin/rake - - name: Create Coverage Artifact - uses: actions/upload-artifact@v2 + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Ruby and gems + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 with: - name: code-coverage - path: coverage/ + bundler-cache: true + # Add or replace any other lints here + - name: Security audit dependencies + run: bin/bundler-audit --update + - name: Security audit application code + run: bin/brakeman -q -w2 + - name: Lint Ruby files + run: bin/rubocop --parallel diff --git a/.github/workflows/rubyonrails.yml b/.github/workflows/rubyonrails.yml deleted file mode 100644 index 738eb32..0000000 --- a/.github/workflows/rubyonrails.yml +++ /dev/null @@ -1,77 +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. -# -# This workflow will install a prebuilt Ruby version, install dependencies, and -# run tests and linters. -name: "Ruby on Rails CI" -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] -jobs: - test: - runs-on: ubuntu-latest - services: - redis: - # Docker Hub image - image: redis - # Set health checks to wait until redis has started - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - postgres: - image: postgres:11-alpine - ports: - - "5432:5432" - env: - POSTGRES_DB: rails_test - POSTGRES_USER: rails - POSTGRES_PASSWORD: password - env: - RAILS_ENV: test - DATABASE_URL: "postgres://rails:password@localhost:5432/rails_test" - steps: - - name: Checkout code - uses: actions/checkout@v3 - # Add or replace dependency steps here - - name: Install Ruby and gems - uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 - with: - bundler-cache: true - - name: Connect to Redis - # Runs a script that creates a Redis client, populates - # the client with data, and retrieves data - run: node client.js - # Environment variable used by the `client.js` script to create a new Redis client. - env: - # The hostname used to communicate with the Redis service container - REDIS_HOST: redis - # The default Redis port - REDIS_PORT: 6379 - # Add or replace database setup steps here - - name: Set up database schema - run: bin/rails db:schema:load - # Add or replace test runners here - - name: Run tests - run: bin/rake - - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - name: Install Ruby and gems - uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 - with: - bundler-cache: true - # Add or replace any other lints here - - name: Security audit dependencies - run: bin/bundler-audit --update - - name: Security audit application code - run: bin/brakeman -q -w2 - - name: Lint Ruby files - run: bin/rubocop --parallel