cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.02k stars 3.18k forks source link

Not found binary in the DroneCI #2249

Closed williamcosta closed 5 years ago

williamcosta commented 6 years ago

Current behavior:

screen shot 2018-07-31 at 09 19 26

The code in DroneCI config

pipeline:
  restore-cache:
    image: drillster/drone-volume-cache
    restore: true
    mount:
      - ./node_modules
      - ~/.cache
      - ~/.npm
    volumes:
      - /tmp/cache:/cache
    ttl: 3

  build:
    image: getninjas/nodejs:9-chrome64
    commands:
      - npm ci

  integration-test:
    group: tests
    image: getninjas/nodejs:9-chrome64
    commands:
      - npm run server:test
      - ./node_modules/bin/cypress run
      - npm run clear:pm2
    environment:
      - REDIS_HOST=redis

  rebuild-cache:
    image: drillster/drone-volume-cache
    rebuild: true
    mount:
      - ./node_modules
      - ~/.cache
      - ~/.npm
    volumes:
      - /tmp/cache:/cache

Desired behavior:

I ran my test pipeline on DroneCI and before was running version 2.x running smoothly.

I am trying to update the version to 3.0.2 and now Cypress complains that Binary is not being found, I have already tried some ways to solve with ENV variable and mount folder in cache step.

If anyone can help me, thank you.

Versions

Platform: linux (Debian - 8.10) Cypress: v3.0.2 DroneCI: v0.5

bahmutov commented 6 years ago

Can you try running once with old cache purged? Because it might be restoring old cache folder and not finding the expected binary

Sent from my iPhone

On Jul 31, 2018, at 14:30, William Costa notifications@github.com wrote:

Is this a Feature or Bug?

Current behavior:

The code in DroneCI config

pipeline: restore-cache: image: drillster/drone-volume-cache restore: true mount:

  • ./node_modules
  • ~/.cache
  • ~/.npm volumes:
  • /tmp/cache:/cache ttl: 3

    build: image: getninjas/nodejs:9-chrome64 commands:

  • npm ci

    integration-test: group: tests image: getninjas/nodejs:9-chrome64 commands:

  • npm run server:test
  • ./node_modules/bin/cypress run
  • npm run clear:pm2 environment:
  • REDIS_HOST=redis

    rebuild-cache: image: drillster/drone-volume-cache rebuild: true mount:

  • ./node_modules
  • ~/.cache
  • ~/.npm volumes:
  • /tmp/cache:/cache Desired behavior:

I ran my test pipeline on DroneCI and before was running version 2.x running smoothly.

I am trying to update the version to 3.0.2 and now Cypress complains that Binary is not being found, I have already tried some ways to solve with ENV variable and mount folder in cache step.

If anyone can help me, thank you.

Versions

Platform: linux (Debian - 8.10) Cypress: v3.0.2 DroneCI: v0.5

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

williamcosta commented 6 years ago

@bahmutov I have already tried clearing the CI cache and even removing the CI cache step for testing and not even then the error persisted.

bahmutov commented 6 years ago

Can you show the CI output from the npm install command? It should print messages that it is installing the binary (downloading, unzipping)

Sent from my iPhone

On Jul 31, 2018, at 15:24, William Costa notifications@github.com wrote:

@bahmutov I have already tried clearing the CI cache and even removing the CI cache step for testing and not even then the error persisted.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

williamcosta commented 6 years ago

This is output in build step:

> cypress@3.0.2 postinstall /drone/src/github.com/getninjas/tanya/node_modules/cypress
> node index.js --exec install

[12:05:45]  Downloading Cypress     [started]
[12:05:47]  Downloading Cypress     [completed]
[12:05:47]  Unzipping Cypress       [started]
[12:06:46]  Unzipping Cypress       [completed]
[12:06:46]  Finishing Installation  [started]
[12:06:46]  Finishing Installation  [completed]
added 2363 packages in 89.948s
brian-mann commented 6 years ago

Can you run with DEBUG=cypress:* npm install or DEBUG=cypress:* cypress install.

I believe you can always issue cypress install and unless you pass the --force flag it will not install if its already installed.

We need more output logs from your CI provider. As it stands, there's not enough to debug this. We have thousands of projects running on various CI providers but I'm not sure if we've seen Drone CI that often.

brian-mann commented 6 years ago

Okay actually I know exactly what is happening.

What you've done or did (once) is that you cached the node_modules after Cypress installed.

What this did was cache the CLI tool, but because now in 3.x.x we install to the ~/.cache folder, when your CI provider goes to restore the cache, the binary is missing.

Cypress is not being reinstalled because when you run npm install the Cypress npm module does not reinstall itself (cuz it's already installed) which then prevents the postinstall hook from ever being called.

I believe all you have to do is add a new command: cypress install and cypress will install itself if it doesn't exist, or skip this step if it does.

williamcosta commented 6 years ago

Yes, @brian-mann I do cache the ./node_modules folder, I tried to add the ~/.cache folder to my CI cache, but from what I had debugged this folder is not being created in my CI.

The solution I'm doing per hour is to do a npm i cypress @ 3.0.2 in the step where I run the cypress tests. But this ended up increasing a little bit of my build.

I'll try to debug more with the commands you mentioned above.

Thank you for your help.

jennifer-shehane commented 5 years ago

@williamcosta Were you able to resolve your issue?

williamcosta commented 5 years ago

Hello @jennifer-shehane, my solution was to put a Cypress install on the same pipeline that we ran the specs.

akoidan commented 4 years ago

drone-volume-cache doesn't support caching outside the working directory and explicitly says so:

The cached files or directories must be located in your build workspace. It is not possible to cache files outside of your build workspace.

Screw the plugin, you can mount the directory directly to the host container. The working example can be found at vue-webpack-typescript:

---
kind: pipeline
type: docker
name: default

steps:
  - name: install-deps
    volumes:
      - name: cypress-cache
        path: /root/.cache/Cypress
    image: cypress/base:13.3.0
    commands:
      - yarn install

  - name: test
    volumes:
      - name: cypress-cache
        path: /root/.cache/Cypress
    image: cypress/base:13.3.0
    commands:
      - yarn run test

volumes:
  - name: cypress-cache
    host:
      path: /tmp/cypress-cache

Pay attention that you only wanna do that for things that are protected from being modified along in multiple places at the same time, which for yarn cache is ok, but maybe for something else is NOT.

Since I can't guarantee this safeness for cypress directory, I would recommend you to use included docker build tag, which already has preinstalled .cache/Cypress directory, for ex. cypress/included:3.8.1