MCPcopy
hub / github.com/tensorflow/tfjs / generateCloudbuild

Function generateCloudbuild

scripts/generate_cloudbuild.ts:64–215  ·  view source on GitHub ↗
(packages: Iterable<string>, nightly = false, print = true)

Source from the content-addressed store, hash-verified

62 * 3. Builds and tests all the reverse dependnecies of `packages`
63 */
64export function generateCloudbuild(packages: Iterable<string>, nightly = false, print = true) {
65 // Make sure all packages are declared in package_dependencies.json.
66 const allPackages = new Set(Object.keys(DEPENDENCY_GRAPH));
67 for (const packageName of packages) {
68 if (!allPackages.has(packageName) &&
69 // TODO: remove this check once tfjs-react-native nightly test is fixed.
70 packageName !== 'tfjs-react-native') {
71 throw new Error(
72 `Package ${packageName} was not declared in ` +
73 'package_dependencies.json');
74 }
75 }
76
77 const deps = findDeps(packages);
78 const reverseDeps = findReverseDeps(packages);
79 const depsOfReverseDeps = findDeps(reverseDeps);
80
81 const toBuild =
82 new Set([...deps, ...packages, ...reverseDeps, ...depsOfReverseDeps]);
83 const toTest = new Set([...packages, ...reverseDeps]);
84
85 if (print) {
86 // Log what will be built and tested
87 const buildTestTable = [];
88 for (const packageName of allPackages) {
89 const bazel = BAZEL_PACKAGES.has(packageName);
90 const bazelStr = 'bazel '; // Spaces for left alignment
91 buildTestTable.push({
92 'Package': packageName,
93 'Will Build': bazel ? bazelStr : toBuild.has(packageName) ? '✔' : '',
94 'Will Test': bazel ? bazelStr : toTest.has(packageName) ? '✔' : '',
95 });
96 }
97 printTable(buildTestTable);
98 }
99
100 // Load the general cloudbuild config
101 const baseCloudbuild =
102 yaml.load(fs.readFileSync(path.join(
103 __dirname, 'cloudbuild_general_config.yml'), 'utf8')) as CloudbuildYaml;
104
105 // Filter steps that only run in nightly tests.
106 const nightlyFilter = (step: CustomCloudbuildStep) => nightly || !step.nightlyOnly;
107 const customSteps = baseCloudbuild.steps.filter(nightlyFilter);
108
109 // Steps that are waited for by non-bazel packages.
110 const waitedForByPackages = customSteps
111 .filter(step => step.waitedForByPackages)
112 .map(step => step.id);
113
114 const steps = customSteps.map(removeCustomProps);
115
116 // Load all the cloudbuild files for the packages
117 // that need to be built or tested.
118 const packageCloudbuildSteps = new Map<string, Set<CloudbuildStep>>();
119 for (const packageName of new Set([...toBuild, ...toTest])) {
120 if (BAZEL_PACKAGES.has(packageName)) {
121 // Do not build or test Bazel packages. The bazel-tests step does this.

Calls 12

findDepsFunction · 0.90
findReverseDepsFunction · 0.90
isTestStepFunction · 0.85
makeStepIdFunction · 0.85
hasMethod · 0.80
joinMethod · 0.80
deleteMethod · 0.80
addMethod · 0.65
pushMethod · 0.45
loadMethod · 0.45
setMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…