-
Notifications
You must be signed in to change notification settings - Fork 2k
Add affected packages analysis. #2793
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
Conversation
nsthorat
left a comment
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.
Reviewed 1 of 3 files at r1.
Reviewable status: 0 of 1 approvals obtained (waiting on @dsmilkov, @lina128, @nsthorat, and @pyu10055)
scripts/dependency.json, line 1 at r1 (raw file):
{
can we call this file package_dependencies.json
scripts/diff.js, line 113 at r1 (raw file):
triggeredBuilds.forEach(triggeredBuild => { const affectedPackages = calculateAffectedPackages(dependencyGraph, triggeredBuild);
shouldn't this take into consideration the diff?
scripts/diff.js, line 115 at r1 (raw file):
calculateAffectedPackages(dependencyGraph, triggeredBuild); affectedPackages.forEach(package => { writeFileSync(join(package, 'diff'), '');
why do you have to write '' here?
scripts/diff.js, line 121 at r1 (raw file):
// Deduplicate the triggered builds for log. triggeredBuilds = [...new Set(triggeredBuilds)];
do Array.from here so we're using the default constructors
scripts/test-util.js, line 31 at r1 (raw file):
// Example: // dependencyGraph = { // "tfjs-core": ["tfjs-converter", "tfjs", ...],
any reason the .json file doesn't just look like this map?
scripts/test-util.js, line 41 at r1 (raw file):
const dependencyGraph = {}; dependencyInfo.packages.forEach(
nit: this block should be (not semicolons and indentation):
dependencyInfo.packages.forEach(package => {
package.dependencies.forEach(dependency => {
if (!dependencyGraph[dependency]) {
dependencyGraph[dependency] = [];
}
dependencyGraph[dependency].push(package.package);
});
});
scripts/test-util.js, line 56 at r1 (raw file):
traverseDependencyGraph(dependencyGraph, package, affectedPackages); return [...affectedPackages];
you can do Array.from(affectedPackages)
dsmilkov
left a comment
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.
Great stuff. Tiny comments, non-major thus LGTM
Reviewed 1 of 3 files at r1.
Reviewable status:complete! 1 of 1 approvals obtained (waiting on @dsmilkov, @lina128, @nsthorat, and @pyu10055)
scripts/diff.js, line 113 at r1 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
shouldn't this take into consideration the diff?
I think triggeredBuilds is already pre-populated with the touched packages, from the code above.
scripts/diff.js, line 115 at r1 (raw file):
Previously, nsthorat (Nikhil Thorat) wrote…
why do you have to write '' here?
+1 no need to write.
scripts/diff.js, line 116 at r1 (raw file):
affectedPackages.forEach(package => { writeFileSync(join(package, 'diff'), ''); triggeredBuilds.push(package);
push into a separate array, not the one that you are currently traversing (triggeredBuilds.forEach loop above) to avoid looking into the same items multiple times.
|
nsthorat
left a comment
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.
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @lina128, @nsthorat, and @pyu10055)
scripts/test-util.js, line 31 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
Hi Nikhil, Yeah, we can make the .json file look like this and we can avoid compute the dependency graph each time. However, I think have the .json file mirroring the package.json file of each package, allows us to possibly automate the dependency file. Also it makes adding new package to this file easy, just copy paste from package.json of the new package. But either way has some pros, so I don't have strong preference. What do you think? Which pros is more important?
I think we should let this be manual so there's less magic / moving parts :)
Ah, nice catch. Pushed to a separate array. |
dsmilkov
left a comment
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.
Thanks! LGTM
Reviewed 3 of 5 files at r2, 1 of 2 files at r3.
Reviewable status:complete! 1 of 1 approvals obtained (waiting on @lina128, @nsthorat, and @pyu10055)
pyu10055
left a comment
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.
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @lina128, @nsthorat, and @pyu10055)
scripts/diff.js, line 117 at r3 (raw file):
computeAffectedPackages(dependencyGraph, triggeredBuild); affectedPackages.forEach(package => { writeFileSync(join(package, 'diff'));
package seems to be the name of the packages, with out the directory information, where you are trying to write this file?
and how would this file used?
nsthorat
left a comment
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.
Reviewable status:
complete! 1 of 1 approvals obtained (waiting on @lina128 and @nsthorat)
scripts/diff.js, line 115 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
You are right. Removed ''.
I meant why do you need to write the file at all?
Because we rely on whether the dir has a diff file to trigger cloud build, right? https://github.com/tensorflow/tfjs/blob/master/scripts/run-build.sh#L20 |
nsthorat
left a comment
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.
Reviewable status:
complete! 2 of 1 approvals obtained (waiting on @lina128)
scripts/diff.js, line 115 at r1 (raw file):
Previously, lina128 (Na Li) wrote…
Because we rely on whether the dir has a diff file to trigger cloud build, right? https://github.com/tensorflow/tfjs/blob/master/scripts/run-build.sh#L20
ah, right. can we rename this file from 'diff' to something like 'run-ci'? here and above, and maybe make this file called diff.js something like 'find-affected-packages.js'?
After line 72, I'm in the root directory, so the package name is also the dir name. https://github.com/tensorflow/tfjs/blob/master/scripts/diff.js#L71 I'm trying to write this file under each affected package. So that when the code detects a diff file, it will trigger cloud build: https://github.com/tensorflow/tfjs/blob/master/scripts/run-build.sh |
Done. Changed diff to run-ci in three places in find-affected-packages.js file. Also add run-ci to gitignore. Changed file name to find-affected-packages, also changed yarn command, and cloudbuild accordingly. |
pyu10055
left a comment
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.
Reviewed 3 of 5 files at r2, 5 of 5 files at r4, 2 of 2 files at r5.
Reviewable status:complete! 3 of 1 approvals obtained (waiting on @lina128 and @pyu10055)
Introduced dependency.json in this PR. After this PR, when calculating diff, CI will also analyze affected packages and run tests for those packages too. dependency.json is manually maintained, if there is change tfjs package dependencies, please update dependency.json as well.
p.s.: Test of this PR will not be able to validate whether this works or not, because the change is in diff.js, which triggers all builds, and skip the added logic. In order to test the logic, in one of the debug commit, I removed diff.js from the whitelist and made some changes to Core, the build shows it works as expected. You can check the log in that build for commit e604026.
This change is