I would like to find a sample that runs cypress.io tests on CircleCI using ruby on rails, I have tried and I can’t figure out what is wrong, this one is one of the versions I have tried to run Cypress tests on CircleCI.
version: 2.1
orbs:
ruby: circleci/ruby@1.1.2
node: circleci/node@2
cypress: cypress-io/cypress@1.28.0
jobs:
build:
docker:
- image: cimg/ruby:2.7-node
auth:
username: user
password: $DOCKERHUB_PASSWORD
environment:
RAILS_ENV: test
PGHOST: 127.0.0.1
PGUSER: root
REDIS_CACHE_URL: redis://127.0.0.1:6379
REDIS_QUEUE_URL: redis://127.0.0.1:6379
CYPRESS: 1
- image: circleci/redis:5.0.4
# Service container image available at `host: localhost`
- image: circleci/postgres:13.3
auth:
username: user
password: $DOCKERHUB_PASSWORD # context / project UI env-var reference
environment:
POSTGRES_USER: root
POSTGRES_DB: db_test
POSTGRES_PASSWORD: "password"
steps:
- checkout
- run: sudo apt install -y postgresql-client || true
- run: sudo apt install xvfb
- restore_cache:
name: Restore gem cache
keys:
- gem-cache-v9-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- gem-cache-v9-{{ arch }}-{{ .Branch }}
- gem-cache-v9-{{ arch }}
- gem-cache-v9
- restore_cache:
name: Restore yarn cache
keys:
- yarn-cache-v9-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-cache-v9-{{ arch }}-{{ .Branch }}
- yarn-cache-v9-{{ arch }}
- yarn-cache-v9
- restore_cache:
name: Restore assets cache
keys:
- assets-cache-v9-{{ checksum "dependency_checksum" }}-{{ arch }}-{{ .Branch }}
- assets-cache-v9-{{ checksum "dependency_checksum" }}-{{ arch }}
- assets-cache-v9-{{ checksum "dependency_checksum" }}
# Bundle install dependencies
- run:
name: Install dependencies
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs 3 --retry 3
- node/install-packages:
pkg-manager: yarn
cache-key: "yarn.lock"
- run: cp config/application.example.yml config/application.yml
- run: cp config/database.yml.ci config/database.yml
- save_cache:
name: Save gem cache
paths:
- vendor/bundle
key: gem-cache-v9-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile.lock" }}
- save_cache:
name: Save yarn cache
paths:
- ~/.cache/yarn
key: yarn-cache-v9-{{ arch }}-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run:
name: Database Setup
command: |
bundle exec rake db:create
bundle exec rake db:structure:load
- run:
name: Parallel RSpec
command: bundle exec rspec -t newtests
- run:
name: Compile assets
command: bundle exec rails assets:precompile
- save_cache:
name: Save assets cache
paths:
- public/packs-test
- public/assets
- tmp/cache/webpacker
- tmp/cache/assets/sprockets
key: assets-cache-v9-{{ checksum "dependency_checksum" }}-{{ arch }}-{{ .Branch }}
- run:
name: Run Rails Server
background: true
command: CYPRESS=1 bundle exec rails s -p 5017
- run:
name: Wait for server
command: |
until $(curl --retry 10 --output /dev/null --silent --head --fail http://127.0.0.1:5017); do
printf '.'
sleep 5
done
# - run: yarn add cypress --dev
- cypress/run:
executor: cypress/base-14
#- run:
# yarn: true
# command: yarn run cypress run
# Save artifacts
- store_test_results:
path: test-reports/