Skip to content

Commit

Permalink
Remove colcon-mixin-name (#591)
Browse files Browse the repository at this point in the history
* Remove colcon-mixin-name
* Make sure to delete /root/.colcon as well for Docker jobs
* Make sure to inherit environment instead of completely overwriting it
Signed-off-by: Christophe Bedard <[email protected]>
  • Loading branch information
christophebedard authored Mar 23, 2021
1 parent 3018c9a commit ce324ec
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 39 deletions.
28 changes: 24 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,12 @@ jobs:
id: test_mixin
name: "Test single package, with custom mixin"
with:
colcon-mixin-name: asan
colcon-defaults: |
{
"build": {
"mixin": ["asan-gcc"]
}
}
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
package-name: ament_copyright
target-ros2-distro: ${{ matrix.ros_distribution }}
Expand Down Expand Up @@ -289,7 +294,12 @@ jobs:
id: test_coverage
name: "Test single package, with coverage enabled (Linux only)"
with:
colcon-mixin-name: coverage-gcc
colcon-defaults: |
{
"build": {
"mixin": ["coverage-gcc"]
}
}
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
package-name: osrf_testing_tools_cpp
target-ros2-distro: ${{ matrix.ros_distribution }}
Expand Down Expand Up @@ -391,7 +401,12 @@ jobs:
id: test_mixin
name: "Test single package, with custom mixin"
with:
colcon-mixin-name: asan
colcon-defaults: |
{
"build": {
"mixin": ["asan-gcc"]
}
}
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
package-name: ament_copyright
target-ros2-distro: ${{ matrix.ros_distribution }}
Expand Down Expand Up @@ -428,7 +443,12 @@ jobs:
id: test_coverage
name: "Test single package, with coverage enabled (Linux only)"
with:
colcon-mixin-name: coverage-gcc
colcon-defaults: |
{
"build": {
"mixin": ["coverage-gcc"]
}
}
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
package-name: osrf_testing_tools_cpp
target-ros2-distro: ${{ matrix.ros_distribution }}
Expand Down
49 changes: 35 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ steps:
required-ros-distributions: foxy
- uses: ros-tooling/[email protected]
with:
colcon-mixin-name: asan
colcon-defaults: |
{
"build": {
"mixin": ["asan-gcc"]
}
}
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/3e627e0fa30db85aea05a50e2c61a9832664d236/index.yaml
package-name: my_package
target-ros2-distro: foxy
Expand All @@ -194,12 +199,11 @@ ASan is analyzing memory issues at runtime. ASan diagnostic messages will be emi

#### Generate code coverage information using `lcov` and `colcon-lcov-result`

If the compiler is invoked with the appropriate flags, `action-ros-ci` will use
[`colcon-lcov-result`](https://github.com/colcon/colcon-lcov-result) to generate
coverage information.
Generate code coverage information for C/C++ files using the appropriate mixins for `gcc`.
`action-ros-ci` uses [`colcon-lcov-result`](https://github.com/colcon/colcon-lcov-result) to aggregate generated coverage information.

Flags can be passed manually using, for instance, `extra-cmake-args`, but it is
preferable to use a `colcon` mixin to pass the appropriate flags automatically.
preferable to use a `colcon` mixin (through [`colcon-defaults`](#Use-a-colcon-defaultsyaml-file)) to pass the appropriate flags automatically.

```yaml
steps:
Expand All @@ -210,20 +214,21 @@ steps:
with:
package-name: my_package
target-ros2-distro: foxy
colcon-mixin-name: coverage-gcc
colcon-defaults: |
{
"build": {
"mixin": ["coverage-gcc"]
}
}
# If possible, pin the repository in the workflow to a specific commit to avoid
# changes in colcon-mixin-repository from breaking your tests.
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/1ddb69bedfd1f04c2f000e95452f7c24a4d6176b/index.yaml
```

#### Generate code coverage information using `coveragepy` and `colcon-coveragepy-result`

If `colcon` is invoked with the `coverage-pytest` mixin, `action-ros-ci` will use
[`colcon-coveragepy-result`](https://github.com/colcon/colcon-coveragepy-result) to generate
coverage information.

Flags can be passed manually using, for instance, `extra-cmake-args`, but it is
preferable to use a `colcon` mixin to pass the appropriate flags automatically.
Generate code coverage information for Python files using the appropriate mixins.
`action-ros-ci` uses [`colcon-coveragepy-result`](https://github.com/colcon/colcon-coveragepy-result) to aggregate generated coverage information.

```yaml
steps:
Expand All @@ -234,7 +239,15 @@ steps:
with:
package-name: my_package
target-ros2-distro: foxy
colcon-mixin-name: coverage-pytest
colcon-defaults: |
{
"build": {
"mixin": ["coverage-pytest"]
},
"test": {
"mixin": ["coverage-pytest"]
}
}
# If possible, pin the repository in the workflow to a specific commit to avoid
# changes in colcon-mixin-repository from breaking your tests.
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/1ddb69bedfd1f04c2f000e95452f7c24a4d6176b/index.yaml
Expand All @@ -257,7 +270,15 @@ steps:
with:
package-name: my_package
target-ros2-distro: foxy
colcon-mixin-name: coverage-gcc coverage-pytest
colcon-defaults: |
{
"build": {
"mixin": ["coverage-gcc", "coverage-pytest"]
},
"test": {
"mixin": ["coverage-pytest"]
}
}
# If possible, pin the repository in the workflow to a specific commit to avoid
# changes in colcon-mixin-repository from breaking your tests.
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/1ddb69bedfd1f04c2f000e95452f7c24a4d6176b/index.yaml
Expand Down
8 changes: 2 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ inputs:
Use a pipe to provide a multiline string.
See: https://colcon.readthedocs.io/en/released/user/configuration.html#defaults-yaml
required: false
colcon-mixin-name:
default: ""
description: "Colcon mixin to be used to compile and test (empty means no mixin)"
required: false
colcon-mixin-repository:
default: "https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml"
description: "Mixin repository containing the mixin specified in colcon-mixin-name"
description: "Mixin repository containing the mixin(s) specified through colcon-defaults or colcon-extra-args"
required: false
coverage-ignore-pattern:
description: |
Expand All @@ -33,7 +29,7 @@ inputs:
colcon-extra-args:
default: ""
description: |
Arbitrary space-separated additional flags to pass to colcon.
Arbitrary space-separated additional flags to pass to colcon (build & test).
required: false
import-token:
default: ""
Expand Down
18 changes: 9 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10949,6 +10949,9 @@ function execBashCommand(commandLine, commandPrefix, options, log_message) {
toolRunnerCommandLineArgs = ["-c", bashScript];
}
const runner = new tr.ToolRunner(toolRunnerCommandLine, toolRunnerCommandLineArgs, options);
if (options && options.silent) {
return runner.exec();
}
return core.group(message, () => {
return runner.exec();
});
Expand Down Expand Up @@ -11009,7 +11012,6 @@ function run() {
const repo = github.context.repo;
const workspace = process.env.GITHUB_WORKSPACE;
const colconDefaults = core.getInput("colcon-defaults");
const colconMixinName = core.getInput("colcon-mixin-name");
const colconMixinRepo = core.getInput("colcon-mixin-repository");
const extraCmakeArgs = core.getInput("extra-cmake-args");
const colconExtraArgs = core.getInput("colcon-extra-args");
Expand Down Expand Up @@ -11089,10 +11091,11 @@ function run() {
cwd: rosWorkspaceDir,
};
if (colconDefaultsFile !== "") {
options.env = {
COLCON_DEFAULTS_FILE: colconDefaultsFile,
};
options.env = Object.assign(Object.assign({}, process.env), { COLCON_DEFAULTS_FILE: colconDefaultsFile });
}
// Make sure to delete root .colcon directory if it exists
// This is because, for some reason, using Docker, commands might get run as root
yield execBashCommand(`rm -rf ${path.join(path.sep, "root", ".colcon")} || true`, undefined, Object.assign(Object.assign({}, options), { silent: true }));
const curlFlags = curlFlagsArray.join(" ");
for (const vcsRepoFileUrl of vcsRepoFileUrlListResolved) {
yield execBashCommand(`curl ${curlFlags} '${vcsRepoFileUrl}' | vcs import --force --recursive src/`, undefined, options);
Expand Down Expand Up @@ -11142,14 +11145,11 @@ done`;
// Print HEAD commits of all repos
yield execBashCommand("vcs log -l1 src/", undefined, options);
yield installRosdeps(packageNames, rosWorkspaceDir, targetRos1Distro, targetRos2Distro);
if (colconMixinName !== "" && colconMixinRepo !== "") {
if (colconDefaults.includes(`"mixin"`) && colconMixinRepo !== "") {
yield execBashCommand(`colcon mixin add default '${colconMixinRepo}'`, undefined, options);
yield execBashCommand("colcon mixin update default", undefined, options);
}
let extra_options = [];
if (colconMixinName !== "") {
extra_options = extra_options.concat(["--mixin", colconMixinName]);
}
if (colconExtraArgs !== "") {
extra_options = extra_options.concat(colconExtraArgs);
}
Expand Down Expand Up @@ -11197,7 +11197,7 @@ done`;
`--event-handlers console_cohesion+`,
`--packages-up-to ${packageNames}`,
`${extra_options.join(" ")}`,
`--cmake-args ${extraCmakeArgs}`,
extraCmakeArgs !== "" ? `--cmake-args ${extraCmakeArgs}` : "",
].join(" ");
if (!isWindows) {
colconBuildCmd = colconBuildCmd.concat(" --symlink-install");
Expand Down
20 changes: 14 additions & 6 deletions src/action-ros-ci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export async function execBashCommand(
toolRunnerCommandLineArgs,
options
);
if (options && options.silent) {
return runner.exec();
}
return core.group(message, () => {
return runner.exec();
});
Expand Down Expand Up @@ -211,7 +214,6 @@ async function run() {
const workspace = process.env.GITHUB_WORKSPACE as string;

const colconDefaults = core.getInput("colcon-defaults");
const colconMixinName = core.getInput("colcon-mixin-name");
const colconMixinRepo = core.getInput("colcon-mixin-repository");
const extraCmakeArgs = core.getInput("extra-cmake-args");
const colconExtraArgs = core.getInput("colcon-extra-args");
Expand Down Expand Up @@ -322,10 +324,19 @@ async function run() {
};
if (colconDefaultsFile !== "") {
options.env = {
...process.env,
COLCON_DEFAULTS_FILE: colconDefaultsFile,
};
}

// Make sure to delete root .colcon directory if it exists
// This is because, for some reason, using Docker, commands might get run as root
await execBashCommand(
`rm -rf ${path.join(path.sep, "root", ".colcon")} || true`,
undefined,
{ ...options, silent: true }
);

const curlFlags = curlFlagsArray.join(" ");
for (const vcsRepoFileUrl of vcsRepoFileUrlListResolved) {
await execBashCommand(
Expand Down Expand Up @@ -395,7 +406,7 @@ done`;
targetRos2Distro
);

if (colconMixinName !== "" && colconMixinRepo !== "") {
if (colconDefaults.includes(`"mixin"`) && colconMixinRepo !== "") {
await execBashCommand(
`colcon mixin add default '${colconMixinRepo}'`,
undefined,
Expand All @@ -405,9 +416,6 @@ done`;
}

let extra_options: string[] = [];
if (colconMixinName !== "") {
extra_options = extra_options.concat(["--mixin", colconMixinName]);
}
if (colconExtraArgs !== "") {
extra_options = extra_options.concat(colconExtraArgs);
}
Expand Down Expand Up @@ -457,7 +465,7 @@ done`;
`--event-handlers console_cohesion+`,
`--packages-up-to ${packageNames}`,
`${extra_options.join(" ")}`,
`--cmake-args ${extraCmakeArgs}`,
extraCmakeArgs !== "" ? `--cmake-args ${extraCmakeArgs}` : "",
].join(" ");
if (!isWindows) {
colconBuildCmd = colconBuildCmd.concat(" --symlink-install");
Expand Down

0 comments on commit ce324ec

Please sign in to comment.