gh-signoff:基于 GitHub CLI 的本地 CI 工具项目

Local CI. Sign off on your own work.

Branch5Tags0
FilesLast commitLast update
1 year ago
1 month ago
1 year ago
1 month ago
1 month ago

gh-signoff

一个用于本地 CI 的 GitHub CLI 扩展。在自己的机器上运行测试,测试通过后进行签署确认。

远程 CI 运行器在可重复构建、全面测试套件和并行执行方面表现出色。但许多应用并不需要所有这些功能。或许你的应用也不需要。

如今的开发笔记本电脑速度非常快,却常常未被充分利用,而且它们本就是你已拥有的设备。相比之下,云 CI 服务通常速度慢、成本高,并且是租用的。

你已经信任团队具备良好的测试、推送和部署规范。合并队列、部署流水线以及流程繁琐的 CI……这些都显得过于复杂了。

绿色的 GitHub 提交状态正是我们所需要的,但不租用云 CI 服务的话,获取这一状态却相当麻烦。

所以,让我们自己动手解决。将 CI 带回本地。

运行你的测试套件(例如 rails test),测试通过后签署确认你的工作(使用 gh signoff)。

现在,你就是 CI 了。✌️👀

如何签署确认

# Install the extension
gh extension install basecamp/gh-signoff

# When your tests pass, sign off on your PR
gh signoff

如果不使用 -f,signoff 要求 HEAD 包含在 @{push} 中。当 @{push} 无法解析时,只有在特定的集中式场景下,signoff 才会回退到 @{upstream}push.default 设为 simple(或未设置),上游位于真实远程仓库,且其单一推送 URL 与其拉取 URL 匹配,同时没有 pushRemote/pushDefault/推送引用规格的重定向。否则,signoff 将拒绝执行。对于检出了不同名称跟踪分支的 CI 工作区,可能需要设置 git config push.default upstream

要求 PR 合并前进行 signoff

# Require signoff to merge PRs
gh signoff install

高级用法:部分签核

大多数项目只需一次签核即可。如果您追求更高阶的功能、更细致的控制或更有序的管理,可以使用部分签核来反映每个 CI 步骤、每个构建平台(例如 linux、macos、windows)、每个签核角色(例如 qa、dev、ops)等。

# Sign off on CI steps
gh signoff tests      # Tests are green
gh signoff lint       # Linting checks pass
gh signoff security   # Security scan is happy

# Or all at once
gh signoff tests lint security

如需要求部分签署:

# Require partial signoff for the default branch
gh signoff install security

# Require multiple signoffs at once
gh signoff install tests lint security

# With a specific branch
gh signoff install --branch main tests lint security

# Check if partial signoff is required
gh signoff check tests
gh signoff check --branch main tests lint security

检查签署状态

检查您是否已签署当前提交:

gh signoff status
✓ signoff

使用部分签署:

gh signoff status
✓ signoff
✓ tests
✗ lint
✗ security

Bash 补全

# Add to ~/.bashrc:
eval "$(gh signoff completion)"

许可协议

本工具根据 MIT 许可协议 的条款以开源形式提供。

Introduction

本地持续集成。自主完成并确认您的工作。【此简介由AI生成】

Customize your domain
102.03 K30Visit GitHub