Skip to content

Commit c25076f

Browse files
authored
Bug fix: fail the action when catching exception from cli command (#13)
* Bug fix: fail the action when catching exception from cli command - We need to fail the action whenever there is an exception, we already did that in multiple places except in fetchRosinstallDependencies and getSampleAppVersion
1 parent 0efdc92 commit c25076f

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

robomaker-sample-app-ci/dist/index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -724,24 +724,27 @@ function getSampleAppVersion() {
724724
], getWorkingDirExecOptions(grepAfter));
725725
version = grepAfter.stdout.trim();
726726
}
727-
catch (err) {
728-
console.error(err);
727+
catch (error) {
728+
core.setFailed(error.message);
729729
}
730730
return Promise.resolve(version);
731731
});
732732
}
733-
// If .rosinstall exists, run 'rosws update' and return a list of names of the packages that were added.
733+
// If .rosinstall exists, run 'vcs import' and return a list of names of the packages that were added in both workspaces.
734734
function fetchRosinstallDependencies() {
735735
return __awaiter(this, void 0, void 0, function* () {
736736
let colconListAfter = { stdout: '', stderr: '' };
737737
let packages = [];
738738
// Download dependencies not in apt if .rosinstall exists
739739
try {
740+
// When generate-sources: true, the expected behavior is to include sources from both workspaces including their dependencies.
741+
// In order to make generate-sources work as expected, dependencies are fetched in both the workspaces here.
740742
for (let workspace of ["robot_ws", "simulation_ws"]) {
741743
if (fs.existsSync(path.join(workspace, '.rosinstall'))) {
742-
yield exec.exec("vcs", ["import", "--input", ".rosinstall"], {cwd: workspace});
744+
yield exec.exec("vcs", ["import", "--input", ".rosinstall"], { cwd: workspace });
743745
}
744746
}
747+
// this is outside the loop as we don't want to build both the dependency packages
745748
if (fs.existsSync(path.join(WORKSPACE_DIRECTORY, '.rosinstall'))) {
746749
yield exec.exec("colcon", ["list", "--names-only"], getWorkingDirExecOptions(colconListAfter));
747750
const packagesAfter = colconListAfter.stdout.split("\n");
@@ -750,13 +753,12 @@ function fetchRosinstallDependencies() {
750753
});
751754
}
752755
}
753-
catch (err) {
754-
console.error(err);
756+
catch (error) {
757+
core.setFailed(error.message);
755758
}
756759
return Promise.resolve(packages);
757760
});
758761
}
759-
760762
function setup() {
761763
return __awaiter(this, void 0, void 0, function* () {
762764
try {

robomaker-sample-app-ci/src/aws-robomaker-sample-application-ci.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ async function getSampleAppVersion() : Promise<string> {
6666
"find ../robot_ws -name package.xml -exec grep -Po '(?<=<version>)[^\\s<>]*(?=</version>)' {} +"],
6767
getWorkingDirExecOptions(grepAfter));
6868
version = grepAfter.stdout.trim();
69-
} catch(err) {
70-
console.error(err);
69+
} catch(error) {
70+
core.setFailed(error.message);
7171
}
7272
return Promise.resolve(version);
7373
}
@@ -93,8 +93,8 @@ async function fetchRosinstallDependencies(): Promise<string[]> {
9393
packages.push(packageName.trim());
9494
});
9595
}
96-
} catch(err) {
97-
console.error(err);
96+
} catch(error) {
97+
core.setFailed(error.message);
9898
}
9999
return Promise.resolve(packages);
100100
}

0 commit comments

Comments
 (0)