Record recommended tech stack for projects - #269
Conversation
✅ Deploy Preview for wonderful-mousse-057100 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
siddharth-krishna
left a comment
There was a problem hiding this comment.
Great idea, thanks! I started to collect some similar recommendations, e.g. repository settings, pre-commit hooks, in this presentation -- perhaps we can merge the recommendations here and launch it and ask everyone to add/update/comment?
Good idea, I added some of the ideas from the slides! I think it would be nice to also add examples for each point (and maybe in the future a template)? |
brynpickering
left a comment
There was a problem hiding this comment.
Some things possibly missing
- use in pre-commit: codespell, markdown linter, snakefmt, yaml linters, markdown link checkers
- add a contributing guideline, a way to list contributors, an .editorconfig
- I've found a CODEOWNERS file to be quite useful as you can get automatic review requests that differ by where in the repo changes have been made and you can enforce at least one codeowner to approve before merging PRs
- something about yaml and data schema when working with configs and data?
| * No force pushes | ||
| * Use pull requests for all changes | ||
| * Merge branches instead of rebasing | ||
| * Squash and merge pull requests to keep the commit history clean |
There was a problem hiding this comment.
I think this is good for python library projects, but in other project types (e.g. snakemake workflows)the full commit history can be quite instructive / can be used to resurrect superseded attempts at solving an issue when it later turns out that it was the correct approach.
There was a problem hiding this comment.
The full PR branch history is preserved by GitHub, and I think this is the better place to archive this information, because it also has the context of why each change was necessary (review comments, CI failures, etc).
I would be okay with merge-merging PRs if everyone had iron discipline and kept their PR branches full of atomic, clean commits with descriptive messages, but too often we have (and it's much easier to have) commits like "fix, fix fix, typo, revert fix fix, ..."
It's been on my list for a while to make a handbook page/section on why I recommend squash-merging all PRs, but some other reasons include: easier to roll-back/revert a breaking change in production, easier to git bisect and find the source of a bug, and every commit on the main branch is a "valid" state of the project that works (or at least, CI passes).
There was a problem hiding this comment.
The full PR branch history is preserved by GitHub
Is that the case even once a branch is deleted? I tend to keep repos clean by deleting branches on merging PRs but I assume at some point you can't roll back that deletion and the branch history is lost forever?
There was a problem hiding this comment.
Yep!
Here's one of the first PRs on the benchmark repo: open-energy-transition/solver-benchmark#9
You can go through and view all the commits still, e.g.: open-energy-transition/solver-benchmark@f56d9ee
We should also add a recommendation to auto-delete PR branches on merge. :)
| * No force pushes | ||
| * Use pull requests for all changes |
There was a problem hiding this comment.
| * No force pushes | |
| * Use pull requests for all changes | |
| * Add [main branch protection](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/managing-a-branch-protection-rule) to include: | |
| * no force pushes; | |
| * at least one `approve` review before merge; | |
| * override rights for project admins only; | |
| * no pushes directly to `main` allowed (i.e. use pull requests for all changes). |
| * Squash and merge pull requests to keep the commit history clean | ||
| * Continuous integration: | ||
| * For public repositories / open source projects: `github actions` | ||
| * For private repositories / internal projects: ? |
There was a problem hiding this comment.
If they are lightweight, github actions could still be possible (what's our total private repo allowance?)
There was a problem hiding this comment.
We pay for GitHub actions per minute on private repos. It's still probably the recommended way, although I'd add that for forks such as pypsa-x it is a good idea to disable win/macOS actions since they cost 4-8x as much.
| * `uv` for new projects | ||
| * always use virtual environments (better reproducibility, isolation, and dependency management) | ||
| * `uv init` to create a new project with default structure | ||
| * `uv add <package>` to add a package to the project | ||
| * `uv pip install <package>` to install a package in the virtual environment without adding it as a dependency | ||
| * `uv run <command>` to run a command in the virtual environment |
| * Documentation: | ||
| * doc strings follow [numpydoc style](https://numpydoc.readthedocs.io/en/latest/format.html) | ||
| * Framework: `mkdocs-material` | ||
| * Hosting: `readthedocs` |
There was a problem hiding this comment.
Github pages can be a better option when there's the possibility of name clashes with existing RTD projects or when in a private repo. Not sure how best to recommend one or the other.
| * doc strings follow [numpydoc style](https://numpydoc.readthedocs.io/en/latest/format.html) | ||
| * Framework: `mkdocs-material` | ||
| * Hosting: `readthedocs` | ||
| * Repositories should use pre-commit framework: `pre-commit` |
There was a problem hiding this comment.
I would consider this to be part of continuous integration
| * Public repositories: use `pre-commit.ci` for automatic checks (instead of integrating `pre-commit` into CI) | ||
| * Private repositories: use `pre-commit` in CI | ||
| * Code style: | ||
| * `black` |
There was a problem hiding this comment.
maybe don't even mention black since ruff handles everything?
| * doc strings follow [numpydoc style](https://numpydoc.readthedocs.io/en/latest/format.html) | ||
| * Framework: `mkdocs-material` | ||
| * Hosting: `readthedocs` | ||
| * Repositories should use pre-commit framework: `pre-commit` |
There was a problem hiding this comment.
Link to your favourite implementation of .pre-commit-config.yaml so others can copy that across to their project if they like
siddharth-krishna
left a comment
There was a problem hiding this comment.
Thanks, Bryn for the review and suggestions! Johannes, whenever you think this is ready I think we can merge it in and iterate in successive PRs. 🚀
| * No force pushes | ||
| * Use pull requests for all changes | ||
| * Merge branches instead of rebasing | ||
| * Squash and merge pull requests to keep the commit history clean |
There was a problem hiding this comment.
The full PR branch history is preserved by GitHub, and I think this is the better place to archive this information, because it also has the context of why each change was necessary (review comments, CI failures, etc).
I would be okay with merge-merging PRs if everyone had iron discipline and kept their PR branches full of atomic, clean commits with descriptive messages, but too often we have (and it's much easier to have) commits like "fix, fix fix, typo, revert fix fix, ..."
It's been on my list for a while to make a handbook page/section on why I recommend squash-merging all PRs, but some other reasons include: easier to roll-back/revert a breaking change in production, easier to git bisect and find the source of a bug, and every commit on the main branch is a "valid" state of the project that works (or at least, CI passes).
| * Squash and merge pull requests to keep the commit history clean | ||
| * Continuous integration: | ||
| * For public repositories / open source projects: `github actions` | ||
| * For private repositories / internal projects: ? |
There was a problem hiding this comment.
We pay for GitHub actions per minute on private repos. It's still probably the recommended way, although I'd add that for forks such as pypsa-x it is a good idea to disable win/macOS actions since they cost 4-8x as much.
| * Continuous integration: | ||
| * For public repositories / open source projects: `github actions` | ||
| * For private repositories / internal projects: ? | ||
| * Use a pinned environment for the CI to ensure continuity and reproducibility |
There was a problem hiding this comment.
@brynpickering or @SermishaNarayana or whoever knows the latest/best way to do this could you please add a section below with instructions and link to it here? Huge thanks
There was a problem hiding this comment.
Using a pinned environment? If we recommend using uv or pixi that would come as standard without the user really having to do anything.
As requested by Sid [here](open-energy-transition/oet-zib-manual#12 (comment)). Supersedes some content in #269 I haven't filled in the `uv` config recommendation section as I don't use it so don't know what would be recommended. I would be inclined to recommend `pixi` for all but pure Python packages, but realise that several use `uv` already and so didn't want to push for it too hard. The reason being that those working on Linux often miss the fact that they are utilising non-python libs that others will need. `pixi` allows those dependencies to be explicitly referenced in the project dependencies for better cross-platform compatibility. ## Changes Proposed in This Pull Request ## Checklist - [ ] I have checked the Deploy Preview link in the netlify bot's comment, and my changes look good - [ ] I tested my contribution locally, and it seems to work fine. - [ ] Code and workflow changes are sufficiently documented. - [ ] If new pages are added, maintainers are assigned for that document. - [ ] If the document falls under a controlled category, a controlled document banner is present. --------- Co-authored-by: Siddharth Krishna <siddharth-krishna@users.noreply.github.com>
|
@siddharth-krishna @euronion is this now stale or could we merge with minimal updates? |
|
I think this PR still has some really useful stuff! But it needs updating before merge:
Would anyone have the bandwidth to do the above? 🙏 |
@siddharth-krishna
The OS coords group had the idea of documenting and harmonising our tech stack that we recommend for our projects, in order to reduce the number of tools we use.
Some ideas written down to start the discussion, list is not complete ofc.
Do we already have something similar?
What do you think about this initative?
Changes Proposed in This Pull Request
Checklist