-
-
Notifications
You must be signed in to change notification settings - Fork 71
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
New: Add option to allow use of file contents for cache #63
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
- Start Date: 2020-07-15 | ||
- RFC PR: https://github.com/eslint/rfcs/pull/63 | ||
- Authors: @c-home | ||
|
||
# Allow use of file contents for cache | ||
|
||
## Summary | ||
|
||
This RFC proposes improving cache for CI by providing an option to use a hash (instead of `mtime` and `fsize`) comparison to determine whether a file has changed. | ||
|
||
## Motivation | ||
|
||
Motivation for this change is the same as [#11490](https://github.com/eslint/eslint/issues/11490), where details of files like `mtime` are not preserved in the CI environment. With a hash comparison, the cache can be used in CI and would significantly reduce the time ESLint takes to run. | ||
|
||
ESLint uses [`file-entry-create`](https://github.com/royriojas/file-entry-cache) as its cache provider. [fileEntryCache#create](https://github.com/royriojas/file-entry-cache#createcachename-directory-usechecksum) gives the option to use a md5 hash through the `useChecksum` argument, but ESLint currently does not utilize it. | ||
|
||
## Detailed Design | ||
|
||
This RFC adds a `--cache-strategy` CLI option. Users can specify the option to be: | ||
- `contents`, for the use of an md5 hash | ||
- `metadata`, for the use of `mtime` and `fsize` | ||
|
||
Modified time and size (`metadata`), does not need to be specified as it will remain the default. | ||
|
||
The implementation will be similar to [#11487](https://github.com/eslint/eslint/pull/11487), with differences in the naming of the options. The options were kept general so if the underlying implementation of the comparison method were to change, the usage and documentation can remain the same. | ||
|
||
## Documentation | ||
|
||
Documentation for ESLint CLI will be updated with a description of the option. | ||
|
||
## Drawbacks | ||
|
||
- Specifying the details of the cache behaviour through a public option can make it more difficult to change the design and implementation [without breaking its usage](https://github.com/eslint/eslint/issues/11490#issuecomment-471400143). | ||
- Comparing files based on their contents is slower than comparing files by their file metadata. However, a file contents comparison is not the default. | ||
- Like any new feature, this flag will slightly increase the complexity and maintenance costs of ESLint. | ||
|
||
## Backwards Compatibility Analysis | ||
|
||
This change is backwards-compatible. It adds a new CLI option while keeping the behavior the same if the option is not specified. | ||
|
||
## Alternatives | ||
|
||
Mentioned as an alternative in [#11487](https://github.com/eslint/eslint/pull/11487), and if `file-entry-cache` [#14](https://github.com/royriojas/file-entry-cache/pull/14) were to be merged, an environment variable could be passed through `eslint` to `file-entry-cache`. | ||
|
||
## Open Questions | ||
|
||
None | ||
|
||
## Frequently Asked Questions | ||
|
||
None yet | ||
|
||
## Related Discussions | ||
|
||
- https://github.com/eslint/eslint/issues/11319 | ||
- https://github.com/eslint/eslint/issues/11490 | ||
- https://github.com/eslint/eslint/pull/11487 | ||
- https://github.com/royriojas/file-entry-cache/pull/14 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please describe the details of the implementation here? Which files would be changed?