如何在不暴露秘密的情况下在 Github 上添加 CI 测试?

How to add CI tests on Github without exposing secrets?

我在 Github 上有一个(私人)存储库,我想

在这个 repo 中,我有多个项目,其中之一是“my_big_project”,我想跟踪它的代码覆盖率。

 -- small_project
 -- my_big_project
    |-- main/
    |-- utils/
    |-- tests/
    |-- local.settings.json  # my secrets

我用 coverage run -m unittest discover my_big_project/ "test_*.py"

启动测试

我的测试使用存储在 local.settings.json 中的秘密(.gitignore 会忽略它以避免上传到 Github)。

如何在不将我的秘密上传到 Github 的服务器的情况下自动执行测试并跟踪覆盖率?

您可以使用 GitHub's Vault Secrets(据我所知,这与“不将我的秘密上传到 Github 的服务器”的要求有点矛盾,但要么这样,要么避免在测试中使用任何秘密,e.x。模拟需要机密的 API)