6.6. Contributions
What is a code of conduct?
A code of conduct is a document that establishes expectations for behavior for community members. It serves as a guideline to help create a safe, respectful, and collaborative environment. This document typically addresses issues such as harassment, discrimination, and conflict resolution. By having a clear code of conduct, projects can encourage an inclusive atmosphere that encourages participation from diverse groups of people.
You can add a code of conduct for your project by following this guide from GitHub or adding a CODE_OF_CONDUCT.md
file directly at the root of your repository. You can find examples on the Open Source Guides: Establishing a code of conduct.
What are contribution guidelines?
Contribution guidelines are instructions provided by a project to help contributors understand how they can effectively participate. These guidelines often include standards for coding practices, the submission process for patches or features, and criteria for acceptable behavior when interacting with the project’s community. By following these guidelines, contributors can ensure their efforts align with the project goals and requirements, streamlining the collaboration process.
You can define the contributing guidelines for your project by creating a CONTRIBUTING.md
file at the top of your repository.
How can you build a good software community?
Building a good software community involves several key strategies:
- Open Communication: Encourage open and transparent communication where all members feel heard. Utilize forums, chats, and regular meetings to facilitate discussions.
- Recognition and Rewards: Recognize and reward contributions, whether they are code submissions, documentation, or community help. This can promote a sense of value and appreciation among members.
- Inclusivity: Promote an inclusive environment by actively engaging with diverse groups and considering different perspectives in decision-making processes.
- Learning and Development: Provide opportunities for learning and personal development through workshops, seminars, and mentoring programs. This helps members grow their skills and stay engaged with the community.
- Leadership and Governance: Establish clear leadership and governance structures that define roles and responsibilities. This helps in managing the community efficiently and ensuring that everyone knows how to contribute effectively.
How should you invite others to your repository?
Inviting others to your repository can be effectively managed through the use of permissions. Here are some steps to consider:
- Clear Roles and Permissions: Define roles within your repository (e.g., Viewer, Contributor, Maintainer) and assign appropriate permissions that align with these roles.
- Contribution Guidelines: Provide clear contribution guidelines to help new contributors understand how to get started.
- Welcoming Message: Send a welcoming message explaining the project’s goals, the importance of each role, and how new contributors can get involved.
- Use of Tools: Utilize tools like GitHub’s issue tracker and pull requests to facilitate collaboration and communication.
How can you help people become better contributors?
Helping people become better contributors primarily involves mentorship and effective code reviews. Here’s how you can implement these strategies:
- Code Reviews: Conduct thorough code reviews that not only focus on the correctness of code but also on best practices and design principles. Provide constructive feedback that helps contributors understand what they did well and where they can improve.
- Documentation: Ensure your project has comprehensive documentation that is easy to understand. This can help contributors get up to speed quickly and reduce misunderstandings.
- Regular Feedback: Offer regular feedback sessions where contributors can discuss their progress and receive advice on overcoming challenges.
- Mentoring: Establish a mentoring program where experienced contributors can guide new members. This can significantly enhance the learning curve and encourage more meaningful contributions.
Is it possible to automate the code review process?
Yes, automating parts of the code review process is possible and can significantly enhance efficiency.
For instance, you can enable code review with Google Gemini Code Assist. After you install the Gemini Code Assist App from GitHub marketplace, you can add a .gemini/config.yaml
file at the root of your repository with the following content:
# https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github
have_fun: false
code_review:
disable: false
comment_severity_threshold: MEDIUM
max_review_comments: -1
pull_request_opened:
help: false
summary: true
code_review: true
On pull requests, Gemini Code Assist will automatically review the code and add comments.
How to guarantee that GitHub contributions follow the repository standards?
To ensure that contributions to your GitHub repository adhere to the established standards, you can set up GitHub rulesets. These rulesets define a set of rules that apply to specific branches or the entire repository.
The rules can enforce various constraints, such as requiring linear history, preventing force pushes, or mandating specific merge methods.
Here is an example of a ruleset configuration for the main
branch, which can be saved in a file named .github/rulesets/main.json
:
{
"name": "main",
"target": "branch",
"enforcement": "active",
"conditions": {
"ref_name": {
"exclude": [],
"include": [
"~DEFAULT_BRANCH"
]
}
},
"rules": [
{
"type": "deletion"
},
{
"type": "required_linear_history"
},
{
"type": "pull_request",
"parameters": {
"required_approving_review_count": 0,
"dismiss_stale_reviews_on_push": true,
"require_code_owner_review": false,
"require_last_push_approval": false,
"required_review_thread_resolution": false,
"allowed_merge_methods": [
"squash",
"rebase"
]
}
},
{
"type": "required_status_checks",
"parameters": {
"strict_required_status_checks_policy": true,
"do_not_enforce_on_create": false,
"required_status_checks": [
{
"context": "checks",
"integration_id": 15368
}
]
}
},
{
"type": "non_fast_forward"
}
],
"bypass_actors": [
{
"actor_id": 5,
"actor_type": "RepositoryRole",
"bypass_mode": "always"
}
]
}
You can then install GitHub rulesets manually or with the following Just task:
# install github rulesets
[group('install')]
install-rulesets:
#!/usr/bin/env bash
set -euo pipefail
repo=$(gh repo view --json=name --jq=.name)
owner=$(gh repo view --json=owner --jq=.owner.login)
gh api --method POST -H "Accept: application/vnd.github+json" \
"/repos/$owner/$repo/rulesets" --input=".github/rulesets/main.json"