Skip to content

Commit

Permalink
List only jazelle targets in jazelle changes (#869)
Browse files Browse the repository at this point in the history
https://github.com/uber/fusionjs/pull/869

Do not list bazel targets that are not tracked by jazelle's manifest.json. This change means `jazelle changes` won't report bazel targets that were not created by jazelle. This is useful for gradual migration of code into bazel while that code is not ready to be packagified as a NPM package (and/or if the code is non-JS)
  • Loading branch information
lhorie authored and fusionjs-sync-bot[bot] committed Feb 5, 2020
1 parent 8eb2da7 commit ca7fac9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bin/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function runMaster() {
for (const data of payload) {
if (data.length > 0) {
const requiredCores = Math.min(availableCores, data.length);
const workers = [...Array(requiredCores)].map(() => fork());
const workers = [...Array(requiredCores)].map(() => fork(process.env));

await install({
root,
Expand Down Expand Up @@ -79,7 +79,7 @@ async function runMaster() {
const command = data.shift();
const log = `${tmpdir()}/${Math.random() * 1e17}`;

if (worker.state === 'dead') worker = fork();
if (worker.state === 'dead') worker = fork(process.env);

worker.send({command, log});
worker.once('exit', async () => {
Expand Down
3 changes: 1 addition & 2 deletions commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ const {resolve} = require('path');
const {assertProjectDir} = require('../utils/assert-project-dir.js');
const {getManifest} = require('../utils/get-manifest.js');
const {getLocalDependencies} = require('../utils/get-local-dependencies.js');
const {node, yarn} = require('../utils/binary-paths.js');
const {exec, read, write} = require('../utils/node-helpers.js');
const {read, write} = require('../utils/node-helpers.js');
const {findLocalDependency} = require('../utils/find-local-dependency.js');
const {add: addDep} = require('../utils/lockfile.js');
const {install} = require('./install.js');
Expand Down
4 changes: 2 additions & 2 deletions commands/align.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type AlignArgs = {
type Align = (AlignArgs) => Promise<void>
*/
const align /*: Align */ = async ({root, cwd}) => {
const {projects, versionPolicy} = await getManifest({root});
const {projects, versionPolicy} = /*:: await */ await getManifest({root});
if (versionPolicy) {
const deps = await getAllDependencies({root, projects});
const meta = JSON.parse(await read(`${cwd}/package.json`, 'utf8'));
Expand Down Expand Up @@ -44,7 +44,7 @@ const shouldSyncVersions = ({versionPolicy, name}) => {
const {lockstep = false, exceptions = []} = versionPolicy;
return (
(lockstep && !exceptions.includes(name)) ||
(!lockstep && exceptions.include(name))
(!lockstep && exceptions.includes(name))
);
};

Expand Down
8 changes: 7 additions & 1 deletion commands/outdated.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ const {exec} = require('../utils/node-helpers.js');
const {node, yarn} = require('../utils/binary-paths.js');
const {minVersion, gt} = require('semver');

const outdated = async ({root}) => {
/*::
type OutdatedArgs = {
root: string,
};
type Outdated = (OutdatedArgs) => Promise<void>
*/
const outdated /*: Outdated */ = async ({root}) => {
const {projects} = await getManifest({root});
const locals = await getAllDependencies({root, projects});
const map = {};
Expand Down
8 changes: 6 additions & 2 deletions utils/find-changed-targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const findChangedBazelTargets = async ({root, files}) => {
const targets = result.split('\n').filter(Boolean);
return {workspace, targets};
} else {
const projects = await batch(root, lines, async file => {
const queried = await batch(root, lines, async file => {
const find = `${bazel} query "${file}"`;
const result = await exec(find, opts).catch(async e => {
// if file doesn't exist, find which package it would've belong to, and find another file in the same package
Expand All @@ -66,10 +66,14 @@ const findChangedBazelTargets = async ({root, files}) => {
const project = await exec(cmd, opts);
return project;
});
const targets = await batch(root, projects, async project => {
const unfiltered = await batch(root, queried, async project => {
const cmd = `${bazel} query 'let graph = kind(".*_test rule", rdeps("...", "${project}")) in $graph except filter("node_modules", $graph)'`;
return exec(cmd, opts);
});
const targets = unfiltered.filter(target => {
const path = target.replace(/\/\/(.+?):.+/, '$1');
return projects.includes(path);
});
return {workspace, targets};
}
} else {
Expand Down

0 comments on commit ca7fac9

Please sign in to comment.