Fork the project on GitHub and clone your fork locally.
$ git clone firstname.lastname@example.org:username/electron.git $ cd electron $ git remote add upstream https://github.com/electron/electron.git $ git fetch upstream
Build steps and dependencies differ slightly depending on your operating system. See these detailed guides on building Electron locally:
Once you've built the project locally, you're ready to start making changes!
To keep your development environment organized, create local branches to
hold your work. These should be branched directly off of the
$ git checkout -b my-branch -t upstream/master
Most pull requests opened against the
electron/electron repository include
changes to either the C/C++ code in the
lib/ folder, the documentation in
or tests in the
Please be sure to run
npm run lint from time to time on any code changes
to ensure that they follow the project's code style.
See coding style for more information about best practice when modifying code in different parts of the project.
It is recommended to keep your changes grouped logically within individual commits. Many contributors find it easier to review changes that are split across multiple commits. There is no limit to the number of commits in a pull request.
$ git add my/changed/files $ git commit
Note that multiple commits often get squashed when they are landed.
A good commit message should describe what changed and why. The Electron project uses semantic commit messages to streamline the release process.
Before a pull request can be merged, it must have a pull request title with a semantic prefix.
Examples of commit messages with semantic prefixes:
fix: don't overwrite prevent_default if default wasn't prevented
feat: add app.isPackaged() method
docs: app.isDefaultProtocolClient is now available on Linux
Other things to keep in mind when writing a commit message:
The first line should:
A commit that has the text
BREAKING CHANGE: at the beginning of its optional
body or footer section introduces a breaking API change (correlating with Major
in semantic versioning). A breaking change can be part of commits of any type.
chore: types would all be valid, in addition to any
See conventionalcommits.org for more details.
Once you have committed your changes, it is a good idea to use
git merge) to synchronize your work with the main repository.
$ git fetch upstream $ git rebase upstream/master
This ensures that your working branch has the latest changes from
Bug fixes and features should always come with tests. A testing guide has been provided to make the process easier. Looking at other tests to see how they should be structured can also help.
Before submitting your changes in a pull request, always run the full test suite. To run the tests:
$ npm run test
Make sure the linter does not report any issues and that all tests pass. Please do not submit patches that fail either check.
If you are updating tests and want to run a single spec to check it:
$ npm run test -match=menu
The above would only run spec modules matching
menu, which is useful for
anyone who's working on tests that would otherwise be at the very end of
the testing cycle.
Once your commits are ready to go -- with passing tests and linting -- begin the process of opening a pull request by pushing your working branch to your fork on GitHub.
$ git push origin my-branch
From within GitHub, opening a new pull request will present you with a template that should be filled out:
<!-- Thank you for your pull request. Please provide a description above and review the requirements below. Bug fixes and new features should include tests and possibly benchmarks. Contributors guide: https://github.com/electron/electron/blob/master/CONTRIBUTING.md -->
You will probably get feedback or requests for changes to your pull request. This is a big part of the submission process so don't be discouraged! Some contributors may sign off on the pull request right away. Others may have detailed comments or feedback. This is a necessary part of the process in order to evaluate whether the changes are correct and necessary.
To make changes to an existing pull request, make the changes to your local branch, add a new commit with those changes, and push those to your fork. GitHub will automatically update the pull request.
$ git add my/changed/files $ git commit $ git push origin my-branch
There are a number of more advanced mechanisms for managing commits using
git rebase that can be used, but are beyond the scope of this guide.
Feel free to post a comment in the pull request to ping reviewers if you are awaiting an answer on something. If you encounter words or acronyms that seem unfamiliar, refer to this glossary.
All pull requests require approval from a Code Owner of the area you modified in order to land. Whenever a maintainer reviews a pull request they may request changes. These may be small, such as fixing a typo, or may involve substantive changes. Such requests are intended to be helpful, but at times may come across as abrupt or unhelpful, especially if they do not include concrete suggestions on how to change them.
Try not to be discouraged. If you feel that a review is unfair, say so or seek the input of another project contributor. Often such comments are the result of a reviewer having taken insufficient time to review and are not ill-intended. Such difficulties can often be resolved with a bit of patience. That said, reviewers should be expected to provide helpful feeback.
In order to land, a pull request needs to be reviewed and approved by at least one Electron Code Owner and pass CI. After that, if there are no objections from other contributors, the pull request can be merged.
Congratulations and thanks for your contribution!
Every pull request is tested on the Continuous Integration (CI) system to confirm that it works on Electron's supported platforms.
Ideally, the pull request will pass ("be green") on all of CI's platforms. This means that all tests pass and there are no linting errors. However, it is not uncommon for the CI infrastructure itself to fail on specific platforms or for so-called "flaky" tests to fail ("be red"). Each CI failure must be manually inspected to determine the cause.
CI starts automatically when you open a pull request, but only Releasers can restart a CI run. If you believe CI is giving a false negative, ask a Releaser to restart the tests.