Christopher Lam

Joined

2,340 Experience
21 Lessons Completed
0 Questions Solved

Activity

Hey - I have a Github Action test file as below. When I run the CI, the system tests which use Selenium WebDriver do not pass. The following error occurs:

 Selenium::WebDriver::Error::UnknownError:
            unknown error: Chrome failed to start: exited abnormally.
              (unknown error: DevToolsActivePort file doesn't exist)
              (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

My Github Action:

name: Verify Pull Request
on:
  pull_request:
    branches:
      - development
      - master

jobs:
  linters:
    name: Linters
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Setup Ruby and install gems
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true

      - name: Setup Node
        uses: actions/setup-node@v1
        with:
          node-version: 14.18.1
      - name: Find yarn cache location
        id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - name: JS package cache
        uses: actions/cache@v1
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: Install packages
        run: |
          yarn install --pure-lockfile

      - name: Run security checks
        run: |
          bin/bundler-audit --update
          bin/brakeman -q -w2

  tests:
    name: Tests
    runs-on: ubuntu-latest
    services:
      postgres:
        image: postgres:12.1-alpine
        ports: ["5432:5432"]
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

      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

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Connect to Redis
        # Runs a script that creates a Redis client, populates
        # the client with data, and retrieves data
        run: bundle exec redis-server
        # 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

      - name: Setup Ruby and install gems
        uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true

      - name: Setup Node
        uses: actions/setup-node@v1
        with:
          node-version: 14.18.1
      - name: Find yarn cache location
        id: yarn-cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - name: JS package cache
        uses: actions/cache@v1
        with:
          path: ${{ steps.yarn-cache.outputs.dir }}
          key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: |
            ${{ runner.os }}-yarn-
      - name: Install packages
        run: |
          yarn install --pure-lockfile

      - name: Setup test database
        env:
          DATABASE_URL: postgres://postgres:@localhost:5432/enlighten_test
          REDIS_URL: redis://localhost:6379/0
          RAILS_ENV: test
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
        run: |
          bin/rails db:setup

      - name: Install Selenium
        run: |
          sudo gem install selenium-webdriver

      - name: Install chrome Headless
        run: |
          sudo apt-get update
          sudo apt-get install google-chrome-stable

      - name: Run tests
        env:
          DATABASE_URL: postgres://postgres:@localhost:5432/enlighten_test
          REDIS_URL: redis://localhost:6379/0
          RAILS_ENV: test
          RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
          HEADLESS_CHROME: true
        run: bundle exec rspec

How do I fix this?

Posted in What are your Recommended Linters?

Hey there - I often get syntax errors in my ERB templates, is there a guide to recommended Rails linters?

Posted in How to use Stripe Checkout in Rails Discussion

how do you set the redirect url after checkout?

How do we add the redirect url after Stripe payment?

Posted in How to use Stripe Checkout in Rails Discussion

how do you customise the checkout button?

How do I constantly monitor a Rails database & then action an alert? eg. I want the user to save an alert in the backend. The backend would check an external API and compare the price in the DB against the price of the external API. When they match, Rails would action an alert. How would i make this scalable if there are hundreds of alerts & send alerts at a certain future date as well?

Posted in Hatchbox not returning correct credentials

Hi there,

I have deployed an app successfully but the app crashed immediately I tried to login. I ran bundle exec rails c and it seems like the values aren't being returned (returns as nil) from my environment credentials production.yml.enc. I am running Rails 6. Anyone got any advice to fix this?

Cheers,
Chris

Hey Chris - do you recommend a way to test the Notification class in RSpec? eg. test Twilio so you don't have to keep resending the SMS over and over.