Page MenuHomePhabricator

PendingChangesBot: Pull requests howto
Open, Needs TriagePublic

Description

TASK: Add pull request handling guide to PendingChangesBot

Example workflow

Example pull request: https://github.com/Wikimedia-Suomi/PendingChangesBot-ng/pull/27

1.) Fetch the code

mkdir 27
cd 27
git clone https://github.com/Wikimedia-Suomi/PendingChangesBot-ng.git
cd PendingChangesBot-ng

2.) Fetch the pull request

git fetch origin pull/27/head:pr-27
git checkout pr-27

3.) Create virtualenv

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

4.) Add username to app/user-config.py

echo "usernames['meta']['meta'] = 'YOUR_WIKIMEDIA_USERNAME'" > app/user-config.py
echo "usernames['wikipedia']['fi'] = 'YOUR_WIKIMEDIA_USERNAME'" >> app/user-config.py

4.b) Make first login to meta.wikimedia.org and superset.toolforge.org
If you have problems with superset login and you have logged in earlier then try logging out and then login for force refreshing the login information.

5.) Test code with ruff

ruff check app

6.) Run migrations, tests and app

cd app
python manage.py makemigrations
python manage.py migrate
python manage.py test
python manage.py runserver

7.) Review code
If something doesn’t work then return feedback as a comment and wait new version

8.) When there is new version then pull changes and return to #5

git fetch origin pull/27/head     
git merge FETCH_HEAD

9.) All OK
If everything works then select “Squash and merge” in github and write commit message. Also leave thank you message for the contributor on pull request thread.

10.) clean local tree*

cd ../../
rm -rf 27

Event Timeline

Zache updated the task description. (Show Details)
Zache updated the task description. (Show Details)
Zache updated the task description. (Show Details)
Zache updated the task description. (Show Details)

Steps 3 and 4 could be before 2 (Fetch the pull request) since they only need to be done once.

Checkout, fetch, pull etc. are recurring steps in development, not part of initial setup.

Also there might need to be initial pull (fetch+merge) at the start

Apparently bitbucket uses slash instead of dash in pull request naming? (such as pr/101)
The dash-format does not seem to be working (maybe github deleted those branches after merging?)
The way github manages pull requests does not seem to be visible to real git tool, only github's own gh cli..

Working checkout of github's pull requests would be something like this:
git checkout -b <remote branch> main
git pull git@github.com:<user>/PendingChangesBot-ng.git <branch>

.. where <user> is the one who made the pull request

The current guide expects that one creates a new clean directory for each pull request. It technically is not needed and the user could do everything in the same directory, but as you would anyway may need to clean up the database as there may be migrations, it is easier to track these when the whole thing is in separate directories.

However, I changed the order a little bit but kept the initial git commands in front as, at least for me, it was easier mentally to do all initial git commands first.

I also added a "thank contributor" message as part of the process at end. It is just something that says something nice in the comment thread which tells that we are appreciating the contribution and not just silently merging the pull request.

Zache updated the task description. (Show Details)