测试拉取请求

许多人正在GitHub上开发新功能或修复错误。为了帮助引擎开发,你可能会被要求用Godot构建来测试这些拉取请求,该构建包括有关拉取请求中的代码。

感谢GitHub Actions,所有的 拉取请求pull requests 都有持续构建。这些构建可以让你尝试拉取请求,而不需要从源代码编译任何东西。

下载编译后的版本

你可以从GitHub Actions中下载拉取请求构建。由于只有已登录的用户可以直接从GitHub Actions下载构建,因此根据你是否有GitHub账户,程序会有所不同。

备注

由于GitHub Actions的限制,构建只在拉取请求最后更新后的90天内可用。如果你仍然希望在本地尝试拉取请求,你可以 从源代码编译拉取请求 分支来代替。

如果你有 GitHub 账户

  • 打开拉取请求页面。点击页面顶部附近的 检查Checks 标签:

../../_images/testing_pull_requests_access_checks.webp

  • Click the Artifacts dropdown on the right of the page:

../../_images/testing_pull_requests_checks_artifacts.webp

  • In the dropdown, click the artifact’s name to download it. Remember to scroll if you cannot see the name of the platform you’re looking for:

../../_images/testing_pull_requests_checks_artifacts_list.webp

  • Extract the ZIP archive then run the executable. Note that Windows and macOS binaries are not code signed. This means you may have to bypass a security warning before you can run the executable. On Windows, if you frequently test pull request builds, it may be better to disable Windows SmartScreen permanently in the Windows security settings. On macOS, see 在 macOS 上运行 Godot 应用 for instructions on bypassing Gatekeeper.

如果你没有 GitHub 账户

如果你没有GitHub账户,也无法注册,你可以使用第三方的 nightly.link 服务来生成一个通用的下载链接。

  • 打开拉取请求页面。点击页面顶部附近的 fork 分支名称:

../../_images/testing_pull_requests_access_fork.png

  • Now that you are on the fork’s branch page, click the .github folder at the top of the file list. Then, click on the workflows folder (which is inside the .github folder). Click the workflow file for the platform you wish to download artifacts for. After clicking on the file (which opens the file view), copy the page URL from your browser’s address bar.

  • Open the nightly.link website and paste the URL you just copied into the text field located below the heading Paste a GitHub link, get a nightly.link!. After pasting the URL, click Get links on the right. If the format of the URL you pasted is correct, you should be presented with a page like this:

../../_images/testing_pull_requests_nightly_link.png

  • 点击你想下载的工件的URL。

  • 提取ZIP档案,然后运行可执行文件。注意,Windows和macOS的二进制文件是没有代码签名的。这意味着你可能必须在运行可执行文件之前绕过安全警告。如果你经常测试拉取请求的构建,可能最好永久地禁用Windows SmartScreen或 禁用macOS Gatekeeper

从源编译拉取请求分支

对于最后一次更新超过90天的拉取请求,或者在Godot的GitHub Actions设置不支持的平台和配置上进行测试,可能需要采用这种方法。

Downloading a zipped pull request branch

  • 打开拉取请求页面。点击页面顶部附近的 fork 分支名称:

../../_images/testing_pull_requests_access_fork.png

  • 现在你在fork的分支页面上,点击页面右侧的绿色 Code 按钮,然后在下拉菜单中选择 下载ZIP :

../../_images/testing_pull_requests_fork_zip.png

  • 提取 ZIP 压缩包,按照你的操作系统的编译说明操作。

Checking out a pull request branch with git

Alternatively, you can checkout the pull request directly with git:

  • Open the pull request page. Note the pull request number (PR_NUMBER), and the branch name (BRANCH_NAME), but without the user name.

../../_images/testing_pull_requests_command_line_checkout.webp

  • Construct the command using this pattern:
  1. $ git fetch upstream pull/PR_NUMBER/head:BRANCH_NAME

So for the pull request above, the actual command will be:

  1. # Fetch PR branch locally
  2. $ git fetch upstream pull/48734/head:editor_file_dialog_filter_sort
  • Once the pull request finishes downloading, checkout its branch:
  1. $ git checkout editor_file_dialog_filter_sort
  • And follow the compiling instructions for your operating system.