Skip to content

Commit

Permalink
[Bazel] More resilient Workspace Status (#93244) (#93273)
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>

Co-authored-by: Tyler Smalley <tyler.smalley@elastic.co>
  • Loading branch information
kibanamachine and Tyler Smalley authored Mar 2, 2021
1 parent e709686 commit 08417cb
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/dev/bazel_workspace_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,23 @@

// Commit SHA
const commitSHACmdResult = await runCmd('git', ['rev-parse', 'HEAD']);
if (commitSHACmdResult.exitCode !== 0) {
process.exit(1);
}
console.log(`COMMIT_SHA ${commitSHACmdResult.stdout}`);
if (commitSHACmdResult.exitCode === 0) {
console.log(`COMMIT_SHA ${commitSHACmdResult.stdout}`);

// Git branch
const gitBranchCmdResult = await runCmd('git', ['rev-parse', '--abbrev-ref', 'HEAD']);
if (gitBranchCmdResult.exitCode !== 0) {
process.exit(1);
}
console.log(`GIT_BRANCH ${gitBranchCmdResult.stdout}`);
// Branch
const gitBranchCmdResult = await runCmd('git', ['rev-parse', '--abbrev-ref', 'HEAD']);
if (gitBranchCmdResult.exitCode === 0) {
console.log(`GIT_BRANCH ${gitBranchCmdResult.stdout}`);
}

// Tree status
const treeStatusCmdResult = await runCmd('git', ['diff-index', '--quiet', 'HEAD', '--']);
const treeStatusVarStr = 'GIT_TREE_STATUS';
if (treeStatusCmdResult.exitCode === 0) {
console.log(`${treeStatusVarStr} Clean`);
} else {
console.log(`${treeStatusVarStr} Modified`);
// Tree status
const treeStatusCmdResult = await runCmd('git', ['diff-index', '--quiet', 'HEAD', '--']);
const treeStatusVarStr = 'GIT_TREE_STATUS';
if (treeStatusCmdResult.exitCode === 0) {
console.log(`${treeStatusVarStr} Clean`);
} else {
console.log(`${treeStatusVarStr} Modified`);
}
}

// Host
Expand All @@ -72,9 +70,8 @@
return !cpu.model.includes('Intel') || index % 2 === 1;
}).length;

if (hostCmdResult.exitCode !== 0) {
process.exit(1);
if (hostCmdResult.exitCode === 0) {
console.log(`HOST ${hostStr}-${coresStr}`);
}
console.log(`HOST ${hostStr}-${coresStr}`);
}
})();

0 comments on commit 08417cb

Please sign in to comment.