Fix database connection for Railway - use DATABASE_URL in production #251
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI Pipeline | |
| on: | |
| pull_request: | |
| push: | |
| branches: [main] | |
| jobs: | |
| scan_ruby: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: bundle install --jobs 4 --retry 3 --verbose | |
| - name: Scan for common Rails security vulnerabilities using static analysis | |
| run: bin/brakeman --no-pager --no-exit-on-warn | |
| - name: Clear gem cache | |
| run: bundle clean --force | |
| scan_js: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| bundler-cache: true | |
| - name: Install JavaScript dependencies | |
| run: echo "No JavaScript dependencies to audit" | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: bundle install --jobs 4 --retry 3 --verbose | |
| - name: Lint code for consistent style | |
| run: bin/rubocop -f github | |
| test: | |
| runs-on: ubuntu-latest | |
| env: | |
| RAILS_ENV: test | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: 123456 | |
| POSTGRES_TEST_DB: api-quequeo-test | |
| DATABASE_URL: postgres://postgres:123456@localhost:5432/api-quequeo-test | |
| services: | |
| postgres: | |
| image: postgres | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: 123456 | |
| POSTGRES_DB: api-quequeo-test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd="pg_isready" | |
| --health-interval=10s | |
| --health-timeout=5s | |
| --health-retries=5 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: bundle install --jobs 4 --retry 3 --verbose | |
| - name: Wait for PostgreSQL to be ready | |
| run: | | |
| until pg_isready -h localhost -U postgres; do | |
| echo "Waiting for PostgreSQL..." | |
| sleep 2 | |
| done | |
| - name: Prepare the database | |
| run: bin/rails db:prepare --verbose | |
| - name: Run RSpec tests | |
| run: bundle exec rspec --format documentation |