Skip to content

Commit

Permalink
feat(colcon-build): enable cpu resource control (#309)
Browse files Browse the repository at this point in the history
Signed-off-by: M. Fatih Cırıt <[email protected]>
  • Loading branch information
xmfcx authored Aug 20, 2024
1 parent 89245b3 commit 0dbf0d4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
22 changes: 12 additions & 10 deletions colcon-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ jobs:
## Inputs
| Name | Required | Description |
| ------------------- | -------- | ---------------------------------------------------------------------------- |
| rosdistro | true | ROS distro. |
| target-packages | true | The target packages to build. |
| build-depends-repos | false | The `.repos` file that includes build dependencies. |
| cmake-build-type | false | The value for `CMAKE_BUILD_TYPE`. |
| token | false | The token for build dependencies. |
| include-eol-distros | false | If true, adds `--include-eol-distros` to `rosdep update`. |
| cache-key-element | false | This value is added to the github actions cache key. |
| nice-command | false | This command is prepended to the `colcon build` to avoid draining resources. |
| Name | Required | Description |
| ---------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| rosdistro | true | ROS distro. |
| target-packages | true | The target packages to build. |
| build-depends-repos | false | The `.repos` file that includes build dependencies. |
| cmake-build-type | false | The value for `CMAKE_BUILD_TYPE`. |
| token | false | The token for build dependencies. |
| include-eol-distros | false | If true, adds `--include-eol-distros` to `rosdep update`. |
| cache-key-element | false | This value is added to the github actions cache key. |
| nice-command | false | This command is prepended to the `colcon build` to avoid draining resources. |
| colcon-parallel-workers-flag | false | Will be appended to the colcon build command to limit number of packages built in parallel. e.g. "--parallel-workers 3" |
| makeflags | false | Will be exported as MAKEFLAGS environment variable for colcon build step. e.g. "-j 4" |

## Outputs

Expand Down
13 changes: 12 additions & 1 deletion colcon-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ inputs:
description: See `man nice` for details
required: false
default: nice -n 19
colcon-parallel-workers-flag:
description: Will be appended to the colcon build command to limit number of packages built in parallel. e.g. "--parallel-workers 3"
default: ""
required: false
makeflags:
description: Will be exported as MAKEFLAGS environment variable. e.g. "-j 4"
default: ""
required: false

runs:
using: composite
Expand Down Expand Up @@ -84,7 +92,10 @@ runs:
cat /etc/nsswitch.conf
sed -e 's#hosts:\(.*\)dns\(.*\)#hosts:\1\2#g' -i.bak /etc/nsswitch.conf
cat /etc/nsswitch.conf
${{ inputs.nice-command }} colcon build --event-handlers console_cohesion+ \
MAKEFLAGS="${{ inputs.makeflags }}"
echo "MAKEFLAGS=$MAKEFLAGS" # for debugging
${{ inputs.nice-command }} colcon build ${{ inputs.colcon-parallel-workers-flag }} \
--event-handlers console_cohesion+ \
--packages-above-and-dependencies ${{ inputs.target-packages }} \
--cmake-args -DCMAKE_BUILD_TYPE=${{ inputs.cmake-build-type }} \
--mixin coverage-gcc coverage-pytest compile-commands
Expand Down

0 comments on commit 0dbf0d4

Please sign in to comment.