Travis CI: запустить кипарис на рельсах сервера - PullRequest
0 голосов
/ 02 июля 2018

Я создал публичное репо для тестирования приватного репо .

У меня одна и та же конфигурация в моем private-repo и public-repo:


    {
      "os": "linux",
      "env": "BUNDLE_GEMS__CONTRIBSYS__COM=1234567890",
      "dist": "trusty",
      "cache": {
        "bundler": true,
        yarn: true,
        "directories": [
          "~/.cache"
        ]
      },
      "group": "stable",
      "addons": {
        "postgresql": "9.4"
      },
      "script": [
        "$(yarn bin)/cypress run"
      ],
      "install": [
        "yarn add cypress"
      ],
      "node_js": 10,
      "language": "node_js",
      "services": [
        "redis-server",
        "postgresql"
      ],
      "before_script": [
        "rails server -p 3000 -b 127.0.0.1 &",
        "psql -c 'create database travis_ci_test;' -U postgres",
        "RAILS_ENV=test bundle exec rake db:schema:load",
        "RAILS_ENV=test bundle exec rake db:seed"
      ],
      "before_install": [
        "gem install bundler",
        "bundle install"
      ]
    }

Но я не понимаю, почему у меня есть это сообщение об ошибке в моем приват-репо:


      Testing
        1) can i access to 127.0.0.1
        2) can i access to localhost
      0 passing (1m)
      2 failing
      1) Testing can i access to 127.0.0.1:
         CypressError: cy.request() timed out waiting 30000ms for a response from your server.
    The request we sent was:
    Method: GET
    URL: http://127.0.0.1:3000/
    No response was received within the timeout.
          at Object.cypressErr (http://localhost:36431/__cypress/runner/cypress_runner.js:68076:11)
          at Object.throwErr (http://localhost:36431/__cypress/runner/cypress_runner.js:68041:18)
          at Object.throwErrByPath (http://localhost:36431/__cypress/runner/cypress_runner.js:68068:17)
          at http://localhost:36431/__cypress/runner/cypress_runner.js:59657:25
          at tryCatcher (http://localhost:36431/__cypress/runner/cypress_runner.js:7091:23)
          at http://localhost:36431/__cypress/runner/cypress_runner.js:2408:41
          at tryCatcher (http://localhost:36431/__cypress/runner/cypress_runner.js:7091:23)
          at Promise._settlePromiseFromHandler (http://localhost:36431/__cypress/runner/cypress_runner.js:5113:31)
          at Promise._settlePromise (http://localhost:36431/__cypress/runner/cypress_runner.js:5170:18)
          at Promise._settlePromise0 (http://localhost:36431/__cypress/runner/cypress_runner.js:5215:10)
          at Promise._settlePromises (http://localhost:36431/__cypress/runner/cypress_runner.js:5290:18)
          at Async._drainQueue (http://localhost:36431/__cypress/runner/cypress_runner.js:2023:16)
          at Async._drainQueues (http://localhost:36431/__cypress/runner/cypress_runner.js:2033:10)
          at Async.drainQueues (http://localhost:36431/__cypress/runner/cypress_runner.js:1907:14)
          at 

Мое публичное репо: https://github.com/joffreyBerrier/rails-travis

Моя публичная сборка travis: https://travis -ci.org / joffreyBerrier / rails-travis / builds

Мой тест на кипарис:


    describe('Testing', () => {
      it('can i access to 127.0.0.1', () => {
        cy.request('http://127.0.0.1:3000');
      });

      it('can i access to localhost', () => {
        cy.request('localhost:3000');
      });
    });

1 Ответ

0 голосов
/ 12 июля 2019

ОП решил свою проблему, используя следующее .travis.yml:

language: node_js
node_js:
  - 9.11.2
addons:
  postgresql: "9.4"
services:
  - redis-server
  - postgresql
cache:
  bundler: true
  yarn: true
  directories:
    - /home/travis/.rvm/
    - ~/.cache
before_install:
  - gem install bundler
  - bundle install
install:
  - yarn add cypress
before_script:
  - psql -c 'create database travis_ci_test;' -U postgres
  - bin/rails server &
  - bundle exec rake assets:precompile
  - sleep 10
  - RAILS_ENV=test bundle exec rake db:schema:load
  - RAILS_ENV=test bundle exec rake your_seed
script:
  - $(yarn bin)/cypress run --record
  - bundle exec rspec spec/controllers spec/models spec/jobs
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...