Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
- Deno 2.1.1 or later
- MongoDB 8.0
- Redis 7.4
We provide two development environments:
- Base Environment:
devcontainer open .devcontainer/pull-base
- Full Environment (includes monitoring tools which supports amd64 only):
devcontainer open .devcontainer/pull-full
The full environment includes additional tools:
- Mongo Express (port 8081)
- Redis Commander (port 8082)
- Bull Board (port 8083)
- Fork and clone the repository
- Make sure you have Deno installed
- Install development hooks:
deno task install-hooks
- Set up your GitHub App. Follow the Probot documentation for detailed instructions on creating a GitHub App.
- Set up your environment variables by copying the
.env.example
file to.env
and filling in the required values:cp .env.example .env
- Start the development server:
Start the development worker:
deno task dev
deno task worker
deno task dev
: Start the app in development modedeno task dev:skip-full-sync
: Start without initial full syncdeno task worker
: Start the background workerdeno task test
: Run testsdeno task check
: Run linter and formatter checksdeno task full-sync
: Run full repository syncdeno task manual-process <owner>/<repo>
: Process specific repository
The main Express.js application that:
- Handles GitHub webhooks
- Serves API endpoints
- Initializes the scheduler
Processes repository sync jobs using BullMQ:
- Handles job concurrency
- Manages retries and failures
- Processes jobs based on priority
3. Scheduler (@wei/probot-scheduler
)
Manages periodic repository checks:
- Schedules jobs using cron expressions
- Maintains job queues in Redis
- Handles job priorities and scheduling
- MongoDB: Stores repository and installation data
- Redis: Manages job queues and caching
- Connections: Managed through
src/configs/database.ts
andsrc/configs/redis.ts
The Pull processor is the core component that handles repository synchronization. Here's a detailed breakdown of its functionality:
graph TD
A[Routine Check] --> B{Has Diff?}
B -->|Yes| C{Existing PR?}
B -->|No| D[Skip]
C -->|Yes| E[Check Auto Merge]
C -->|No| F[Create PR]
F --> E
E --> G{Mergeable?}
G -->|Yes| H[Process Merge]
G -->|No| I[Handle Conflict]
-
Routine Check (
routineCheck
):- Iterates through configured rules in
pull.yml
- For each rule:
- Normalizes base and upstream branch names
- Checks for differences between branches
- Creates or updates pull requests as needed
- Iterates through configured rules in
-
Difference Detection (
hasDiff
):- Compares commits between base and upstream branches
- Handles special cases:
- Large diffs that timeout
- Missing branches
- No common ancestor
- Returns true if changes are detected
-
Pull Request Management:
- Updates (
getOpenPR
):- Finds existing PRs created by the bot
- Validates PR matches current sync rule
- Creation (
createPR
):- Creates new pull request with standardized title
- Assigns reviewers and labels
- Updates PR body with tracking information
- Updates (
-
Merge Process (
checkAutoMerge
,processMerge
):- Supports multiple merge methods:
none
: No automatic mergingmerge
: Standard merge commitsquash
: Squash and mergerebase
: Rebase and mergehardreset
: Force push to base branch
- Handles merge conflicts:
- Adds conflict label
- Assigns conflict reviewers
- Updates PR status
- Supports multiple merge methods:
The processor implements robust error handling:
- Retries for mergeable status checks
- Graceful handling of GitHub API limitations
- Detailed logging for debugging
- Conflict resolution workflows
When modifying the Pull processor:
- Maintain idempotency in operations
- Implement proper error handling
- Add detailed logging for debugging
- Consider edge cases
- Create a new branch:
git checkout -b my-branch-name
- Make your changes
- Make sure the tests pass:
deno test
- Format your code:
deno fmt
- Run the linter:
deno lint
- Push to your fork and submit a pull request
- Pat yourself on the back and wait for your pull request to be reviewed and merged
Here are a few things you can do that will increase the likelihood of your pull request being accepted:
- Follow the style guide enforced by Deno's built-in formatter. You can format
your code by running
deno fmt
- Write and update tests
- Keep your changes as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests
- Write a good commit message
Work in Progress pull requests are also welcome to get feedback early on, or if there is something blocked you.
By contributing, you agree that your contributions will be licensed under its MIT License.