自托管 github runner 在哪里执行代码?在同一台机器上有多个跑步者是一个好习惯吗?

Where does self hosted github runner executes the code? Is having multiple runners on same machine a good practice?

最近我在我自己托管的 GitHub 运行 用户上尝试了 运行ning 构建测试。我知道的一件事是它 运行 在其隔离的虚拟环境中并在执行结束时破坏环境(如果我错了请纠正我)。现在如果我们想控制环境进行调试,我们如何才能访问这个虚拟环境?

另外,为了安装多个 运行 用户,我为多个 运行 用户创建了多个文件夹,这样我就可以 运行 使用同一台机器并行进行测试。如果一个 运行ner 在隔离的虚拟环境中 运行ning,那么执行一个 运行ner 是否有可能中断其他 运行ner 的执行?

Where does self hosted github runner executes the code?

One thing I know that it runs in its isolated virtual environment and destroys the environment at the end of the execution (Correct me if I am wrong)

这仅适用于 GitHub 托管的运行器,但不适用于自托管的运行器。与 GitHub 托管的运行器相比,自托管运行器的实现方式略有不同。根据the documentation

each GitHub-hosted runner is always a clean isolated virtual machine, and it is destroyed at the end of the job execution

自托管运行器作为常规进程实现,没有虚拟化或与它们 运行 所在的 OS 隔离。这意味着 GitHub 操作工作流作业执行引起的任何副作用对 OS 中的每个进程 运行 都是可见的。任何文件系统修改也会在工作流的执行过程中持续存在(例如,安装依赖项将对稍后在同一运行器上执行的其他工作流可见,甚至对设置在同一 OS 上的其他运行器可见 - 就像在你的案件)。所以你必须知道,一旦运行器设置好,它在执行作业之间是有状态的。这个事实暗示了一些 security drawbacks. You can read more about the differences between GitHub-hosted and self-hosted runners here.

Now if we want to take control of the environment to debug how can we get access to this virtual environment?

作为多个运行器提供基本调试功能logging levels. If this is not enough you can also use a dedicated tmate debug action or search for the other debug-related actions you can find on theGitHub Marketplace

Is there a chance that execution of one runner can interrupt execution on other runner if they are running on isolated virtual environments?

如上所述,自托管运行器不使用虚拟环境,而是使用现有的 OS 环境。但是,在相同 OS 上设置的每个运行器都独立于其他运行器执行工作流作业。当然,由一名跑步者的工作引起的特定副作用可能会对另一名跑步者产生负面影响。例如,如果您在一个运行器上执行的集成测试在给定的静态端口上启动所需的 http 服务器,那么相同的测试将无法在另一个运行器上设置的 http 服务器,因为该端口将不可用。

Is having multiple runners on same machine a good practice?

一如既往,视情况而定。一般来说,在同一个 OS 上设置多个自托管运行器并没有错。我自己多次使用这种方法。但是,如果您担心我提到的(隔离、可能干扰作业执行运行的负面影响、安全问题等),那么您应该重新考虑该方法。