Skip to content

Commit

Permalink
Parsing full bash output is unreliable cross-platform - running inlin…
Browse files Browse the repository at this point in the history
…e is easier. But, this _still_ doesn't allow us to fail with existing semantics

Signed-off-by: Emerson Knapp <eknapp@amazon.com>
  • Loading branch information
Emerson Knapp committed Dec 31, 2020
1 parent 61234b7 commit 8e956e0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
10 changes: 5 additions & 5 deletions __tests__/ros-ci.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ describe("execBashCommand test suite", () => {
expect(mockGroup).toBeCalled();
expect(result).not.toEqual(0);
});
it("splits output lines in checkOutput", async () => {
const lines = await execBashCheckOutput('echo hi; echo hi');
console.log(lines);
expect(lines.length).toEqual(3); // newline at end of output adds 1
})
// it("splits output lines in checkOutput", async () => {
// const lines = await execBashCheckOutput('echo hi; echo hi');
// console.log(lines);
// expect(lines.length).toEqual(3); // newline at end of output adds 1
// });
});

describe("validate distribution test", () => {
Expand Down
22 changes: 10 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10624,13 +10624,13 @@ function validateDistros(ros1Distro, ros2Distro) {
return true;
}
exports.validateDistros = validateDistros;
function installRosdeps(fromPaths, distro, options) {
function installRosdeps(upToPackages, distro, options) {
return __awaiter(this, void 0, void 0, function* () {
const prefixVars = [
"DEBIAN_FRONTEND=noninteractive",
"RTI_NC_LICENSE_ACCEPTED=yes"
].join(" ");
return yield execBashCommand(`rosdep install -r --from-paths ${fromPaths.join(" ")} --ignore-src --rosdistro ${distro} -y || true`, prefixVars, options);
return yield execBashCommand(`rosdep install -r --from-paths $(colcon list -p --packages-up-to ${upToPackages}) --ignore-src --rosdistro ${distro} -y`, prefixVars, options);
});
}
function run() {
Expand All @@ -10643,8 +10643,7 @@ function run() {
const extraCmakeArgs = core.getInput("extra-cmake-args");
const colconExtraArgs = core.getInput("colcon-extra-args");
const importToken = core.getInput("import-token");
const packageName = core.getInput("package-name", { required: true });
const packageNameList = packageName.split(RegExp("\\s"));
const packageNames = core.getInput("package-name", { required: true }).split(RegExp("\\s")).join(" ");
const rosWorkspaceName = "ros_ws";
core.setOutput("ros-workspace-directory-name", rosWorkspaceName);
const rosWorkspaceDir = path.join(workspace, rosWorkspaceName);
Expand Down Expand Up @@ -10710,13 +10709,12 @@ function run() {
yield execBashCommand("vcs import --force --recursive src/ < package.repo", undefined, options);
// Install ROS dependencies for each distribution being sourced
// Only install dependencies for the specific paths of the packages being built, not necessarily every package in the workspace
const spaceSeparatedPackages = packageNameList.join(" ");
const desiredPackagePaths = yield execBashCheckOutput(`colcon list -p --packages-up-to ${spaceSeparatedPackages}`);
// const desiredPackagePaths = await execBashCheckOutput(`colcon list -p --packages-up-to ${packageNames}`);
if (targetRos1Distro) {
installRosdeps(desiredPackagePaths, targetRos1Distro, options);
installRosdeps(packageNames, targetRos1Distro, options);
}
if (targetRos2Distro) {
installRosdeps(desiredPackagePaths, targetRos2Distro, options);
installRosdeps(packageNames, targetRos2Distro, options);
}
if (colconMixinName !== "" && colconMixinRepo !== "") {
yield execBashCommand(`colcon mixin add default '${colconMixinRepo}'`);
Expand Down Expand Up @@ -10771,7 +10769,7 @@ function run() {
let colconBuildCmd = [
`colcon build`,
`--event-handlers console_cohesion+`,
`--packages-up-to ${packageNameList.join(" ")}`,
`--packages-up-to ${packageNames}`,
`${extra_options.join(" ")}`,
`--cmake-args ${extraCmakeArgs}`,
].join(" ");
Expand All @@ -10791,23 +10789,23 @@ function run() {
`--event-handlers console_cohesion+`,
`--pytest-with-coverage`,
`--return-code-on-test-failure`,
`--packages-select ${packageNameList.join(" ")}`,
`--packages-select ${packageNames}`,
`${extra_options.join(" ")}`,
].join(" ");
yield execBashCommand(colconTestCmd, colconCommandPrefix, options);
// ignoreReturnCode, check comment above in --initial
const colconLcovResultCmd = [
`colcon lcov-result`,
`--filter ${coverageIgnorePattern}`,
`--packages-select ${packageNameList.join(" ")}`,
`--packages-select ${packageNames}`,
].join(" ");
yield execBashCommand(colconLcovResultCmd, colconCommandPrefix, {
cwd: rosWorkspaceDir,
ignoreReturnCode: true,
});
const colconCoveragepyResultCmd = [
`colcon coveragepy-result`,
`--packages-select ${packageNameList.join(" ")}`,
`--packages-select ${packageNames}`,
].join(" ");
yield execBashCommand(colconCoveragepyResultCmd, colconCommandPrefix, options);
core.setOutput("ros-workspace-directory-name", rosWorkspaceName);
Expand Down
22 changes: 10 additions & 12 deletions src/action-ros-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function validateDistros(
}

async function installRosdeps(
fromPaths: string[],
upToPackages: string,
distro: string,
options?: im.ExecOptions
): Promise<number> {
Expand All @@ -175,7 +175,7 @@ async function installRosdeps(
"RTI_NC_LICENSE_ACCEPTED=yes"
].join(" ");
return await execBashCommand(
`rosdep install -r --from-paths ${fromPaths.join(" ")} --ignore-src --rosdistro ${distro} -y || true`,
`rosdep install -r --from-paths $(colcon list -p --packages-up-to ${upToPackages}) --ignore-src --rosdistro ${distro} -y`,
prefixVars,
options
);
Expand All @@ -191,8 +191,7 @@ async function run() {
const extraCmakeArgs = core.getInput("extra-cmake-args");
const colconExtraArgs = core.getInput("colcon-extra-args");
const importToken = core.getInput("import-token");
const packageName = core.getInput("package-name", { required: true });
const packageNameList = packageName.split(RegExp("\\s"));
const packageNames = core.getInput("package-name", { required: true }).split(RegExp("\\s")).join(" ");
const rosWorkspaceName = "ros_ws";
core.setOutput("ros-workspace-directory-name", rosWorkspaceName);
const rosWorkspaceDir = path.join(workspace, rosWorkspaceName);
Expand Down Expand Up @@ -283,13 +282,12 @@ async function run() {

// Install ROS dependencies for each distribution being sourced
// Only install dependencies for the specific paths of the packages being built, not necessarily every package in the workspace
const spaceSeparatedPackages = packageNameList.join(" ");
const desiredPackagePaths = await execBashCheckOutput(`colcon list -p --packages-up-to ${spaceSeparatedPackages}`);
// const desiredPackagePaths = await execBashCheckOutput(`colcon list -p --packages-up-to ${packageNames}`);
if (targetRos1Distro) {
installRosdeps(desiredPackagePaths, targetRos1Distro, options);
installRosdeps(packageNames, targetRos1Distro, options);
}
if (targetRos2Distro) {
installRosdeps(desiredPackagePaths, targetRos2Distro, options);
installRosdeps(packageNames, targetRos2Distro, options);
}

if (colconMixinName !== "" && colconMixinRepo !== "") {
Expand Down Expand Up @@ -348,7 +346,7 @@ async function run() {
let colconBuildCmd = [
`colcon build`,
`--event-handlers console_cohesion+`,
`--packages-up-to ${packageNameList.join(" ")}`,
`--packages-up-to ${packageNames}`,
`${extra_options.join(" ")}`,
`--cmake-args ${extraCmakeArgs}`,
].join(" ");
Expand All @@ -370,7 +368,7 @@ async function run() {
`--event-handlers console_cohesion+`,
`--pytest-with-coverage`,
`--return-code-on-test-failure`,
`--packages-select ${packageNameList.join(" ")}`,
`--packages-select ${packageNames}`,
`${extra_options.join(" ")}`,
].join(" ");
await execBashCommand(colconTestCmd, colconCommandPrefix, options);
Expand All @@ -379,7 +377,7 @@ async function run() {
const colconLcovResultCmd = [
`colcon lcov-result`,
`--filter ${coverageIgnorePattern}`,
`--packages-select ${packageNameList.join(" ")}`,
`--packages-select ${packageNames}`,
].join(" ");
await execBashCommand(colconLcovResultCmd, colconCommandPrefix, {
cwd: rosWorkspaceDir,
Expand All @@ -388,7 +386,7 @@ async function run() {

const colconCoveragepyResultCmd = [
`colcon coveragepy-result`,
`--packages-select ${packageNameList.join(" ")}`,
`--packages-select ${packageNames}`,
].join(" ");
await execBashCommand(
colconCoveragepyResultCmd,
Expand Down

0 comments on commit 8e956e0

Please sign in to comment.