This article was first published on the Nebula Graph Community public account
background
As an open source distributed graph database product, all of Nebula's research and development processes operate on GitHub. Based on the GitHub ecosystem, the Nebula technical team has a set of automated processes for pr: every time a pr is submitted, the pull request bot runs a test to see if the pr merge to the main branch can ensure that some current functions can continue to operate normally.
At this time, the problem arises: each pr has to run the test every time it comes up, which is time-consuming and causes unnecessary consumption to the test machine. As a result, the Nebula R&D team intends to evolve the existing pr merge robot.
This article mainly describes how to optimize the design under the original setting to save test resources.
Design ideas
Based on the implementation ideas of the existing bot, a new bot is developed to optimize the pr merge. The main feature of the new bot is that, by using the on schedule function provided by github action, it can automatically execute the merged tests of all pull requests after a period of time, so that there is no need to run CI for each pull request, saving time and performance consumption. If the test fails, one of the pull requests is eliminated with a random elimination scheme and the test is continued until the test passes or the available pull request is useless. Then merge the pull request contained in this test pass into the main branch, and provide the function of sending this merge information to the DingTalk group.
Assuming that the user has a new pull request, it needs to experience:
- pull request approved by reviewers
- Repository maintainer comments/merge, agreeing to merge
- After completing 1 and 2, the pull request will be recognized by the bot as a pull request that can be merged
- The bot preloads all pull requests marked as mergeable into the runner's local master-based branch for ci testing
- If the test passes, the pull request will be merged to the main branch; if the test fails, the bot will randomly remove the existing pull request, and then test it again until the test passes or no branch is available.
- (Optional) The bot sends the result of this merge to the DingTalk group
requires attention:
- When using auto-merge-bot, the repository needs to configure a team in GitHub orgnization, and the roles of some members in this team need to be marked as maintainers, corresponding to step 2 above.
- The maintainer can agree to merge the pull request by commenting/merge, or cancel the merge by commenting/wait a minute or deleting the comment, but if the bot is already running, it can only cancel the merge by manually stopping the workflow of the bot. This feature will be added in a future version.
- For the DingTalk group sending function, you need to configure a robot in the DingTalk group, see https://developers.dingtalk.com/document/robots/custom-robot-access and https://developers.dingtalk.com/document/ robots/customize-robot-security-settings , currently only supports signed security settings.
- The code of the ci test needs to be passed in by the user in the input parameters.
- The schedule of Github Action has a delay and will not run as scheduled at the specified time, usually 15-30 minutes.
test case
...
on:
schedule:
- cron: '* */1 * * *' --- 每小时跑一次
workflow_dispatch:
...
- name: Run merge script
uses: klay-ke/auto-merge-pr@master --- 该地址以后可能会改
id: merge-pr
with:
send-to-dingtalk-group: true
dingtalk-access-token: ${{ secrets.DINGTALK_ACCESS_TOKEN }}
dingtalk-secret: ${{ secrets.DINGTALK_SECRET }}
maintainer-team-name: ${{ secrets.MAINTAINER_TEAM_NAME }}
gh-token: ${{ secrets.GH_TOKEN }}
ci-command: 'bash ./build.sh'
enter
parameter | type | required | Defaults | describe |
---|---|---|---|---|
send-to-dingtalk-group | boolean | no | false | If true, it indicates that merge information needs to be sent to the DingTalk group, and the dingtalk-access-token and dingtalk-access-token fields need to be provided |
dingtalk-access-token | string | when send-to-dingtalk-group is true | empty string | Dingding group robot access token |
dingtalk-secret | string | when send-to-dingtalk-group is true | empty string | The secret of the Dingding group robot. |
maintainer-team-name | string | Yes | None | the name of the maintainer team |
gh-token | string | Yes | None | Github Token |
ci-command | string | no | None | ci test code |
output
The output can be read in subsequent steps through ${{ steps.{action设置的id - 对应用例中的merge-pr}.outputs.{参数名} }}
;
parameter | type | describe |
---|---|---|
merge-info | string | This merge information |
error-log | string | error log |
pass-log | string | log information |
merged | boolean | Whether there is a pull request successfully merged |
above.
The first essay contest of Nebula community is officially launched🔗 The prizes are rich, covering the whole scene: mechanical keyboard, mobile phone wireless charging, health assistant smart bracelet, more database design, knowledge map practice books waiting for you to pick up, and Nebula exquisite Non-stop delivery around 🎁
Welcome friends who are interested in Nebula and who like to study and write interesting stories about themselves and Nebula~
Exchange graph database technology? To join the Nebula exchange group, please fill in your Nebula business card first, and the Nebula assistant will pull you into the group~~
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。