Update guidelines for syncing code between repos (#9831)

This commit is contained in:
Lianmin Zheng
2025-08-30 16:10:35 -07:00
committed by GitHub
parent 0d04008936
commit 646076b71e
2 changed files with 10 additions and 8 deletions

View File

@@ -5,13 +5,13 @@ on:
branches: [ main ] branches: [ main ]
paths: paths:
- "python/**" - "python/**"
- "scripts/**" - "scripts/ci/**"
- "test/**" - "test/**"
pull_request: pull_request:
branches: [ main ] branches: [ main ]
paths: paths:
- "python/**" - "python/**"
- "scripts/**" - "scripts/ci/**"
- "test/**" - "test/**"
concurrency: concurrency:

View File

@@ -1,12 +1,14 @@
### Sync Code Between OSS and Private Fork ### Sync Code Between OSS and Private Fork
We can use the following principals and tools to sync the code between the a private fork and the oss repo [sgl-project/sglang](https://github.com/sgl-project/sglang/tree/main). You can use the following principles and tools to sync the code between a private fork and the OSS repo [sgl-project/sglang](https://github.com/sgl-project/sglang/tree/main).
It learns from [Copybara](https://github.com/google/copybara), a tool used at Google for maintaining open-source code synchronization.
## Principals ## Principals
- The folder `python/sglang/srt` is 100% mirrored between the private fork and OSS repo. - The core folders (e.g., `python/sglang/srt`) are 100% mirrored between the private fork and OSS repo.
- The OSS repo is the single source of truth. If one commit changes `python/sglang/srt` in the private repo, the change should be synced to the OSS repo as soon as possible with the action B below. - The OSS repo is the single source of truth. If one commit changes `python/sglang/srt` in the private repo, the change should be synced to the OSS repo as soon as possible with the action B below.
- The common code (e.g., base classes, well-known techniques in the industry without private secrets) goes to `python/sglang/srt`. The private-specific code (e.g., with private-specific features, confidential info) goes to `python/sglang/private` . - The common code (e.g., base classes, well-known techniques in the industry without private secrets) goes to `python/sglang/srt`. The private-specific code (e.g., with private-specific features, confidential info) goes to `python/sglang/private` .
- Anytime you want to make private changes to a file or class under `python/sglang/srt`, duplicate the file and move it under `python/sglang/private`. You can achieve code reuse by importing and inheriting.
## How to sync the code bidirectionally ## How to sync the code bidirectionally
### Action A: Copy code from OSS to private ### Action A: Copy code from OSS to private
@@ -21,5 +23,5 @@ We can use the following principals and tools to sync the code between the a pri
- We can run this action: [Open A PR to Copy Code To OSS](https://github.com/sgl-project/sglang/tree/main/.github/workflows/open-pr-copy-to-oss.yml) - We can run this action: [Open A PR to Copy Code To OSS](https://github.com/sgl-project/sglang/tree/main/.github/workflows/open-pr-copy-to-oss.yml)
- It opens a PR to apply the diff of one specific commit of the private fork to the OSS main branch. It will only pick the changes under certain folders (e.g., `python/sglang/srt` , `test/srt` , `sgl-kernel` ) and ignore changes under private folders (e.g., `python/sglang/private` ) - It opens a PR to apply the diff of one specific commit of the private fork to the OSS main branch. It will only pick the changes under certain folders (e.g., `python/sglang/srt` , `test/srt` , `sgl-kernel` ) and ignore changes under private folders (e.g., `python/sglang/private` )
- For example, you can have a PR that changes both `python/sglang/srt` and `python/sglang/private/srt`. Once you merge the PR into the private repo, `python/sglang/srt` becomes desynced between the two repos. You need to run this action on your merge commit immediately to open a PR to send your diff to the OSS repo. Then, we need to merge the OSS PR as soon as possible. Once your OSS PR is merged, we can run action A again. - For example, you can have a PR that changes both `python/sglang/srt` and `python/sglang/private/srt`. Once you merge the PR into the private repo, `python/sglang/srt` becomes desynced between the two repos. You need to run this action on your merge commit immediately to open a PR to send your diff to the OSS repo. Then, we need to merge the OSS PR as soon as possible. Once your OSS PR is merged, we can run action A again.
- Action A copies files directly but Action B applies diff. This is because OSS is the source of truth, action A can just copy files. Action B cannot copy so it uses diff instead. - Action A copies files directly, but Action B applies diff. This is because OSS is the source of truth; action A can just copy files. Action B cannot copy, so it uses diff instead.
- This action currently needs manual trigger in order to prevent incidental code leak. One can also consider making it automatic. - This action currently needs a manual trigger in order to prevent incidental code leaks. One can also consider making it automatic.