conda-forge / conda-forge/conda-forge-bot
Make auto merge conditional
- Dominant language
- Python
- Stars
- 76
- Forks
- 99
- Avg merge
- 1h 44m
- Merged PRs (30d)
- 126
Description
_Related discussion:_ https://gitter.im/conda-forge/conda-forge.github.io?at=61fa95d53349fe1c71f02f94
_Idea:_ The bot should be able to take into consideration changes of upstream files before auto-merging a PR.
_Reason:_ Automerge is currently dangerous to use because dependency and license updates are missed. Ref: https://github.com/regro/cf-scripts/issues/1471#issuecomment-957650919
_Approach:_
The new conditional merge would work as follows:
1. Open the PR
2. Read `conda-forge.yml` Ref: https://gitter.im/conda-forge/conda-forge.github.io?at=61fa9615ced11857f98db66e
3. Extract whether auto-merge is enabled
4. Extract whether files are specified
5. If files are specified, download the source
6. Check if lines are specified in `conda-forge.yml` that should be kept/removed
_Note_: Removing lines is required as sometimes the version and requirements are specified in the same file (For example: `setup.py`). This way, the line containing the version can be removed and then the file can be read and checked if something else changed.
7. Get SHA256 of file and compare it with SHA256 specified in `conda-forge.yml` for file.
8. If the SHA256 is the same, merge the PR, if not, post a message about which file changed and maybe post the new SHA256.
_Sample `conda-forge.yml`:_
```yaml
bot:
automerge: true
files:
- /path/to/requirements.txt/in/upstream
SHA256: 001a8e6cd3e7f7304237e1413d0b941f74a0b1fa950155467dfa69c030f535c9
- /url/to/setup.py/in/upstream/at/{{ PKG_VERSION }}
SHA256: 001a8e6cd3e7f7304237e1413d0b941f74a0b1fa950155467dfa69c030f535c9
exclude:
- 15 # The line in the file containing the version
- 19. # Contains something else in the file that can change during versions
```
_To consider:_
1. The `conda-forge.yml` should be set up in a way that an incorrectly configured `files` section throws an error and is not skipped. Otherwise, the auto-merge will become unconditional but the maintainer is not aware of it.
2. Because of line endings etc. it might be that a SHA256 will never match. Maybe we can create an online tool that does this. Experienced users should never need it but it would make it easier for beginners.
3. In v2 this can be combined with an automatic update of deps using regex.
4. Should the linter check that the file actually exists and that the SHA256 is correct when the maintainer initially sets it up?
Contributor guide
Assessment
This issue has not been assessed yet.