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

multiroot jest-change-files #3969

Merged
merged 1 commit into from
Jul 6, 2017

Conversation

aaronabramov
Copy link
Contributor

@aaronabramov aaronabramov commented Jul 6, 2017

first step towards optimizing performance of this module.

the problem we hit at fb is that we have too many roots specified for every project, and we had to get changed files for each root.
Now all roots are first resolved to a SCM root and deduped, so we'll be querying SCM only once per context.

includes a shitload of tests and types.

todo (followup PRs):

  • Share results between context (www, mobile are in the same repo and will give different results, but with the current implementation it'll do one request for every context)
  • Start fetching the result as soon as possible, before any of the hastemap stuff is generated (might be happening already, haven't looked into it yet)

return new Promise((resolve, reject) => {
let args = ['status', '-amnu'];
if (options && options.withAncestor) {
args.push('--rev', 'ancestor(.^)');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cpojer any idea what ancestor(.^) does? it seems to be used only inside www. HG documentation is very complicated and honestly after 15 min of reading it i was still not sure :)
if this is returning current cahnges + the latest commit, --rev .^ should be enough

Copy link
Member

Choose a reason for hiding this comment

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

Maybe ask internally, but I think that's about what it does. If it's only used internally, that's probably why I added this here and we can kill it :D

@@ -29,6 +29,9 @@ const run = (cmd, cwd) => {
throw new Error(message);
}

result.stdout = String(result.stdout);
Copy link
Member

Choose a reason for hiding this comment

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

I'd feel better about this if you called toString() explicitly.

@@ -57,7 +60,8 @@ const makeTemplate = string => {
};
};

const cleanup = (directory: string) => rimraf.sync(directory);
const cleanup = (directory: string) =>
fs.existsSync(directory) && rimraf.sync(directory);
Copy link
Member

Choose a reason for hiding this comment

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

I'll buy an if-statement.

stdout = stdout.trim();
if (stdout === '') {
resolve([]);
const adapter: SCMAdapter = {
Copy link
Member

Choose a reason for hiding this comment

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

Do you need this explicit typing here?

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. to make sure both git and hg have the same API and don't deviate

@cpojer
Copy link
Member

cpojer commented Jul 6, 2017

This looks fine overall, but I'm not entirely sure about the plan here. This doesn't really change anything, does it? Are you planning to take the main call out of SearchSource and pass Set<Context> into the SCM code at the end?

options: Options,
): Promise<Array<Path>> => {
return new Promise((resolve, reject) => {
let args = ['status', '-amnu'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

also i think i found a bug here. the original arguments were -amn and that does not return untracked files. ./git.js does return untracked files

@aaronabramov aaronabramov force-pushed the jest-changed-files branch 6 times, most recently from 3e921ef to 08cb3c5 Compare July 6, 2017 17:34
@codecov-io
Copy link

Codecov Report

Merging #3969 into master will decrease coverage by 0.12%.
The diff coverage is 67.94%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #3969      +/-   ##
=========================================
- Coverage   59.92%   59.8%   -0.13%     
=========================================
  Files         196     196              
  Lines        6785    6769      -16     
  Branches        6       6              
=========================================
- Hits         4066    4048      -18     
- Misses       2716    2718       +2     
  Partials        3       3
Impacted Files Coverage Δ
packages/jest-cli/src/search_source.js 79.31% <0%> (+8.29%) ⬆️
packages/jest-changed-files/src/hg.js 32.25% <32.14%> (-54.41%) ⬇️
packages/jest-changed-files/src/git.js 92.59% <92.59%> (+0.28%) ⬆️
packages/jest-changed-files/src/index.js 95.23% <95%> (+95.23%) ⬆️
packages/jest-haste-map/src/module_map.js 77.77% <0%> (-2.23%) ⬇️
packages/jest-matchers/src/matchers.js 99.37% <0%> (-0.01%) ⬇️
packages/eslint-config-fb-strict/index.js 0% <0%> (ø) ⬆️
packages/jest-haste-map/src/index.js 92.8% <0%> (ø) ⬆️
packages/jest-matchers/src/index.js 97.46% <0%> (+0.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c11a98e...0ef151e. Read the comment docs.

@aaronabramov aaronabramov merged commit 8abb0dd into jestjs:master Jul 6, 2017
@aaronabramov aaronabramov deleted the jest-changed-files branch July 6, 2017 22:43
tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants