CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Managing deployments (now we have git)
Pages: 1 [2]

Author Topic: Managing deployments (now we have git)  (Read 4350 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Managing deployments (now we have git)
September 18, 2013, 03:32:06 am
Quote from: jaapjansma on September 18, 2013, 12:26:32 am
my only way to contribute things to core is through patches in the JIRRA. And that is good enough for me as far as I am concerned.

It's a solution that is fine for patches once in a blue moon, but it pushes extra work on the one that has to take the patch and carry it through the "normal" git PR process.

If you have more complex or have more regular patches, the "industrial" solution of using git and pull request is more scalable. All the issues listed here are going to be here (granted, on someone else plate), plus extra issues with patches (and dealing with conflict on a patch is much more painful than through git)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Managing deployments (now we have git)
September 21, 2013, 11:24:31 pm
Quote from: Eileen on September 18, 2013, 02:17:09 am
Thinking back to why I originally abandoned the submodules approach (& whether I should go back to it) - apart from the quirks submodules throws up - I hit a couple things, 1) I found it easier to have a d6 & a d7 deployment branch since I needed different versions - at that point it seemed easier just to commit the directory. The other was the 'cleaning' of patches I tend to do - ie. rebasing against new releases - however, looking at github I see only 3 patches on packages & only a handful on https://github.com/fuzionnz/civicrm-drupal7/commits/master -  probably already in core. So, perhaps I need to try the submodules approach again for 4.4.

I haven't used git-submodules much -- only a little bit when using "puppet" (because that's common in the puppet community). Their directory structure is a little different from the (typical/traditional) CiviCRM directory structure -- and I think their structure would be a bit easier for managing long-term forks (due to cleaner "separation of concerns").

Quick comparison. If you wanted a git submodule setup for a "full build", you might try "Example A" in https://docs.google.com/spreadsheet/ccc?key=0AujctkQuBowkdG1QbEpSZFU3N0p4NGRaYTh6VE91TFE&usp=sharing .

In this setup, https://github.com/myuser/civicrm-core.git#4.3 (aka origin/4.3) serves multiple purposes -- it holds the core code; it holds all your patches to core code; AND it holds metadata about each submodule's revision. Note that your long-running fork branch (e.g. origin/4.3) includes submodules for drupal & packages, but the official branch (e.g. upstream/4.3) does not. Now suppose you want to begin work on a new patch (ie make a new branch for future PR). One must choose a base-branch of either origin/4.3 or upstream/4.3), but that's an impossible choice: if you use origin/4.3, then your working copy will include the submodules (making a full/usable source-tree) but will also include all your unrelated/proprietary patches (which prevents you from sending a clean PR). If you use "upstream/4.3", then it can merge cleanly anywhere, but you can't run it locally because it's missing the submodules.

If we emulated the typical usage of "git submodules" from the puppet community (see "Example B" in https://docs.google.com/spreadsheet/ccc?key=0AujctkQuBowkdG1QbEpSZFU3N0p4NGRaYTh6VE91TFE&usp=sharing ), you wouldn't face this impossible choice because the build data is separate from the code patches. I did a little experimenting on my local machine, and I don't think it would be too hard to make "Example B" work. (It requires changes to civicrm.settings.php, civicrm.config.php, and any code that references "packages". If you need the web-based installer, then that might also require patches.)

So what would the day-to-day steps look like?

  • A. Pick a feature or bug to work on
  • A.1. Create branch "origin/my-fix" based on "upstream/4.3"
  • A.2. Write code and commit to "origin/my-fix"
  • A.3. Merge "origin/my-fix" into any long-running branches -- switch the order/timing as desired:
  • A.3.a. Merge "origin/my-fix" into "upstream/4.3" by submitting a pull-request
  • A.3.b. (Special) Merge "origin/my-fix" into "origin/4.3" via CLI, pull-request, or whatever your group wants.
    B. (Special) Periodically, to make sure that your long-running fork stays aligned with the official code, merge "upstream/4.3" into "origin/4.3".

My strong suspicion is that most of the steps are the same regardless of whether you work with civicrm-core.git, civicrm-drupal.git, civicrm-packages.git, or a hypothetical civicrm-everything.git -- and regardless of whether you have a long-running fork. The major variations are A.3.b and B:

  • If (like most folks) you don't have a long-running fork, then skip A.3.b + B.
  • If you have a long-running fork, then do the git merge for A.3.b + B.
  • If you have a long-running fork based on git-submodules, then you also need to update the parent project so that the submodule ref points to the latest HEAD of origin/4.3.
  • If you have a long-running fork based on drush-make or composer, then updating the build document (make-file/composer.json/composer.lock) is optional. It depends on whether you choose to include branch-names or commit-names in the build document.
TLDR

  • The basic mechanics of making a patch/PR should be the same for everyone.
  • Branches should be based on the lowest-common-denominator (e.g. upstream/4.3). If you base patches on something else, then you cannot use git merge or PRs!. The only option is cherry-picking in multiple places.
  • git-submodules requires a little overhead compared to drush-make/composer
  • Some patches (relatively small/managaeble) may be required to core to work more flexibly with different build practices.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Managing deployments (now we have git)
September 22, 2013, 02:25:38 pm
Quote
If we emulated the typical usage of "git submodules" from the puppet community (see "Example B" in https://docs.google.com/spreadsheet/ccc?key=0AujctkQuBowkdG1QbEpSZFU3N0p4NGRaYTh6VE91TFE&usp=sharing ), you wouldn't face this impossible choice because

ie. - to put this really simply - if the CMS & packages folders were not inside the civicrm folder then the problem would go away?

And by extension tools & tests out of the main repo as well.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Managing deployments (now we have git)
September 22, 2013, 10:51:00 pm
Quote from: Eileen on September 22, 2013, 02:25:38 pm
ie. - to put this really simply - if the CMS & packages folders were not inside the civicrm folder then the problem would go away?

Yes (give-or-take bug-fixes).

Quote from: Eileen on September 22, 2013, 02:25:38 pm
And by extension tools & tests out of the main repo as well.

Yes, I can see how it appears that way with your stated goal, and (from a "build-process" perspective) that's true. I could go along with moving "tools" to its own repo but disagree with moving "tests" (or "xml" -- which is also omitted from tarballs used for deployment). A few key points:

  • "tests" and "xml" are tightly coupled to the core code-base, and working on those is integral to the development process. It should be normal, accepted, and expected that a patch touches both the "CRM" or "api" code as well as the "tests" or "xml" code. Splitting those out into separate repos would incur the overhead of coordinating separate patches to separate repos on a day-to-day basis. (By contrast, the CMS and packages directories are things that need coordinated patches for maybe one developer each week, so the overhead is much lower; and the "packages" aspect will resolve itself when we replace "packages" with a sane build-document.)
  • On a production deployment, it's pretty easy to remove (or restrict access to) unwanted files with a config-file or script. It might take 3 lines or 30 lines (depending on the exact requirements/goals/process), but either way it's pretty small.
  • Looking at other systems like Drupal contrib and Symfony, it's common for unit-tests and schema documents (like "tests"/"xml") to live in the same repo as the corresponding code -- and even get deployed! Why are these problematic for CiviCRM -- and no one else?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Managing deployments (now we have git)
September 22, 2013, 10:54:28 pm
I don't have a problem having extra stuff in our deployment if I'm not out on a limb with it. The reason being I'm concerned that one pair of eyes isn't enough to pick up something that might be insecure.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

nicolas

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 6
    • cividesk
  • CiviCRM version: 4.4 LTS
  • CMS version: Standalone (yep)
  • MySQL version: 5.1
  • PHP version: 5.3
Re: Managing deployments (now we have git)
September 25, 2013, 09:41:32 am
I agree with Eileen from a security perspective we should not put 'tests', 'packaging' or any other utility scripts/code in a live, Internet-facing site. However I also see Tim's point about convenience for the developer, and we want to make it very easy to write units tests!

The logical way to solve this is to have a higher-level directory that contains a civicrm (executable code), tests, doc and other such folders. This is common and a lot of components are packaged like this today. You can then point your web root at the civicrm directory and then have both Tim and Eileen happy.

In our case, 'pointing the web root' might mean creating a symlink from the CMS module/plugin/extension folder, or extracting the tarball and copying only the civicrm directory to the CMS directory tree.

So the install instructions for civicrm might be a little more complicated than they are today, but by pushing this theory a little further I think we might even be able to release just one tarball for civicrm, with all the CMS bits included, and then have a couple of 'cp' or 'ln -s' for the install process. This could simplify the GIT repos, development and release processes significantly.
cividesk -- CiviCRM delivered ... your way!

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Managing deployments (now we have git)
September 25, 2013, 01:05:51 pm
So the structure would then be

--modules
 -- civicrm
 -- cms folder
 -- packages folder
 -- civicrm-core folder
   -- CRM
   -- api
   
etc

But
--civicrm-core folder would not actually be root of the civicrm-core repo but a symlink to a folder within it?
 

NB - as far as the security side is concerned - I don't think there is anything inherently insecure about deployment files on the production site. I think there is something inherently secure about having files on a production site - I think there is something inherently secure about having deployment files that developers don't expect to be on production sites is insecure. ie. I know you will look at PRs touching those files differently if you know the files will be on people's live sites & having many multiple have those files on their live sites will give us the critical mass to pick up security problems
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Managing deployments (now we have git)
September 26, 2013, 01:06:26 am
In the node.js world, you can define a prod and test environment that can fetch different extra packages.

Isn't it the same with composer?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Managing deployments (now we have git)
October 08, 2013, 07:22:15 am
No that is not the same with composer. Why on earth would you have a different test environment? That is the question. Your test environment and dev environment should match your live. Only when you are test upgrading packages they are not in sync.

With composer you store the composer config file and your composer state file (composer.json and composer.lock) in git. That way you can create different branches in git for different purposes.
Developer at Edeveloper / CiviCoop

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Managing deployments (now we have git)
October 08, 2013, 08:10:38 am
A) @xavier and @jaapjansama -- I *think* the analog to Xavier's node.js "environment" would be to differentiate "require" and "require-dev" -- e.g. http://getcomposer.org/doc/04-schema.md#require-dev . A typical example would be the "phpunit" or "Selenium" executable -- you need to install it on a development machine but not on a production machine. When calling composer, you can pass "--dev" or "--no-dev" to indicate whether you want to install dev tools. (The phrase "prod and test environment" might be confusing because refers to something else in Symfony's jargon -- e.g. it refers to having multiple databases running off the same codebase.)

B) There's been a confluence of issues which led me to create a github repo called "civicrm-drupal-project." This is a very small repo that you can clone/fork which defines how to build a CiviCRM environment. The architecture is inspired by "Symfony Standard Edition" (which provides a thin top-level project for downstream developers to clone/fork). The issues motivating this are:

 - The discussion here about managing deployments.
 - A discussion with erawat about how difficult it is to setup testing.
 - A discussion with other folks about setting up their git forks.
 - A pull request from Peter H with a new way to run tests. (His approach downloads+configures Drupal, spawns mysqld on a ramdisk, creates config files, etc.)
 - A discussion with some Windows users about how hard it is to setup civix in their environment.

The "civicrm-drupal-project" basically downloads all things we recommend for Civi development. The difficulty of installation should be roughly on par with installation of civix, but it gets a lot more done (so that the overall process is easier/less frustrating). It's still early/WIP:

 - Notes: https://pad.riseup.net/p/u6aiEzRqP4YN
 - Web page: https://github.com/civicrm/civicrm-drupal-project

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Managing deployments (now we have git)
October 08, 2013, 08:14:54 am
@totten your project seems very nice but it depends on having a Bash shell to get it up and running. No problem for me as I work on windows and can create a Linux VM but for most users on windows/mac it could be a problem.
Or does mac run bash scripts out of the box?
Developer at Edeveloper / CiviCoop

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Managing deployments (now we have git)
October 08, 2013, 08:37:14 am
Macs run bash. :)

I don't really use Windows enough to say what would work well for new developers there (and I'm skeptical of whether anything can work well there). Windows devs would still need to setup bash+git+drush+drushmake+AMP (e.g. maybe with Vagrant/VMs, Cygwin, or Acquia Dev Desktop?). But hopefully this would be a net-improvement (e.g. reducing a 20 step process to a 10 step process).

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Managing deployments (now we have git)
November 10, 2013, 11:42:53 pm
I've opened this ticket to track moving the drupal folder out of the main core folder http://issues.civicrm.org/jira/browse/CRM-13737

This is very helpful when maintaining a downstream deployment fork.

We discussed various options last week & concluded that we will get something like this going before we create our 4.4 deployment repo. We did discuss make scripts & various other options but nothing seemed a really good flow. However, as the problem was mainly around pushing stuff back upstream I'm just slowly down on that & evaluating what I can cut back on.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Managing deployments (now we have git)

This forum was archived on 2017-11-26.