ros-tooling / setup-ros

Github Action to set up ROS 2 on hosts
Apache License 2.0
84 stars 39 forks source link

provide an option to run without sudo #631

Open christian-rauch opened 9 months ago

christian-rauch commented 9 months ago

Description

Inside Docker containers, processes usually run as root. The action uses sudo to install packages via apt. This has two downsides:

  1. You may have to install sudo to make the action work.
  2. Since sudo runs without -E environment variables are not forwarded.

Completion Criteria

The action should provide two options:

  1. flag to select if actions should run with or without sudo
  2. parameter to provide additional command line argument to sudo, e.g. -E.

Testing Notes / Suggestions

Add an additional test where the action runs as root without sudo being installed.

christophebedard commented 9 months ago

You may have to install sudo to make the action work.

Can you share an example GitHub action config where this would be necessary? I'm guessing this is only if your own Docker image doesn't have sudo OR if you run your own runners(?).

christian-rauch commented 9 months ago

Docker images without sudo are one issue. You can quickly check this with docker run --rm -ti ubuntu:22.04 bash -c "sudo apt update". This could be worked around by installing sudo in the image first, but it would still be nicer if you do not have to do this.

The main problem is that you cannot pass options to sudo, such as -E or --preserve-env.

christophebedard commented 8 months ago

Sounds reasonable to me. A PR would be appreciated :grin: