Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1281 warning on no write #7126

Merged
merged 6 commits into from
May 12, 2020

Conversation

mrmeku
Copy link
Contributor

@mrmeku mrmeku commented Apr 23, 2020

User facing changelog

Cypress no longer requires write access to the projectRoot, it instead will display a warning.

Additional details

  • This allows for cypress inetegration with other tools such as Bazel
  • It allows Cypress to be run in sandboxed or otherwise readonly fs environments

How has the user experience changed?

Before

Screen Shot 2020-05-05 at 10 35 11 AM

After

Screen Shot 2020-05-05 at 10 25 28 AM

PR Tasks

  • Have tests been added/updated?
  • Has the original issue been tagged with a release in ZenHub?
  • Has a PR for user-facing changes been opened in cypress-documentation?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Apr 23, 2020

Thanks for the contribution! Below are some guidelines Cypress uses when doing PR reviews.

  • Please write [WIP] in the title of your Pull Request if your PR is not ready for review - someone will review your PR as soon as the [WIP] is removed.
  • Please familiarize yourself with the PR Review Checklist and feel free to make updates on your PR based on these guidelines.

PR Review Checklist

If any of the following requirements can't be met, leave a comment in the review selecting 'Request changes', otherwise 'Approve'.

User Experience

  • The feature/bugfix is self-documenting from within the product.
  • The change provides the end user with a way to fix their problem (no dead ends).

Functionality

  • The code works and performs its intended function with the correct logic.
  • Performance has been factored in (for example, the code cleans up after itself to not cause memory leaks).
  • The code guards against edge cases and invalid input and has tests to cover it.

Maintainability

  • The code is readable (too many nested 'if's are a bad sign).
  • Names used for variables, methods, etc, clearly describe their function.
  • The code is easy to understood and there are relevant comments explaining.
  • New algorithms are documented in the code with link(s) to external docs (flowcharts, w3c, chrome, firefox).
  • There are comments containing link(s) to the addressed issue (in tests and code).

Quality

  • The change does not reimplement code.
  • There's not a module from the ecosystem that should be used instead.
  • There is no redundant or duplicate code.
  • There are no irrelevant comments left in the code.
  • Tests are testing the code’s intended functionality in the best way possible.

Internal

  • The original issue has been tagged with a release in ZenHub.

@CLAassistant
Copy link

CLAassistant commented Apr 23, 2020

CLA assistant check
All committers have signed the CLA.

@mrmeku mrmeku changed the title Carry on my toxicble son Issue 1281 warning on no write Apr 23, 2020
@mrmeku mrmeku force-pushed the carry-on-my-toxicble-son branch 4 times, most recently from ffca899 to 201ce45 Compare April 24, 2020 19:03
@mrmeku
Copy link
Contributor Author

mrmeku commented Apr 28, 2020

@jennifer-shehane Could I get a review on this? Its a continuation of a PR you were reviewing: #5584

packages/server/test/e2e/8_read_only_fs.ts Outdated Show resolved Hide resolved
packages/server/lib/errors.coffee Outdated Show resolved Hide resolved
@mrmeku mrmeku force-pushed the carry-on-my-toxicble-son branch 2 times, most recently from d2aa498 to 34e5e6d Compare May 4, 2020 18:21
@mrmeku
Copy link
Contributor Author

mrmeku commented May 4, 2020

@jennifer-shehane Merged your changes! Thanks for those. Is there anything else you'd like me to do before this is ready to be merged?

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you add snapshots, this generates a file of the stdout output of the test you wrote. So, you need to run SNAPSHOT_UPDATE=1 yarn test-e2e 8_read_only to generate this file for comparison later (I've gone ahead and done this and committed it). The idea is - if something breaks, we'll see the changes in the STDOUT.

Since the test you wrote has randomized characters - this won't work for snapshot testing. Each time you run the test, the generated output will be different. We need the test to have the same output each time the test is run.

packages/server/test/e2e/8_read_only_fs.ts Outdated Show resolved Hide resolved
@mrmeku mrmeku force-pushed the carry-on-my-toxicble-son branch from c99e6ad to 78a3f52 Compare May 6, 2020 22:35
@mrmeku
Copy link
Contributor Author

mrmeku commented May 6, 2020

@jennifer-shehane Snapshots updated and ready to go

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an issue with the yarn lockfile that was committed. It's resolving to the incorrect has-binary dep. The has-binary dep should not have updated in your committed lockfile.

@mrmeku mrmeku force-pushed the carry-on-my-toxicble-son branch from 78a3f52 to 3dae576 Compare May 7, 2020 23:24
@mrmeku
Copy link
Contributor Author

mrmeku commented May 7, 2020

@jennifer-shehane Sorry I didn't catch that when I was reviewing my code. It's resolved now

@@ -126,7 +126,11 @@ module.exports = {
throw err
}

// else we cannot read due to folder permissions
if (err.toString().startsWith('Error: EACCES: permission denied')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See how line 119 uses an object to filter the .catch block. You should be able to do this in a similar fashion:

.catch({ code: 'EACCES' }, () => {
	return errors.warning(...)
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done! thanks for the advise

Comment on lines 203 to 204
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this plz. you may want to turn on the preference to "end files with a newline" in your editor

packages/server/test/e2e/8_read_only_fs.ts Outdated Show resolved Hide resolved
packages/server/test/e2e/8_read_only_fs.ts Outdated Show resolved Hide resolved
packages/server/test/e2e/8_read_only_fs.ts Outdated Show resolved Hide resolved
// the dir needs executable for debugging
// the main test here is that it isn't writable, which would be either 6 or 7
// See here for more info on these numbers http://permissions-calculator.org/
chmodr.sync(projectDir, 0o500)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoa, i didn't know this 0o prefix was a thing, i am only familiar with using octals via the leading 0 (like 0500)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you totally have to do it this way when running in strict mode
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal

Learn something new about java script everyday

packages/server/test/e2e/8_read_only_fs.ts Outdated Show resolved Hide resolved
const e2e = require('../support/helpers/e2e')
const chmodr = require('chmodr')

describe('e2e project dir access', function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a nice, robust test. you should rename the file to 8_read_only_fs_spec.ts to match how other e2e tests are named.

Comment on lines 46 to 60
Warning: We failed to record the video.

This error will not alter the exit code.

Error: ffmpeg exited with code 1: /tmp/8_read_only_fs/cypress/videos/spec.js.mp4: Permission denied

[stack trace lines]

Warning: We failed processing this video.

This error will not alter the exit code.

Error: ffmpeg exited with code 1: /tmp/8_read_only_fs/cypress/videos/spec.js.mp4: Permission denied

[stack trace lines]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would also like to see a screenshot failure here... using a spec that fails should generate a screenshot

This change replaces the error with a warning
when cypress is executing tests in a readonly fs.
- don't need to run test in a specific browser
- can combine SS + video test into one
- don't seem to need readonly_fs_spec.js
@flotwig
Copy link
Contributor

flotwig commented May 11, 2020

Nyah... the e2e tests are failing because CI runs as root, and root doesn't get a permission denied error. Let me see how we can work around this.

flotwig
flotwig previously approved these changes May 11, 2020
Copy link
Contributor

@flotwig flotwig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I did some cleanup and made it so that failure to create the videos directory will also not crash the test. Added a new e2e test stage so we can run the tests as non-root as well.

circle.yml Show resolved Hide resolved
@flotwig
Copy link
Contributor

flotwig commented May 11, 2020

Note that this PR will not fix errors caused by failure to "scaffold" a new project with a "supportFile". Some work needs to be done to not scaffold supportFolder in run mode:

https://github.com/mrmeku/cypress/blob/b5e46dd3bc7de54b4f9234754e0228ab64a9294e/packages/server/lib/project.js#L574-L582

And with that, it will need to be made possible for individual scaffolding steps to fail and cause the default values for config.supportFile/etc. to change, otherwise Cypress will just end up looking for non-existent files if scaffolding fails.

bahmutov
bahmutov previously approved these changes May 11, 2020
Copy link
Contributor

@bahmutov bahmutov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good fix

@flotwig flotwig dismissed stale reviews from bahmutov and themself via 3e9a2b8 May 11, 2020 19:08
@jennifer-shehane jennifer-shehane dismissed their stale review May 12, 2020 07:53

Dismissing my previous review

@jennifer-shehane
Copy link
Member

@flotwig @bahmutov Can this PR be approved?

@jennifer-shehane
Copy link
Member

@flotwig Are you saying that this PR will not fully close #1281?

@flotwig
Copy link
Contributor

flotwig commented May 12, 2020

@jennifer-shehane it's good to go, just waiting for those dang contributor tests to pass 🙄

It closes #1281 since it will allow the folks in that thread to use Cypress on a read-only FS. I'll open a more specific issue about scaffolding requiring write access once this is closed. (opened #7310)

@yezhengli-Mr9
Copy link

yezhengli-Mr9 commented Nov 30, 2023

Still #1281

See discussion and possible solutions at
npm ERR! https://github.com/cypress-io/cypress/issues/1281
npm ERR! 
npm ERR! ----------
npm ERR! 
npm ERR! Failed to access /root/.cache/Cypress:
npm ERR! 
npm ERR! EACCES: permission denied, mkdir '/root/.cache/Cypress'

although tried

 sudo chown -R $USER:$GROUP ~/.npm
sudo chmod +x /root/.cache

@jennifer-shehane
Copy link
Member

@yezhengli-Mr9 Please open a new issue if you're encountering an issue with Cypress filling out the template.

@cypress-io cypress-io locked and limited conversation to collaborators Dec 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cypress should not require write access of root folder
6 participants