How to contribute guide
MacroEnergy.jl is an open-source software project and contributions are welcome! This guide is a quickstart guide to help you contribute to the project.
Opening an issue
The most straightforward way to contribute to MacroEnergy.jl is to provide feedback directly on the issues page. By clicking on the New issue
button, you will see four types of issues you can open:
Bug Report
- for reporting bugs and errorsQuestion
- for asking questions: "How do I do ...?"Feature Request
- for requesting new featuresOther
- for other types of contributions
Opening a PR
The second way to contribute to MacroEnergy.jl is to open a pull request. This allows you to implement changes and new features and propose them to the repository. Below are some guidelines for opening a PR (for reference, check the official GitHub guide).
Before opening a PR
We recommend opening an issue before opening a PR. This will allow us to discuss the changes you want to make and provide feedback.
Fork the repository (if you don't have already done so):
- Click the "Fork" button in the top-right corner of the MacroEnergy.jl repository.
- This creates your own copy of the repository where you can make changes.
Clone your fork:
# Replace YOUR-USERNAME with your GitHub username git clone https://github.com/YOUR-USERNAME/MacroEnergy.jl.git cd MacroEnergy.jl
Add the original repository as upstream:
# This allows you to keep your fork in sync with the main repository git remote add upstream https://github.com/macroenergy/MacroEnergy.jl.git # Verify the remotes are set up correctly git remote -v
Create a new branch for your changes:
# Get the latest changes from the main repository git checkout main git pull upstream main # Create and switch to a new branch # Replace your-branch-name with a descriptive name git checkout -b your-branch-name
The recommended name for the branch is <user_id>/<short_description>
, where <user_id>
can be a short version of your name or a nickname, and <short_description>
is a short description of the changes you are making.
Make your changes and commit them (this step can be done multiple times, each for a different change):
# Stage your changes git add . # Commit with a descriptive message git commit -m "Description of your changes" # If you need to make more changes, repeat the process
Push to your fork:
# Push your branch to your fork git push origin your-branch-name # If this is the first time pushing this branch, use: git push -u origin your-branch-name
How to open a PR (once the changes are in a good state)
Create a Pull Request:
- Go to your fork on GitHub
- Click "New Pull Request"
- Select your branch
- Select the base repository as
macroenergy/MacroEnergy.jl
and the base branch asmain
(or the correct target branch) - Fill out the PR template
- Submit the PR
Keep your fork up to date (every time a PR is merged into the upstream repository):
# Fetch the latest changes from the main repository git fetch upstream # Switch to main branch git checkout main # Merge the changes from upstream git merge upstream/main # Push the updated main branch to your fork git push origin main
Alternatively, use the Sync fork
button in the GitHub website.
Once a PR is created, you can still make changes to your code. You can do this by committing new changes to your branch and pushing them to your fork. The PR will automatically update to reflect the new changes.
PR review process
- Your PR will be reviewed by maintainers who will provide feedback on the PR.
- If any changes are requested, you can push a new commit to your branch, which will update the PR.
- If any conflicts arise, you can resolve them by pulling the latest changes from the upstream repository and merging them into your branch (you can use the conflict resolution tool provided by GitHub).
- Once the PR is approved, it will be merged into the upstream repository.
- You can delete the branch from your fork to clean up.
- Make sure to have reviewed your code before opening a PR.
- Make sure to have added comments to your code, in particular in hard-to-understand places.
- Make sure to have updated the docs if you added new functions or changed existing ones, to help other users use your code.
- Make sure to have tested your code, and to provide an example case that the reviewer can use to test the code + how to interpret the results (set of json + csv + julia files).
- Try to write a good PR description, including the motivation for the changes you made.
- Try to make small PRs, ideally each one focusing on a single change.
- Help review your PR, for instance by highlighting places where you would particularly like reviewer feedback.
Some useful links
- Creating an issue (GitHub)
- Creating a pull request (GitHub)
- Creating a pull request from a fork (GitHub)
- Git guide
- ColPrac: Contributor's Guide on Collaborative Practices for Community Packages
- Julia Style Guide