fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] dw_dev2012-05-17 11:42 pm
Entry tags:

Rough outline of workflow -- aka let's talk

I've been reading up on Git, trying to figure out how to document a process that works for everyone, and it just isn't working. All I know is how I want to do things, and I can only guess what would work best for everyone. So instead of my sitting here writing down guidelines, which might get set in stone even if they don't really work for you, let's actually talk about it, and then document the hell out of what we decide on.

Big bold critical disclaimer: If you are uncomfortable with really vague instructions and a process that might break at any point, just hang back and wait! This is the "We need people to try doing this so we know where the major stress points are" step.

Other disclaimer: We'll document what seems a reasonable way to do things to make it easier for anyone coming in, but that doesn't mean you need to stick to the script strictly. You can manage your code on your end however you'd like -- so long as you send that pull request!

Useful links:

  • github:help -- check out the beginner and intermediate sections, as well as further git resources. I don't think we'll need anything from the other sections, until we run into specific issues.

  • Git flow -- abstraction on top of Git to make the most common workflow more convenient

Here's what we need to figure out:

Starting from scratch

  1. Create a Github account

  2. Set up Git on your computer

    github:help -> "Set up Git" (provides instructions specific to each operating system)

  3. Fork our code

  4. Pick a bug

    We'd still be doing this from Bugzilla, as issues support on Git is very rudimentary, and we use Bugzilla for more things than just code bugs, so we don't want to split them. I believe that this is workable, though!

  5. Start working on the bug

    What I'd like to do is encourage each bug to occur on its own branch.

    A branch is a separate line of development, one that lets you isolate your current set of changes from changes other people make. But if we do this, we'll need to explain the concept of branching, in a way that makes it seem intuitive, somehow! (Does anyone have any good suggestions of how to best explain it?)

    For those playing along,

    To make a branch using git-flow:

    git flow feature start descriptive-text-bug1234
    

    To make a branch using vanilla git:

    git branch feature/descriptive-text-bug1234
    git checkout feature/descriptive-text-1245
    
  6. Edit your code

    This will work the same as before.

  7. Test your changes

    Make sure your code is live on your own server (a Dreamhack will work here -- we're still talking about the best way to integrate the Dreamhack machine in the process, but at the very least we'll make sure it's very clear how to send your changes to your Dreamhack). Restart the server if necessary. Test that your changes have had the desired effect, and have not broken anything otherwise

  8. Commit your changes

    Committing means saving your current set of changes along with a description of what these changes are. "Commit early, commit often" is a good mantra. Commit at each good stopping point, or whenever you have a coherent set of changes.

    To those familiar with Mercurial, let's talk about the staging area in Git. The staging area means that instead of commiting all your changes, you'll need to tell git which of the files you've changed which you want to commit this time.

    It may help a bit to see this in GUI form: it's like you were presented with a list of filenames with checkboxes, and you need to check each one to include it with the current commit. The thing that trips up most people coming into Git is that when we start the commit process, nothing is checked on this list, so you have to have a separate step first of adding all the files.

    commit screen in the Github GUI. Contains a textbox to type in a commit message, a list of files that have changed with checkboxes to select/deselect them. Also displays the actual lines that have been changed in each file, with the ability to select / deselect per line.

    This is roughly equivalent to:

    Vanilla git command:

    git add cgi-bin/DW/Teleporter.pm t/teleport.t
    git commit
    

    Then fill in with a commit message, example:

    (Bug 1234) Make sure we always foo the bar

    One complication: if you're working locally on your computer (say you want to use a GUI text editor), and have your Dreamhack as your web server -- that is, they're not both on the same computer -- it might make sense to commit first, and then push your changes to your Dreamhack for testing (command will be similar to that in step 9 below, but instead of having Github as a destination, your Dreamhack will be the destination)

    The alternative so far has been to use FTP to copy over each file that you've changed -- making sure you navigate to the right directory on the Dreamhack side each time. The first option is harder to explain, the second option is way more work and runs the risk of missing something, so the question of how to handle this has been the major roadblock in this whole conversion process -- this step is the fuzziest, right now, like I said in step 7. We may ask people to try it both ways and see which one is clearer. Or if anybody has any better solutions, please please please suggest them!

  9. Now publish your changes to Github, so other people can look at it

    To do this using git-flow:

    git flow feature publish descriptive-text-bug1234
    

    To do this using vanilla git:

    git checkout develop
    git push origin descriptive-text-bug1234
    
  10. Then ask us to take a look

    Send us a pull request -- which basically means you're asking us to suck your changes into the main Dreamwidth code repository.

  11. Wait. Respond to any questions brought up in review, or if you'd like, pick up a new bug (start from #4)

What comes after the first patch has tripped up a lot of people. The old way of doing things, and what we're discussing now are roughly similar when you're starting from scratch. It's here, after the first patch, that the difference is immediately clear.

Picking up more bugs

  1. Update your repository from the latest code

    Vanilla git:

    # switch back to the develop branch
    git checkout develop
    
    # pull in changes
    git pull upstream develop
    

    If you'd had changes that aren't on their own branch, you'd have to deal with merging or rebasing here. Luckily, all your changes are set aside in another branch, yeah?

  2. Start from step 4 above

Making additional tweaks after a review

  1. Switch back to the relevant branch

    Git flow:

    git flow feature checkout descriptive-name-bug1234
    

    Vanilla Git:

    git checkout feature/descriptive-name-bug1234
    
  2. Start from step 6 above

There are other things we should discuss, like how to make sure your changes are against the latest version of the repository when you submit them, how to have multiple people work collaboratively on the same bug (which is where Github really shines!), how to best adapt to a branch-y workflow as opposed to a Mercurial queue-based workflow, and the subtle details of command-line client vs GUI client. I don't want to distract from the overall goal here of trying out the basic workflow, but I'll post more about those more advanced things in a few days and we can talk them over once everybody who's interested has a chance to play around a bit.

denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2012-05-17 03:51 pm (UTC)(link)
Thank you so much for all the work you've done in putting this together so far! (Also, lol teleporter.)

I will reiterate two quick things for everybody watching: one, the process really is super fuzzy in a few places (I haven't even tried doing any of this myself because I'm the type to get really annoyed by super fuzzy process, so if you're like me, definitely just hang tight) and two, there really are a lot of subtle details that we can discuss -- [personal profile] fu mentioned a bunch of them at the end of her post but I'm sure everybody can think of specific scenarios that they want answers about. Right now, we really are looking for discussion on the basic workflow steps for a single bug that's being done all at once (like the ones provided here), not the more advanced stuff like collaboration or a major bug being worked on over extended time. That's all important stuff to talk about too, but we want to get the basic workflow down first.
cesy: "Cesy" - An old-fashioned quill and ink (Default)

[personal profile] cesy 2012-05-17 04:05 pm (UTC)(link)
git branch feature/descriptive-text-bug1234
git checkout feature/descriptive-text-1245

You can do these both at once: git checkout -b feature/descriptive-text-bug1234

Is it worth clarifying the difference between origin (your fork) and upstream (Dreamwidth main repo)? My usual process after finishing a bug and pushing it is to switch back to the master branch, pull from upstream, push to origin, then checkout a new branch for the next bug. That means the Github GUI is up-to-date and easy to use for all their visual comparison stuff.

Also, before pushing to Github / publishing and pull requesting, I usually rebase to catch any changes made while I was working, to make it easier for whoever reviews and merges the pull request.

Edit: Also, given all of this, I am contemplating getting back into DW development. Can you link me to instructions for installing DW locally, or is there any chance we could install Dropbox or another syncing option on the Dreamhacks? AO3 has had a lot of success with Dropbox on their Dreamhack equivalent.
Edited 2012-05-17 16:07 (UTC)
cesy: "Cesy" - An old-fashioned quill and ink (Default)

[personal profile] cesy 2012-05-17 08:33 pm (UTC)(link)
Yeah, we did a bit of that with the prompt memes functionality. If one of you is the main dev, and the other person is helping out with smaller bits, then the main person can rebase onto master after merging in their assistant's bits, then the assistant has to start again from the main developer's new version and do another round. If you're both equal and all over the code, and haven't agreed who's going to do the final pull req, it gets messy and you can't rebase.

I'm not sure if I've explained that very well - let me know if it doesn't make sense. Basically person A starts off from master, codes part 1 of the new feature, pushes. B pulls that branch, codes part 2. Meanwhile, A codes part 3 and the master moves ahead with other development. B finishes part 2, A publishes part 3 (without rebasing, ignoring master at this stage, since A knows B is working off zir code). B rebases off A, then pull requests to A's fork. A merges B's code, and now has a branch that contains 1, 2 and 3 all neatly. A can then rebase to master and force publishes, breaking history. B restarts the next bit of development off the back of A's neatly rewritten history, and the cycle starts again. Repeat as necessary until the feature is done, then A can pull req to the main repo, with B's commits all being appropriately credited and showing as merges into A's branch, and A's branch merged into master all at once.
sophie: A cartoon-like representation of a girl standing on a hill, with brown hair, blue eyes, a flowery top, and blue skirt. ☀ (Default)

[personal profile] sophie 2012-05-17 05:06 pm (UTC)(link)
Hi!

Fu pointed me here. :) I'm curious how the AO3 manages to have Dropbox work on a single server for everybody - after all, there's no proof from Dropbox's point of view that it's not just one user using multiple accounts to get around the limit on free Dropbox accounts. So I'm curious about they've solved that, and also how you work with running multiple daemons.
cesy: "Cesy" - An old-fashioned quill and ink (Default)

[personal profile] cesy 2012-05-17 08:44 pm (UTC)(link)
Every user has two dropbox accounts - their hack one and their personal one. I don't know all the details on the server side, but I imagine [personal profile] sidra or [personal profile] astolat would be willing to share.

When a user first sets up their hack, they start dropboxd and get the prompt to link their computer to an account. They create a brand new Dropbox account, make an "OTW-Projects" folder in it, then share that folder with their personal Dropbox account on their home computer. That lets each user edit their code on their own computer, it syncs with the 'hack, but without sharing their personal files with the rest of the 'hack users.

Each user has to start and stop their own dropbox daemon - I'm not sure how that's set up from a sysadmin point of view to stop them interfering with each other.
necaris: me looking dapper at a wedding (Default)

[personal profile] necaris 2012-05-18 12:33 am (UTC)(link)
From what I can see (http://dropboxwiki.com/Forums_FAQ/Running_Multiple_Instances_Of_Dropbox#Unix) Dropbox sets things up relative to $HOME, so multiple instances should be fine so long as they're run by separate users :-)
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2012-05-19 01:19 pm (UTC)(link)
OK, I'm not interested in having my github account sitting between the git repo on my dreamhack and the main Dreamwidth github repo, so my ideal workflow would include submitting a pull request from the command line on my dreamhack. Can I do that? Pointers to TFM gratefully accepted if it explains how.

ETA: looks like https://github.com/defunkt/hub may be what I'm looking for. More later.
Edited (https://github.com/defunkt/hub) 2012-05-19 14:19 (UTC)
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2012-06-21 06:16 pm (UTC)(link)
OK, here's what I did. I was hoping initially not to need a github repo of my own (since I wasn't planning to use it for anything), but apparently I need one because I can't send pull requests directly from the git repo on my dreamhack to the main Dreamwidth github repo.

mkdir dw-free-git
git clone https://github.com/pauamma/dw-free dw-free-git
cd dw-free-git
git remote add upstream git://github.com/dreamwidth/dw-free.git
git fetch upstream
git branch feature/obsolete-email-bug4448
git checkout feature/obsolete-email-bug4448
vi `git grep -l fduuvrzv`
vi `git grep -l afunamatata.dw`
git commit -a
git remote set-url origin https://pauamma@github.com/pauamma/dw-free
git push --all
hub pull-request -b dreamwidth/dw-free:develop
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2012-07-25 07:24 pm (UTC)(link)
OK, so here are the "work on something else, then return to bug after feedback on pull request" commands:

git checkout develop
git branch andnowforsomethingcompletelydifferent
git checkout andnowforsomethingcompletelydifferent
vi README
git commit -a
git push --all
git branch feature/obsolete-email-bug4448
git checkout feature/obsolete-email-bug4448
vi cgi-bin/LJ/Console/Command/MakeInvites.pm
git push --all
hub pull-request -b dreamwidth/dw-free:develop

At this point, there are, as far as I'm concerned, 2 showstoppers with the suggested github workflow:

1- Submitting a pull request (the equivalent of uploading a patch to Bugzilla) doesn't update the bug status.
2- Merging a pull request (or whatever you call the equivalent of comitting a patch to the main hg repo) doesn't post to changelog.

I think I heard someone mention there might be a way to automate #2 (although it's not implemented yet, unless I missed something). However, I can't think of a way to get #1 without considerable manual effort. (Tracking the branch associated with the bug on the developer's own github repo, if that would notify of pull requests, would require knowing when that branch is created and what it's called, neither of which can be automated as far as I can tell.)

Anyone has an idea?
mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)

[staff profile] mark 2012-07-25 07:46 pm (UTC)(link)
Github has support for adding hooks that do anything. It's easy for us to create a callback service that Github will post to when someone comments, adds a pull request, etc etc. We extract the bug ID and then update Bugzilla. Easy-peasy.

Both are solvable with this.
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2012-07-25 07:49 pm (UTC)(link)
In the meantime I still think we should go with "upload your favorite cat macro as an attachment, set review? commit? flags on it" ;)

(I know, I know, attachment and db size, but it's a funny thought!)
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2012-07-25 07:52 pm (UTC)(link)
Good to know. (Who's working on those bits?)
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2012-07-26 08:45 am (UTC)(link)
Hmm. Not as much "interested" as "need it badly for Github to be usable for me, and therefore motivated to get it done somehow including by doing myself if it comes to that". But if you're asking me to do it, that's close enough from your point of view, I think. Either way: I'll need reference docs for Github plugin dev and for the Bugzilla RPC/API/whatever. Gimme URLs? Also, what is the timeline for moving the other repos to Github? Or are we sticking to hg for those?
pauamma: Cartooney crab wearing hot pink and acid green facemask holding drink with straw (Default)

[personal profile] pauamma 2012-07-26 06:34 pm (UTC)(link)
Thanks. I'll look at the links. (Are we phasing out dw-ops and dw-private, then?)
afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)

[personal profile] afuna 2012-07-26 07:03 pm (UTC)(link)
dw-private isn't relevant to hooks. dw-ops hmm good point, we'll probably move it over at some point?
baggyeyes: Bugs Bunny and the Bull (Default)

[personal profile] baggyeyes 2012-05-28 08:55 pm (UTC)(link)
I'm still scratching at learning Git myself...but I thought this reference might come in handy here too:

git - the simple guide