Skip to content

Commit

Permalink
Add support for building and testing multiple packages (#39)
Browse files Browse the repository at this point in the history
Fix #33

Signed-off-by: Thomas Moulard <tmoulard@amazon.com>
  • Loading branch information
Thomas Moulard authored Dec 3, 2019
1 parent 9a0f4ea commit d4bfc7e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
colcon-mixin-name: asan
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
package-name: ament_copyright
package-name: ament_copyright ament_lint
- uses: actions/upload-artifact@master
with:
name: colcon-logs
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ inputs:
description: 'Mixin repository containing the mixin specified in colcon-mixin-name'
required: false
package-name:
description: 'Name of the package under test, as expected by colcon'
description: |
Name of the package(s) under test, as expected by colcon.
Passing multiple package names is allowed.
Package names can be separated by any whitespace character.
required: true
runs:
using: 'node12'
Expand Down
21 changes: 10 additions & 11 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4783,7 +4783,8 @@ function run() {
const workspace = process.env.GITHUB_WORKSPACE;
const colconMixinName = core.getInput("colcon-mixin-name");
const colconMixinRepo = core.getInput("colcon-mixin-repository");
const packageName = core.getInput("package-name");
const packageName = core.getInput("package-name", { required: true });
const packageNameList = packageName.split(RegExp('\\s'));
const ros2WorkspaceDir = path.join(workspace, "ros2_ws");
// rosdep on Windows does not reliably work on Windows, see
// ros-infrastructure/rosdep#610 for instance. So, we do not run it.
Expand Down Expand Up @@ -4830,7 +4831,7 @@ EOF`
// avoid having rosdep installing unrequired dependencies.
yield exec.exec("bash", [
"-c",
`diff --new-line-format="" --unchanged-line-format="" <(colcon list -p) <(colcon list --packages-up-to ${packageName} -p) | xargs rm -rf`
`diff --new-line-format="" --unchanged-line-format="" <(colcon list -p) <(colcon list --packages-up-to ${packageNameList.join(' ')} -p) | xargs rm -rf`
], options);
// For "latest" builds, rosdep often misses some keys, adding "|| true", to
// ignore those failures, as it is often non-critical.
Expand Down Expand Up @@ -4864,24 +4865,22 @@ EOF`
"build",
"--event-handlers",
"console_cohesion+",
"--packages-up-to",
packageName,
"--symlink-install"
].concat(extra_options), options);
"--symlink-install",
"--packages-up-to"
].concat(packageNameList).concat(extra_options), options);
yield exec.exec("colcon", [
"test",
"--event-handlers",
"console_cohesion+",
"--pytest-args",
"'--cov=.'",
"'--cov-report=xml'",
"--packages-select",
packageName,
"--return-code-on-test-failure"
].concat(extra_options), options);
"--return-code-on-test-failure",
"--packages-select"
].concat(packageNameList).concat(extra_options), options);
// ignoreReturnCode is set to true to avoid having a lack of coverage
// data fail the build.
yield exec.exec("colcon", ["lcov-result", "--packages-select", packageName], { ignoreReturnCode: true });
yield exec.exec("colcon", ["lcov-result", "--packages-select"].concat(packageNameList), { ignoreReturnCode: true });
}
catch (error) {
core.setFailed(error.message);
Expand Down
27 changes: 16 additions & 11 deletions src/action-ros2-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ async function run() {

const colconMixinName = core.getInput("colcon-mixin-name");
const colconMixinRepo = core.getInput("colcon-mixin-repository");
const packageName = core.getInput("package-name");
const packageName = core.getInput("package-name", { required: true });
const packageNameList = packageName.split(RegExp("\\s"));
const ros2WorkspaceDir = path.join(workspace, "ros2_ws");

// rosdep on Windows does not reliably work on Windows, see
Expand Down Expand Up @@ -74,7 +75,9 @@ EOF`
"bash",
[
"-c",
`diff --new-line-format="" --unchanged-line-format="" <(colcon list -p) <(colcon list --packages-up-to ${packageName} -p) | xargs rm -rf`
`diff --new-line-format="" --unchanged-line-format="" <(colcon list -p) <(colcon list --packages-up-to ${packageNameList.join(
" "
)} -p) | xargs rm -rf`
],
options
);
Expand Down Expand Up @@ -121,10 +124,11 @@ EOF`
"build",
"--event-handlers",
"console_cohesion+",
"--packages-up-to",
packageName,
"--symlink-install"
].concat(extra_options),
"--symlink-install",
"--packages-up-to"
]
.concat(packageNameList)
.concat(extra_options),
options
);
await exec.exec(
Expand All @@ -136,18 +140,19 @@ EOF`
"--pytest-args",
"'--cov=.'",
"'--cov-report=xml'",
"--packages-select",
packageName,
"--return-code-on-test-failure"
].concat(extra_options),
"--return-code-on-test-failure",
"--packages-select"
]
.concat(packageNameList)
.concat(extra_options),
options
);

// ignoreReturnCode is set to true to avoid having a lack of coverage
// data fail the build.
await exec.exec(
"colcon",
["lcov-result", "--packages-select", packageName],
["lcov-result", "--packages-select"].concat(packageNameList),
{ ignoreReturnCode: true }
);
} catch (error) {
Expand Down

0 comments on commit d4bfc7e

Please sign in to comment.