User Tools

Site Tools


dev:starting

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:starting [2019/03/05 14:33] – [Submit the patch] alazzarodev:starting [2022/12/16 09:27] (current) – Fix link krack
Line 4: Line 4:
 Documentation improvements, bug fixes, performance enhancements, portability issues, new features, new methods ... you are encouraged to contribute so that the community as a whole can benefit. Documentation improvements, bug fixes, performance enhancements, portability issues, new features, new methods ... you are encouraged to contribute so that the community as a whole can benefit.
  
-CP2K is a large project, there is no way to study the full code, and start when that is done! Start working on small patches first, that are easy to code, to test and to integrate. Small patches are easier to review and thus will be more quickly merged to the Git master branch. As experience with the code grows, tackling larger projects becomes realistic. Developers that regularly contribute can sign up to the [[https://lists.cp2k.org/listinfo/cp2k-dev CP2K developer mailing list]].+CP2K is a large project, there is no way to study the full code, and start when that is done! Start working on small patches first, that are easy to code, to test and to integrate. Small patches are easier to review and thus will be more quickly merged to the Git master branch. As experience with the code grows, tackling larger projects becomes realistic. Developers who contribute regularly  can join the [[https://github.com/orgs/cp2k/teams/cp2k-developers developers team]] on Github.
  
 ===== Prepare the patch ===== ===== Prepare the patch =====
 +
   - Fork the CP2K Repository on GitHub via "Fork" on https://github.com/cp2k/cp2k   - Fork the CP2K Repository on GitHub via "Fork" on https://github.com/cp2k/cp2k
-     You will notice that you will not be able to push directly to the `master` branch of the new https://github.com/cp2k/cp2k repository. This is by intention and we would like to ask you to send changes as Pull Requests instead. +     Even as a member of the development team you will not be able to push directly to the `master` branch of the https://github.com/cp2k/cp2k repository. This is by intention and we would like to ask you to send changes as Pull Requests instead. 
-  - On your machine, clone the repository via **git clone --recursive https://github.com/cp2k/cp2k.git** +  - On your machine, clone the repository via **git clone %%--%%recursive https://github.com/YOURNAME/cp2k.git** 
-  - Move to the downloaded cp2k directory: **cd cp2k**+  - Change into the created cp2k directory: **cd cp2k**
   - Start working in a new branch: **git checkout -b my-new-feature**   - Start working in a new branch: **git checkout -b my-new-feature**
   - Make your changes to the code   - Make your changes to the code
   - Add new and changed files: **git add ...**   - Add new and changed files: **git add ...**
   - Commit the changes: **git commit**   - Commit the changes: **git commit**
-     - Please follow the [[https://github.com/cp2k/cp2k/wiki/Contribution-Guidelines | Guidelines rules]]+     - Please follow the [[https://github.com/cp2k/cp2k/wiki/Contribution-Guidelines | guidelines]]
   - Do the first push to your fork, give the remote branch the same name as the local one: **git push -u origin my-new-feature**   - Do the first push to your fork, give the remote branch the same name as the local one: **git push -u origin my-new-feature**
   - Do some more work, then repeat point 6. and 7.   - Do some more work, then repeat point 6. and 7.
   - Push your new changes to the remote repository via **git push** (note: the '-u origin my-new-feature' does not have to be repeated)   - Push your new changes to the remote repository via **git push** (note: the '-u origin my-new-feature' does not have to be repeated)
 +  - Use the GitHub interface at https://github.com/YOURNAME/cp2k to create a pull-request
 +
 +===== Update your copy of the master/rebase your patch =====
 +
   - To update the 'master' of your fork to the same state as the 'master' of the CP2K repository:   - To update the 'master' of your fork to the same state as the 'master' of the CP2K repository:
      - tell your local git repository once about the remote: **git remote add upstream https://github.com/cp2k/cp2k.git**      - tell your local git repository once about the remote: **git remote add upstream https://github.com/cp2k/cp2k.git**
      - make sure you are on the right branch: **git checkout master**      - make sure you are on the right branch: **git checkout master**
-     - 'rebase' your current branch on top of the cp2k/cp2k master: **git pull --rebase upstream master** +     - 'rebase' your current branch on top of the cp2k/cp2k master: **git pull %%--%%rebase upstream master** 
-     push the changes: **git push** +   To update a branch with patches onto the updated master branch:
-  - You can also rebase your feature branch, in this case do the previous point and then:+
      - **git checkout my-new-feature**      - **git checkout my-new-feature**
-     - **git pull --rebase upstream master**, this may generate rebase/merge-conflicts you should resolve now. If you got lost, you can always use **git rebase --abort** (with Git 1.8 and newer) to revert the attempted rebase +     - **git rebase master**, this may generate rebase/merge-conflicts you should resolve now. If you got lost, you can always use **git rebase %%--%%abort** (with Git 1.8 and newer) to revert the attempted rebase 
-     - after a rebase of a branch with commits which was already pushed to a remote, you have to force-push: **git push --force**+     - after a rebase of a branch with commits which was already pushed to a remote, you have to force-push: **git push %%--%%force** 
 ===== Submit the patch ===== ===== Submit the patch =====
  
Line 48: Line 53:
      - you can check the status of your PR at https://github.com/cp2k/cp2k/pulls      - you can check the status of your PR at https://github.com/cp2k/cp2k/pulls
      - we use 'rebase' to keep the [[https://github.com/cp2k/cp2k/wiki/Git-Tips-&-Tricks  | Git history linear]], meaning that in your final Pull Request there can't be any merge commits      - we use 'rebase' to keep the [[https://github.com/cp2k/cp2k/wiki/Git-Tips-&-Tricks  | Git history linear]], meaning that in your final Pull Request there can't be any merge commits
-  - the PR will trigger the [[https://github.com/cp2k/cp2k/wiki/CP2K-CI | CP2K Continuous Integration system]] to check conventions and running some checks on the PRs+  - the PR will trigger the [[https://github.com/cp2k/cp2k/wiki/CP2K-CI | CP2K Continuous Integration (CI) system]] to check conventions and running some checks 
-     +     - In the case of success, the PR will be merged by one of the CP2K administrators 
 +     - In the case of error, please check what's wrong in the CI logs, fix it in your branch, and commit/push again. The CI will automatically rerun on the new version of the code (no need to close the PR, it will be automatically updated!). Repeat until the CI runs fine
 + 
 +===== Prepare a development environment with Spack ===== 
 + 
 +The HPC package manager [[https://spack.io/|Spack]] can be used to provide a development environment for CP2K. 
 + 
 +<note important>We assume that you followed the basic instructions to install Spack and that the ''spack'' command is available and that you have a checkout of the CP2K source code (for the latter, follow the instructions above).</note> 
 + 
 +  - change into the CP2K directory: ''cd cp2k'' 
 +  - create a Spack environment (here for building an ''sopt'' profile) to make sure we collect all dependencies in one view: ''spack env create -d envs/sopt'' 
 +  - activate the Spack environment using: ''spack env activate -d envs/sopt'' 
 +  - install everything required for CP2K and build & install CP2K from the current source tree (this may take while): ''spack dev-build cp2k@master ~openmp ~mpi'' 
 +  - start a new shell with all the environment variables set using ''spack build-env cp2k@master ~openmp ~mpi -- bash'' 
 +  - to recompile, run: ''make VERSION=sopt'' 
 + 
 +If you experience problems with other tools (like your editor) when inside the Spack environment, you can directly run the build command using: ''spack build-env cp2k@master ~openmp ~mpi %%--%% make VERSION=sopt''
dev/starting.1551796385.txt.gz · Last modified: 2020/08/21 10:14 (external edit)