|
| 1 | +# [Developer documentation](@id dev_docs) |
| 2 | + |
| 3 | +!!! note "Contributing guidelines" |
| 4 | + |
| 5 | + If you haven't, please read the [Contributing guidelines](90-contributing.md) first. |
| 6 | + |
| 7 | +If you want to make contributions to this package that involves code, then this guide is for you. |
| 8 | + |
| 9 | +## First time clone |
| 10 | + |
| 11 | +!!! tip "If you have writing rights" |
| 12 | + |
| 13 | + If you have writing rights, you don't have to fork. Instead, simply clone and skip ahead. Whenever **upstream** is mentioned, use **origin** instead. |
| 14 | + |
| 15 | +If this is the first time you work with this repository, follow the instructions below to clone the repository. |
| 16 | + |
| 17 | +1. Fork this repo |
| 18 | +2. Clone your repo (this will create a `git remote` called `origin`) |
| 19 | +3. Add this repo as a remote: |
| 20 | + |
| 21 | + ```bash |
| 22 | + git remote add upstream https://github.com/JuliaHEP/LorentzVectorBase.jl.git |
| 23 | + ``` |
| 24 | + |
| 25 | +This will ensure that you have two remotes in your git: `origin` and `upstream`. |
| 26 | +You will create branches and push to `origin`, and you will fetch and update your local `main` branch from `upstream`. |
| 27 | + |
| 28 | +## Code Formatting |
| 29 | + |
| 30 | +To maintain code consistency, format your code with: |
| 31 | + |
| 32 | +```julia |
| 33 | +julia --project=.formatting -e 'using Pkg; Pkg.instantiate(); include(".formatting/format_all.jl")' |
| 34 | +``` |
| 35 | + |
| 36 | +This ensures adherence to the project's formatting standards. |
| 37 | +
|
| 38 | +## Testing |
| 39 | +
|
| 40 | +As with most Julia packages, you can just open Julia in the repository folder, activate the environment, and run `test`: |
| 41 | +
|
| 42 | +```julia-repl |
| 43 | +julia> # press ] |
| 44 | +pkg> activate . |
| 45 | +pkg> test |
| 46 | +``` |
| 47 | +
|
| 48 | +## Working on a new issue |
| 49 | +
|
| 50 | +We try to keep a linear history in this repo, so it is important to keep your branches up-to-date. |
| 51 | +
|
| 52 | +1. Fetch from the remote and fast-forward your local main |
| 53 | +
|
| 54 | + ```bash |
| 55 | + git fetch upstream |
| 56 | + git switch main |
| 57 | + git merge --ff-only upstream/main |
| 58 | + ``` |
| 59 | +
|
| 60 | +2. Branch from `main` to address the issue (see below for naming) |
| 61 | +
|
| 62 | + ```bash |
| 63 | + git switch -c 42-add-answer-universe |
| 64 | + ``` |
| 65 | +
|
| 66 | +3. Push the new local branch to your personal remote repository |
| 67 | +
|
| 68 | + ```bash |
| 69 | + git push -u origin 42-add-answer-universe |
| 70 | + ``` |
| 71 | +
|
| 72 | +4. Create a pull request to merge your remote branch into the org main. |
| 73 | +
|
| 74 | +### Branch naming |
| 75 | +
|
| 76 | +- If there is an associated issue, add the issue number. |
| 77 | +- If there is no associated issue, **and the changes are small**, add a prefix such as "typo", "hotfix", "small-refactor", according to the type of update. |
| 78 | +- If the changes are not small and there is no associated issue, then create the issue first, so we can properly discuss the changes. |
| 79 | +- Use dash separated imperative wording related to the issue (e.g., `14-add-tests`, `15-fix-model`, `16-remove-obsolete-files`). |
| 80 | +
|
| 81 | +### Commit message |
| 82 | +
|
| 83 | +- Use imperative or present tense, for instance: _Add feature_ or _Fix bug_. |
| 84 | +- Have informative titles. |
| 85 | +- When necessary, add a body with details. |
| 86 | +- If there are breaking changes, add the information to the commit message. |
| 87 | +
|
| 88 | +### Before creating a pull request |
| 89 | +
|
| 90 | +!!! tip "Atomic git commits" |
| 91 | +
|
| 92 | + Try to create "atomic git commits" (recommended reading: [The Utopic Git History](https://blog.esciencecenter.nl/the-utopic-git-history-d44b81c09593)). |
| 93 | +
|
| 94 | +- Make sure the tests pass. |
| 95 | +- Make sure the pre-commit tests pass. |
| 96 | +- Fetch any `main` updates from upstream and rebase your branch, if necessary: |
| 97 | +
|
| 98 | + ```bash |
| 99 | + git fetch upstream |
| 100 | + git rebase upstream/main BRANCH_NAME |
| 101 | + ``` |
| 102 | +
|
| 103 | +- Then you can open a pull request and work with the reviewer to address any issues. |
| 104 | +
|
| 105 | +## Building and viewing the documentation locally |
| 106 | +
|
| 107 | +Following the latest suggestions, we recommend using `LiveServer` to build the documentation. |
| 108 | +Here is how you do it: |
| 109 | +
|
| 110 | +1. Run `julia --project=docs` to open Julia in the environment of the docs. |
| 111 | +1. If this is the first time building the docs |
| 112 | + 1. Press `]` to enter `pkg` mode |
| 113 | + 1. Run `pkg> dev .` to use the development version of your package |
| 114 | + 1. Press backspace to leave `pkg` mode |
| 115 | +1. Run `julia> using LiveServer` |
| 116 | +1. Run `julia> servedocs()` |
| 117 | +
|
| 118 | +## Making a new release |
| 119 | +
|
| 120 | +To create a new release, you can follow these simple steps: |
| 121 | +
|
| 122 | +- Create a branch `release-x.y.z` |
| 123 | +- Update `version` in `Project.toml` |
| 124 | +- Update the `CHANGELOG.md`: |
| 125 | + - Rename the section "Unreleased" to "[x.y.z] - yyyy-mm-dd" (i.e., version under brackets, dash, and date in ISO format) |
| 126 | + - Add a new section on top of it named "Unreleased" |
| 127 | + - Add a new link in the bottom for version "x.y.z" |
| 128 | + - Change the "[unreleased]" link to use the latest version - end of line, `vx.y.z ... HEAD`. |
| 129 | +- Create a commit "Release vx.y.z", push, create a PR, wait for it to pass, merge the PR. |
| 130 | +- Go back to main screen and click on the latest commit (link: <https://github.com/JuliaHEP/LorentzVectorBase.jl/commit/main>) |
| 131 | +- At the bottom, write `@JuliaRegistrator register` |
| 132 | +
|
| 133 | +After that, you only need to wait and verify: |
| 134 | +
|
| 135 | +- Wait for the bot to comment (should take < 1m) with a link to a PR to the registry |
| 136 | +- Follow the link and wait for a comment on the auto-merge |
| 137 | +- The comment should said all is well and auto-merge should occur shortly |
| 138 | +- After the merge happens, TagBot will trigger and create a new GitHub tag. Check on <https://github.com/JuliaHEP/LorentzVectorBase.jl/releases> |
| 139 | +- After the release is create, a "docs" GitHub action will start for the tag. |
| 140 | +- After it passes, a deploy action will run. |
| 141 | +- After that runs, the [stable docs](https://JuliaHEP.github.io/LorentzVectorBase.jl/stable) should be updated. Check them and look for the version number. |
0 commit comments