Skip to content

Commit b0b983b

Browse files
Add build-deps to CI script
1 parent 7a5ec2d commit b0b983b

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

coral-tflite-delegate/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"license": "Apache-2.0",
77
"scripts": {
88
"build": "tsc",
9+
"build-deps": "cd ../tfjs-tflite-node && yarn build",
910
"test-dev": "jasmine --config=jasmine.json",
1011
"test": "yarn build && yarn test-dev",
1112
"test-integration-dev": "jasmine --config=jasmine-integration.json",

presubmit.ts

+10-26
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,7 @@ parentDirs.forEach(curParentDir => {
3939
dirs.push(...curDirs.map(curDir => join(curParentDir, curDir)));
4040
})
4141

42-
// TODO(mattsoulanille): Packages are not sorted based on dependencies. There
43-
// are a few ways to fix this:
44-
// 1. Use only npm versions of packages, so they don't depend on each other.
45-
// 2. Parse package.json and implement topological sort here.
46-
// 3. Use something like Lerna or TurboRepo.
47-
// The current approach is just to enforce order in a subset of the packages.
48-
// It's not a scalabe approach.
49-
const dependenciesInOrder = new Set([
50-
'tfjs-tflite-node', 'coral-tflite-delegate']);
51-
const dirsSet = new Set(dirs);
52-
for (const dep of dependenciesInOrder) {
53-
if (!dirsSet.has(dep)) {
54-
throw new Error(`Directory missing for manually added dependency ${dep}`);
55-
}
56-
}
57-
for (const dir of dirsSet) {
58-
if (dependenciesInOrder.has(dir)) {
59-
dirsSet.delete(dir);
60-
}
61-
}
62-
const sortedDirs = [...dirsSet, ...dependenciesInOrder];
63-
64-
sortedDirs.forEach(dir => {
42+
dirs.forEach(dir => {
6543
shell.cd(dir);
6644

6745
if (!fs.existsSync('./package.json')) {
@@ -71,21 +49,27 @@ sortedDirs.forEach(dir => {
7149

7250
const packageJSON: {'scripts': {[key: string]: string}} =
7351
JSON.parse(fs.readFileSync('./package.json', {encoding: 'utf-8'}));
52+
console.log(`~~~~~~~~~~~~ Running yarn in ${dir} ~~~~~~~~~~~~`);
53+
shell.exec('yarn');
54+
55+
if (packageJSON['scripts']['build-deps'] != null) {
56+
console.log(`~~~~~~~~~~~~ Building deps for ${dir} ~~~~~~~~~~~~`);
57+
shell.exec('yarn build-deps');
58+
console.log('\n');
59+
}
60+
7461
if (packageJSON['scripts']['test-ci'] != null) {
7562
console.log(`~~~~~~~~~~~~ Testing ${dir} ~~~~~~~~~~~~`);
76-
shell.exec('yarn');
7763
shell.exec('yarn test-ci');
7864
console.log('\n');
7965
} else if (packageJSON['scripts']['test'] != null) {
8066
console.log(`~~~~~~~~~~~~ Testing ${dir} ~~~~~~~~~~~~`);
81-
shell.exec('yarn');
8267
shell.exec('yarn test');
8368
console.log('\n');
8469
}
8570

8671
if (packageJSON['scripts']['lint'] != null) {
8772
console.log(`~~~~~~~~~~~~ Linting ${dir} ~~~~~~~~~~~~`);
88-
shell.exec('yarn');
8973
shell.exec('yarn lint');
9074
console.log('\n');
9175
}

0 commit comments

Comments
 (0)