Difference between revisions of "Dev Getting Started"

From Dreamwidth Notes
Jump to: navigation, search
m (Welcome to Development: added wikilink to dreamhacks)
m (no more free/nonfree)
 
(78 intermediate revisions by 15 users not shown)
Line 1: Line 1:
== Welcome to Development ==
+
Welcome to Dreamwidth code development! This page is a guide to how to get started with hacking on the Dreamwidth code. It's intended to cover all steps of the process from the very beginning, but each individual step is a brief overview -- follow the links for more detail. If you're confused about anything here, you can ask us in <dwcomm>dw-dev-training</dwcomm> or the latest <dwcomm>dw-dev</dwcomm> [https://dw-dev.dreamwidth.org/tag/questions question thread], or come talk to us in the [https://dw-dev.dreamwidth.org/209778.html Discord] [[Chat]] channels. One-on-one mentorship may be available if time permits.
  
This document is designed to outline our resources on setting up the DW code on your server.  There is, currently, a high expectation of "tech savvy.If you do not know what sudo is or how to get a root console, then you probably are going to get pretty lost in this. Instead, you may want to request a [[Dreamhacks]] account.
+
This is geared at people who have little to no development experience. If you've got more experience and just need the details of how our project differs from other open source projects out there, check out the [[Dev Quick Start]] list.
  
Doesn't mean you shouldn't try, but forewarned is forearmed!
+
The languages and skills Dreamwidth development uses are:
  
Help can be found on IRC (#dw on irc.zhzh.org) or on the mailing lists.  You might also like [[Setting up Dreamwidth on Linode]] for a quick and easy way to get your own Dreamhack set up on a hosting service.  There is also [[Dreamwidth Scratch Installation]] and [[Running Dreamwidth on a Mac OS X system]].
+
* Perl (the majority of the project)
 +
* [[BML]] (custom templating language inherited from LiveJournal which we are currently phasing out)
 +
* [[Routing and Template Toolkit|TT]] (Template Toolkit - better templating language, used for new pages)
 +
* [[Styles|S2]] (custom templating language used in journal styles)
 +
* HTML / CSS / [[Foundation]]
 +
* Javascript / JQuery
 +
* MySQL and DBI (the Perl interface to MySQL and other SQL databases)
 +
* Test::More (for writing automated tests)
  
If you just want to jump into development quickly, without having to worry about setting up your server environment, you can also ask for a DreamHack account. A DreamHack is a working environment, currently hosted by volunteers, with everything you need to get started already set up for you. If you want one, send an email with your email address and desired username (max. 13 characters) to dreamhack (afunamatata.com).
+
You don't need to know them all! Some familiarity with at least one will be helpful, but we welcome people at all levels, and are happy to answer questions and give advice as long as you're willing to learn.
  
The original LJ Server documentation is [http://www.livejournal.com/doc/server/ here].  You might also find the [http://wiki.ljcode.org/ LJCode wiki] useful.
 
  
You can find information on how to keep your code updated on [[Dev Maintenance]], information on programming style on [[Dev Programming Guidelines]], information on finding things in [[Dev Finding Things]], and information on submitting patches on [[Dev Patches]].  There is a [http://bugs.dwscoalition.org/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&keywords_type=allwords&keywords=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=substring&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailcc2=1&emailtype2=substring&email2=&bugidtype=include&bug_id=&chfie comprehensive bug list] as well as other useful info on [[Bugzilla]].  See [[Development]] for a more complete reading list, or look through the pages in [[:Category:Development]].
+
== One time only: Initial setup ==
  
Niggling difficulties and problems in the installation should be reported to [http://www.dwscoalition.org/show_bug.cgi?id=61 Bug 61].
+
What you need:
  
If you want to look at ljcom code, you can check it out like this:
+
=== A working Dreamwidth installation ===
  
svn co http://code.livejournal.org/svn/ljcom/trunk/ ljcom
+
To hack on the Dreamwidth code, you'll need a development environment: a place where you can install the Dreamwidth code yourself, to make changes and submit them.  We offer hosted sandbox development environments where we'll install the code for you. We call them [[Dreamhacks]], and they're available free of charge for anyone who's interested in contributing to the project. (It's possible for you to install the code yourself on your own server, but we don't recommend it for beginners. Even the most experienced Dreamwidth developers mostly work on Dreamhacks.)
  
BUT ONLY USE IT AS AN EXAMPLE. We can't use code from that repository; it belongs to LiveJournal and is not open source. And only look at it if you have a specific reason--we want people who are able to sign affadavits that they have <i>not</i> seem the <tt>ljcom</tt> code and are thus able to do [[clean room]] implementations.
+
* [http://hack.dreamwidth.net/ Apply for a Dreamhack]: this will give you a hosted development environment with everything already ready for you to get started.  
  
Developers should check out the documentation on [[Design]] as well.
+
* Go through the [[Beginning dev checklist]] and follow along with the steps for getting your Dreamhack account set up. Most of these steps are tasks you'll only have to do once to make sure your development environment is set up to hack on.
  
== Requirements ==
+
=== A GitHub account ===
  
Here is what you'll want for a development environment. Sure, you can probably get away with less or different, but that's not what we're going to support.  The DW code is known to work with the following.  But we'd love to hear of your results using something else.
+
[[Git Getting Started | GitHub]] is the version control system we use. It keeps the "master version" of the Dreamwidth code, keeps track of the changes you make, and allows you to submit those changes to us for us to review and incorporate them.
  
=== Linux based server ===
+
* Create a GitHub account with your preferred username.
  
We are presently using Ubuntu. This may stay or become Debian or Centos at some point, that's undecided. But for now, Ubuntu is the supported distro. If you use anything else, you will need to be familiar enough with the differences to work out any different steps on your own. (But we'd love to hear success stories and get documentation for other ones!)
+
* [https://help.github.com/articles/fork-a-repo/ Fork] the [https://github.com/dreamwidth/dreamwidth/ dreamwidth] repository from the Dreamwidth organization.
  
Notes for other OSes:
+
===A basic sense of the code structure and how to find things===
*[[Running Dreamwidth on a Mac OS X system]]
+
  
=== 64-bit (x86_64 typically, NOT i686/i386) ===
+
You aren't going to know everything right up front, of course, but there are a few things you can look through and familiarize yourself with.
  
This is something you can probably get away without doing, but you'll be unable to test some things and others might be a bit wonky.  Notably, you need the 64 bit version of Perl in order for the pack/unpack operations to work for memcache.
+
* Familiarize yourself with Perl, the language that the majority of DW development is done in. The best reference that we've found to point people at is [http://www.ebb.org/PickingUpPerl/ Picking Up Perl]. You absolutely don't need to be a Perl guru to submit a patch, but you should be familiar with the basic syntax.
  
But if you absolutely do not have a 64 bit system, then you might still be okay. Don't use memcache and don't try to use more than 30 friend groups and you shouldn't run into any big issues.  You will also have to change the pack functions in Entry.pm from using NNNQN to NNNLN to avoid a "Invalid type 'Q' in pack" error when posting to a journal.
+
* If you'd like to practice first, check out [https://openhatch.org/missions/ OpenHatch's Training Missions] -- they'll let you practice with some of the tools you might need! (In particular, you might find their Git training mission helpful.)
  
If you're not sure whether you have a 64 bit system or not, check out the collection of tips on this page: http://www.stata.com/products/64bit.html
+
* Browse through some of the [http://github.com/dreamwidth/dw-free Dreamwidth source code] to get a good sense of where things are and what the setup looks like. The basic directory structure, as well as some guidelines about what goes where, can be found in [[Directory Structure]].  
  
=== 512mb RAM ===
+
* Read the [[Programming Guidelines]]. (You may not understand all of the items there, but you can familiarize yourself with them, and start noticing when existing code doesn't follow the rules as you read.)
  
I have gotten away with less.  Depends on how much traffic you expect and what else you are running on the box.  Also, if you intend on running TheSchwartz workers or not. If you do not, and you only run the web site code, then it will probably work on 256.
+
* If you start to get overwhelmed, don't worry! Go do something else for a bit and come back to this later -- this doesn't all have to be done at once. You can read an old [http://azurelunatic.dreamwidth.org/6731755.html dev pep-talk].  Also, have a look through the Epic List of [[Things Real Dreamwidth Programmers Do]] if you start feeling a bit of [https://en.wikipedia.org/wiki/Impostor_syndrome impostor syndrome]. Finally, you can always ask for help in irc or in <dwcomm>dw-dev-training</dwcomm> -- everybody who's working on the project now was in your shoes at one point, and we all remember what it's like to feel overwhelmed and over our heads. We want to help you!
  
=== Dedicated! ===
+
* If you run into problems following any of these instructions, we also want to know about it so we can fix this documentation. You can let us know in irc or in <dwcomm>dw-dev-training</dwcomm>, or make a note on the [[Dev Wanted How-To]] or [[Installation Wanted How-To]] pages to describe what you found confusing.
  
The LJ/DW code is pretty heavy, and doesn't like other things running.  You should expect that if you are not that technical, you will need a fairly blank server to run it on.  But if you are technical you can do some pretty convoluted setups...  (This one is more of a recommendation and not a hard requirement.)
+
== Finding something to work on ==
  
=== root ===
+
Once you've gone through the initial setup, pick an issue to work on. The issues are kept in [http://wiki.dreamwidth.net/wiki/index.php/Github_Issues GitHub Issues].
  
If you do not have root on the box, you are in for a rough road. Sure, the code doesn't need root privileges to run.  But there are a lot of libraries that need to be installed on the system. If you are using a shared development environment where the owner has installed the modules for you, then you should be fine, but keep in mind that you will not be able to run the code on the standard HTTP port (80) as a non-root user.
+
* Look through the [https://github.com/dreamwidth/dw-free/labels/curated:%20beginner curated:beginner] label for issues that someone thinks would make a good first issue to work on. From time to time, people also post lists of "[http://dw-dev-training.dreamwidth.org/tag/babydev+bait babydev bait]" to <dwcomm>dw_dev_training</dwcomm>, and there is [http://dw-dev-training.dreamwidth.org/45772.html a masterlist].
  
=== MySQL ===
+
* Let people know that you're working on the bug by assigning it to yourself. Comment on the issue you've chosen with some variation on the word "claim" ("claim", "claimed" and "claiming" all work, and can be surrounded by any other text). This will trigger our bot to assign the issue to you.
  
You will need a MySQL database.  It can be local or remote, it doesn't matter really.  As long as you have the ability to create/drop/alter tables in a directory, that's what matters.
+
* [[Git How To#How to create a new branch for feature development / bugfixes|Create a new branch in git for this issue]] so you have a place to make your changes.
  
== Suitable hosting ==
+
== Making your changes ==
  
These hosts are reported to have suitable plans for running Dreamwidth code:
+
* Make sure your git repository is [[Dev_Maintenance#Updating_dw-free|up to date]].
  
* [http://www.linode.com/ Linode] -- 64-bit available by request, not the default; used by <ljuser>afuna</ljuser> and <ljuser>exor674</ljuser>.  Instructions for setting up on this host from a pre-built image (from <ljuser>exor674</ljuser>) are on [[Setting up Dreamwidth on Linode]].
+
* Make your changes, probably in your [[Dreamhacks|Dreamhack]] ([[Beginning_dev_checklist#Editors|editing text files]], though the tricky part is [[Dev Finding Things|finding things]]).
* [http://www.slicehost.com/ Slicehost] -- used by <ljuser>xb95</ljuser>
+
  
They are both VPS hosting plans that will give you full root access at a decent price--about $20 a month.
+
* [[Dev_Maintenance#Restart_the_server|Restart Apache]] and test your changes on the Dreamhack. It's a good idea to test multiple use cases, including logged in/not logged in, community vs personal journal (if applicable), personal journal with different settings, etc.  
  
 +
* [[Git How To#The_Basics|Commit your changes to git.]]
 +
 +
* [[Git How To#The_Basics|Push your new git branch to your github account.]]
 +
 +
 +
== Submitting your changes ==
 +
 +
* Once you're satisfied that your changes fix the issue and don't introduce any new bugs, [[Git How To#How to submit a pull request|open a pull request.]] This sends your changes to us for us to look over in [[Code Review|review]].
 +
 +
* A senior Dreamwidth developer will look over your changes and see if they can be accepted or if there are things you need to change. If there are things that could be improved, the reviewer will comment on the commit and give you notes on what can be improved. Don't worry if your changes don't pass review on the first time -- it's really common for pull requests to go through several versions before they're committed.
 +
 +
* If your pull request needs more changes, you can go back to the branch you made for the change and make those changes. Once you commit them to your branch and [[Git How To#The_Basics|push your changes]] to make them public, the pull request will update automatically. However, this doesn't fire off a notification to the folk reviewing the code, so please leave a comment on your pull request to let people know that the requested changes have been made!
 +
 +
* When your pull request is accepted, the person who accepts it will close the pull request and the issue that the pull request fixed.
 +
 +
== The next fix! ==
 +
 +
* Once your pull request is accepted and merged into the main branch, you can delete the branch for that issue on your GitHub account.
 +
 +
* Switch back to the 'master' branch on your Dreamhack and update to the most current code.
 +
 +
* Pick the next issue to work on!
 +
 +
== Further reading ==
 +
 +
This is a brief overview of the process. There are plenty of places to go for more information. Useful wiki pages include:
 +
 +
* [[Dev Finding Things]] - getting around the code base and figuring out where to start when looking for a specific feature
 +
* [[Dev Programming Guidelines]] - programming style
 +
* [[Design]] - things to keep in mind when designing features. Developers, please take note of this page!
 +
* [[Dev Maintenance]]  - how to keep your code updated
 +
* [[Git How To]] - basic commands for keeping track of your changes using version control. Also includes instructions for submitting those changes via a pull request
 +
* [[Git Getting Started]] - a collection of resources for using Git
 +
* [[Github Issues]] - instructions for filing and claiming bugs to work on
 +
* [[Development]] - another list of stuff that might be useful for you at some point, in particular [[Development#Customising_Your_Dev_Environment | Customising Your Dev Environment]] (for instructions on setting up the Support Board, enabling Beta Features, and so on)
 +
* [[:Category:Development]] - every page tagged with the Development category on the wiki
 +
 +
==What'd we miss?==
 +
 +
If you run into anything in the process that isn't well-documented, or you have questions, you can ask in the <dwcomm>dw_dev_training</dwcomm> community or in the #dreamwidth-dev irc channel. You should also make a note on the [[Dev Wanted How-To]] or [[Installation Wanted How-To]] wiki pages so we can document it better for the next person to come along!
 +
 +
[[Category: Getting Started]]
 
[[Category: Development]]
 
[[Category: Development]]

Latest revision as of 22:09, 17 December 2022

Welcome to Dreamwidth code development! This page is a guide to how to get started with hacking on the Dreamwidth code. It's intended to cover all steps of the process from the very beginning, but each individual step is a brief overview -- follow the links for more detail. If you're confused about anything here, you can ask us in [info]dw-dev-training or the latest [info]dw-dev question thread, or come talk to us in the Discord Chat channels. One-on-one mentorship may be available if time permits.

This is geared at people who have little to no development experience. If you've got more experience and just need the details of how our project differs from other open source projects out there, check out the Dev Quick Start list.

The languages and skills Dreamwidth development uses are:

  • Perl (the majority of the project)
  • BML (custom templating language inherited from LiveJournal which we are currently phasing out)
  • TT (Template Toolkit - better templating language, used for new pages)
  • S2 (custom templating language used in journal styles)
  • HTML / CSS / Foundation
  • Javascript / JQuery
  • MySQL and DBI (the Perl interface to MySQL and other SQL databases)
  • Test::More (for writing automated tests)

You don't need to know them all! Some familiarity with at least one will be helpful, but we welcome people at all levels, and are happy to answer questions and give advice as long as you're willing to learn.


One time only: Initial setup

What you need:

A working Dreamwidth installation

To hack on the Dreamwidth code, you'll need a development environment: a place where you can install the Dreamwidth code yourself, to make changes and submit them. We offer hosted sandbox development environments where we'll install the code for you. We call them Dreamhacks, and they're available free of charge for anyone who's interested in contributing to the project. (It's possible for you to install the code yourself on your own server, but we don't recommend it for beginners. Even the most experienced Dreamwidth developers mostly work on Dreamhacks.)

  • Apply for a Dreamhack: this will give you a hosted development environment with everything already ready for you to get started.
  • Go through the Beginning dev checklist and follow along with the steps for getting your Dreamhack account set up. Most of these steps are tasks you'll only have to do once to make sure your development environment is set up to hack on.

A GitHub account

GitHub is the version control system we use. It keeps the "master version" of the Dreamwidth code, keeps track of the changes you make, and allows you to submit those changes to us for us to review and incorporate them.

  • Create a GitHub account with your preferred username.

A basic sense of the code structure and how to find things

You aren't going to know everything right up front, of course, but there are a few things you can look through and familiarize yourself with.

  • Familiarize yourself with Perl, the language that the majority of DW development is done in. The best reference that we've found to point people at is Picking Up Perl. You absolutely don't need to be a Perl guru to submit a patch, but you should be familiar with the basic syntax.
  • If you'd like to practice first, check out OpenHatch's Training Missions -- they'll let you practice with some of the tools you might need! (In particular, you might find their Git training mission helpful.)
  • Browse through some of the Dreamwidth source code to get a good sense of where things are and what the setup looks like. The basic directory structure, as well as some guidelines about what goes where, can be found in Directory Structure.
  • Read the Programming Guidelines. (You may not understand all of the items there, but you can familiarize yourself with them, and start noticing when existing code doesn't follow the rules as you read.)
  • If you start to get overwhelmed, don't worry! Go do something else for a bit and come back to this later -- this doesn't all have to be done at once. You can read an old dev pep-talk. Also, have a look through the Epic List of Things Real Dreamwidth Programmers Do if you start feeling a bit of impostor syndrome. Finally, you can always ask for help in irc or in [info]dw-dev-training -- everybody who's working on the project now was in your shoes at one point, and we all remember what it's like to feel overwhelmed and over our heads. We want to help you!
  • If you run into problems following any of these instructions, we also want to know about it so we can fix this documentation. You can let us know in irc or in [info]dw-dev-training, or make a note on the Dev Wanted How-To or Installation Wanted How-To pages to describe what you found confusing.

Finding something to work on

Once you've gone through the initial setup, pick an issue to work on. The issues are kept in GitHub Issues.

  • Let people know that you're working on the bug by assigning it to yourself. Comment on the issue you've chosen with some variation on the word "claim" ("claim", "claimed" and "claiming" all work, and can be surrounded by any other text). This will trigger our bot to assign the issue to you.

Making your changes

  • Restart Apache and test your changes on the Dreamhack. It's a good idea to test multiple use cases, including logged in/not logged in, community vs personal journal (if applicable), personal journal with different settings, etc.


Submitting your changes

  • Once you're satisfied that your changes fix the issue and don't introduce any new bugs, open a pull request. This sends your changes to us for us to look over in review.
  • A senior Dreamwidth developer will look over your changes and see if they can be accepted or if there are things you need to change. If there are things that could be improved, the reviewer will comment on the commit and give you notes on what can be improved. Don't worry if your changes don't pass review on the first time -- it's really common for pull requests to go through several versions before they're committed.
  • If your pull request needs more changes, you can go back to the branch you made for the change and make those changes. Once you commit them to your branch and push your changes to make them public, the pull request will update automatically. However, this doesn't fire off a notification to the folk reviewing the code, so please leave a comment on your pull request to let people know that the requested changes have been made!
  • When your pull request is accepted, the person who accepts it will close the pull request and the issue that the pull request fixed.

The next fix!

  • Once your pull request is accepted and merged into the main branch, you can delete the branch for that issue on your GitHub account.
  • Switch back to the 'master' branch on your Dreamhack and update to the most current code.
  • Pick the next issue to work on!

Further reading

This is a brief overview of the process. There are plenty of places to go for more information. Useful wiki pages include:

  • Dev Finding Things - getting around the code base and figuring out where to start when looking for a specific feature
  • Dev Programming Guidelines - programming style
  • Design - things to keep in mind when designing features. Developers, please take note of this page!
  • Dev Maintenance - how to keep your code updated
  • Git How To - basic commands for keeping track of your changes using version control. Also includes instructions for submitting those changes via a pull request
  • Git Getting Started - a collection of resources for using Git
  • Github Issues - instructions for filing and claiming bugs to work on
  • Development - another list of stuff that might be useful for you at some point, in particular Customising Your Dev Environment (for instructions on setting up the Support Board, enabling Beta Features, and so on)
  • Category:Development - every page tagged with the Development category on the wiki

What'd we miss?

If you run into anything in the process that isn't well-documented, or you have questions, you can ask in the [info]dw_dev_training community or in the #dreamwidth-dev irc channel. You should also make a note on the Dev Wanted How-To or Installation Wanted How-To wiki pages so we can document it better for the next person to come along!