Skip to content

Commit

Permalink
Split from updates server.
Browse files Browse the repository at this point in the history
  • Loading branch information
ergonlogic committed Mar 13, 2016
0 parents commit 3fe3cff
Show file tree
Hide file tree
Showing 17 changed files with 351 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.vagrant/*
ansible/roles/*
*.swp
vendor/*
bin/*
selenium-server.jar
composer.phar
behat_params.sh
.local
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
language: php

dist: trusty

sudo: false

install:
- .mk/bootstrap.sh

before_script:
- . ~/.bashrc
# Debugging
- curl http://localhost:8888/

script:
- make test-on-travis
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
MK_DIR ?= .
SHELL := /bin/bash
project_root ?= /vagrant
BIN_DIR = $(MK_DIR)/.local/bin
SRC_DIR = $(MK_DIR)/.local/src

up:
@vagrant up
rebuild:
@vagrant destroy -f && vagrant up
make:
@vagrant ssh -c"cd /var/www/html/d8 && sudo drush -y make /vagrant/dev.build.yml"

include $(MK_DIR)/mk/*.mk

20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MAKE SERVER [![Build status](https://travis-ci.org/ergonlogic/make-server.svg)](https://travis-ci.org/ergonlogic/make-server)
===========

Drush Make is certainly quite useful for building Drupal code-bases. A little-known capability is to load project version data from a source other than the official http://updates.drupal.org. This install profile is intended to make it easy to run your own updates service.

Development
-----------

We use a simple Vagrant-based VM that installs Drush and a Drupal site. It
symlinks this project as an install profile, so that simply editing the code in
this directory is sufficient to see the changes.

$ git clone https://github.com/ergonlogic/make-server.git
$ cd make-server
$ vagrant up

If you want to install Drush from sources, instead of the .phar:

$ DRUSH_DEV=true vagrant up

24 changes: 24 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.define 'make-server' do |d|
d.vm.box = "ubuntu/trusty64"
d.vm.provider "virtualbox" do |v|
v.memory = 1024
v.cpus = 2
end

d.vm.hostname = 'make.local'
d.vm.network 'private_network', ip: '10.57.57.57'
config.vm.network "forwarded_port", guest: 8888, host: 8888

if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end

d.vm.provision "shell",
path: ".mk/bootstrap.sh",
privileged: false,
keep_color: true
end
end
9 changes: 9 additions & 0 deletions behat.composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"require": {
"drupal/drupal-extension": "~3.0",
"guzzlehttp/guzzle" : "~6.0"
},
"config": {
"bin-dir": "bin/"
}
}
19 changes: 19 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
Behat\MinkExtension:
goutte: ~
selenium2: ~
Drupal\DrupalExtension:
blackbox: ~
gherkin:
filters:
tags: ~@wip

44 changes: 44 additions & 0 deletions mk/behat.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
behat = $(bin_dir)/behat
behat_src = $(src_dir)/behat
bde_dir = $(drush_dir)/drush-bde-env
bde_exists = $(shell if [[ -d $(bde_dir) ]]; then echo 1; fi)

_help-behat:
@echo "make behat"
@echo " Install Behat."

drush-bde-env: drush
ifneq '$(bde_exists)' '1'
@echo Cloning Drush Behat config extension
@git clone https://github.com/pfrenssen/drush-bde-env.git $(bde_dir)
@$(drush) cc drush
endif

behat-config: behat drush-bde-env $(root)
@echo Generating project-specific Behat config
@cd $(root) && $(drush) beg --subcontexts=profiles/$(profile)/modules --site-root=$(root) --skip-path-check --base-url=$(uri) $(project_root)/behat_params.sh

deps-behat: aptitude-update composer
@echo Installing Behat dependencies
@sudo DEBIAN_FRONTEND=noninteractive apt-get -y -qq install php5-curl

clean-behat:
@rm -rf $(behat_src)
@rm -f $(behat)

$(behat_src)/composer.json: $(mk_dir)/behat.composer.json
@mkdir -p $(behat_src)
@cp $(mk_dir)/behat.composer.json $(behat_src)/composer.json

$(behat_src)/composer.lock: $(behat_src)/composer.json
@cd $(behat_src) && \
rm -f composer.lock && \
$(composer) install

$(behat_src)/bin/behat: $(behat_src)/composer.lock

$(behat): $(behat_src)/bin/behat
@cd $(bin_dir) && \
ln -sf ../src/behat/bin/behat behat

behat: $(behat)
19 changes: 19 additions & 0 deletions mk/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Set different project roots depending on Vagrant or TravisCI environments.
if [ -z ${TRAVIS_BUILD_DIR+x} ]; then
cd /vagrant
make deps
else
export project_root=$TRAVIS_BUILD_DIR
fi

make init
source ~/.bashrc

make drush

make drupal

make behat

13 changes: 13 additions & 0 deletions mk/composer.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
composer = $(bin_dir)/composer
version = 1.0.0-beta1

_help-composer:
@echo "make composer"
@echo " Install composer."
@echo "make composer version=<version>"
@echo " Install the specified version of Composer. Defaults to $(version)"

composer: init
@curl -sSL -z $(composer) -o $(composer) https://getcomposer.org/download/$(version)/composer.phar
@chmod a+x $(composer)
@$(composer) --version
18 changes: 18 additions & 0 deletions mk/deps.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
deps_hooks = $(shell grep "^deps-[^:]*" $(mk_dir)/mk -rho)

deps: aptitude-update mysql-server $(deps_hooks)

list-deps:
@echo The following dependency hooks are defined:
@echo $(deps_hooks)

mysql-server: vagrant aptitude-update
@echo Installing MySQL server
@echo 'mysql-server mysql-server/root_password password' | sudo debconf-set-selections
@echo 'mysql-server mysql-server/root_password_again password' | sudo debconf-set-selections
@sudo DEBIAN_FRONTEND=noninteractive apt-get -y -qq install mysql-server

aptitude-update: vagrant
@echo Updating apt
@sudo DEBIAN_FRONTEND=noninteractive apt-get update -qq

36 changes: 36 additions & 0 deletions mk/drupal.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
makefile = dev.build.yml
root = ~/drupal
root_exists = $(shell if [[ -d $(root) ]]; then echo 1; fi)
site_exists = $(shell if [[ -f $(root)/sites/default/settings.php ]]; then echo 1; fi)
profile = make_server
port = 8888
uri = http://localhost:$(port)

help-drupal:
@echo "make drupal"
@echo " Build a Drupal codebase, install a site and start a web server."
@echo "make kill-server"
@echo " Stop the server running started during site install."

rebuild-platform: $(root)
$(root): $(project_root)/$(makefile)

build-platform: vm
ifneq '$(root_exists)' '1'
@$(drush) -y make $(project_root)/$(makefile) $(root)
@ln -s $(project_root) $(root)/profiles/$(profile)
endif

drupal: kill-server build-platform
ifneq '$(site_exists)' '1'
@cd $(root) && $(drush) -y site-install $(profile) --db-url=mysql://root@localhost/site0 --account-pass=pwd
endif
@echo "<?php" > ~/.drush/local.alias.drushrc.php
@echo " \$$aliases['local'] = array('root' => '$(root)','uri' => '$(uri)');" >> ~/.drush/local.alias.drushrc.php
@echo "Starting PHP server."
@cd $(root) && php -S 0.0.0.0:$(port) &> ~/runserver.log &

kill-server:
@echo "Stopping PHP server."
@ps aux|grep [p]hp > /dev/null || pkill -f php
@sleep 3
32 changes: 32 additions & 0 deletions mk/drush.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
DRUSH_DIR ?= $(mk_dir)/.local/drush
DRUSH_SRC ?= $(src_dir)/drush
DRUSH_BIN ?= $(bin_dir)/drush
DRUSH_RELEASE ?= 8.0.5
DRUSH_PHAR ?= $(DRUSH_SRC)/drush-$(DRUSH_RELEASE).phar
drush ?= $(DRUSH_BIN) --include=$(DRUSH_DIR)

_help-drush:
@echo "make drush"
@echo " Install Drush."

clean-drush:
@rm -f $(DRUSH_BIN)
@rm -f $(DRUSH_SRC)

deps-drush: aptitude-update mysql-server
@echo Installing Drush dependencies
@sudo DEBIAN_FRONTEND=noninteractive apt-get -y -qq install git php5-mysql php5-cli php5-gd

$(DRUSH_PHAR): init
@echo Downloading the $(DRUSH_RELEASE) release of Drush.
mkdir -p $(DRUSH_SRC)
curl -Ss "https://github.com/drush-ops/drush/releases/download/$(DRUSH_RELEASE)/drush.phar" -z $(DRUSH_PHAR) -o $(DRUSH_PHAR)

$(DRUSH_BIN): $(DRUSH_SRC)/drush-$(DRUSH_RELEASE).phar
@echo Installing the $(DRUSH_RELEASE) release of Drush.
@cd $(bin_dir) && \
ln -sf ../src/drush-$(DRUSH_RELEASE).phar drush
@chmod a+x $(DRUSH_BIN)
@$(drush) --version

drush: $(DRUSH_BIN)
12 changes: 12 additions & 0 deletions mk/help.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
help_hooks = $(shell grep "^help-[^:]*" $(mk_dir)/mk -rho)
help_hooks_hidden = $(shell grep "^_help-[^:]*" $(mk_dir)/mk -rho)

help: $(help_hooks)
all-help: $(help_hooks) $(help_hooks_hidden)

list-help:
@echo "The following help hooks are defined:"
@echo $(help_hooks)
@echo "The following hidden help hooks are defined (displayed with 'all-help'):"
@echo $(help_hooks_hidden)

15 changes: 15 additions & 0 deletions mk/selenium.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
selenium = $(bin_dir)/selenium-server.jar
selenium_version = 2.52
selenium_release = $(selenium-version).0

_help-selenium:
@echo "make selenium"
@echo " Install Selenium."

deps-selenium: vagrant aptitude-update
@echo Installing Selenium dependencies
@sudo DEBIAN_FRONTEND=noninteractive apt-get -y -qq install openjdk-7-jre-headless

selenium: vm
@curl -sSL -z $(selenium) -o $(selenium) http://selenium-release.storage.googleapis.com/$(selenium-version)/selenium-server-standalone-$(selenium-release).jar

9 changes: 9 additions & 0 deletions mk/test.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
help-test:
@echo "make test"
@echo " Run tests."

test: behat-config
@source behat_params.sh && bin/behat
wip: behat-config
@source behat_params.sh && bin/behat --tags=wip

40 changes: 40 additions & 0 deletions mk/utils.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
user = $(shell whoami)
utils = screen htop strace tree
bashrc = export PATH="$(BIN_DIR):$$PATH"

init: $(BIN_DIR) $(SRC_DIR)
@grep -q -F '$(bashrc)' ~/.bashrc || echo '$(bashrc)' >> ~/.bashrc

$(BIN_DIR):
@mkdir -p $(BIN_DIR)

$(SRC_DIR):
@mkdir -p $(SRC_DIR)

fix-time:
@sudo ntpdate -s time.nist.gov

deps-utils: vagrant
@echo Installing some utilities
@sudo DEBIAN_FRONTEND=noninteractive apt-get -y -qq install $(utils)

clean:
@rm -rf $(BIN_DIR)
@rm -rf $(SRC_DIR)

vm:
ifneq ($(user), vagrant)
ifneq ($(user), travis)
@echo Current user is \'$(user)\'.
@echo This command \(make $@\) must be built in a \'vagrant\' or \'travis\' vm.
@exit 1
endif
endif

vagrant:
ifneq ($(user), vagrant)
@echo Current user is \'$(user)\'.
@echo This command \(make $@\) must be built in a \'vagrant\' vm.
@exit 1
endif

0 comments on commit 3fe3cff

Please sign in to comment.