Recipe "How to turn an idea into a certified SMW extension"

From SMW CindyKate - Main
Component 947747
Jump to: navigation, search

Content


Notice:

The following instructions have been tested on Ubuntu 16.04 64bit.

Instructions for other platforms are under construction.

Goal

The goal is to minimize the effort of turning your great new idea for SMW functionality into a certified extension.

STEP 1: Set up local test environment

For your understanding: local test environment ontology

graph TD rmwsd("Repository #quot;MediaWiki Core Cucumber Step Definitions#quot;<hr> <a href='https://github.com/LinuxCompetenceCenter/MediaWiki-Core-Cucumber-Step-Definitions'>GitHub repository</a> ") --> |"is a submodule to"|mwvf ynb --> |hosts directory|mwvf>"Directory #quot;~/mediawiki-vagrant/#quot;<hr> git clone https://github.com/LinuxCompetenceCenter/mediawiki-vagrant.git<br> <a href='https://github.com/LinuxCompetenceCenter/mediawiki-vagrant/blob/master/Vagrantfile'>Vagrantfile</a><br> <a href='https://github.com/LinuxCompetenceCenter/mediawiki-vagrant/blob/master/mw-profiles.yml'>mw-profiles.yml</a> "] mwvf -->|"is shared into /vagrant<br>launches VM by #quot;vagrant up#quot;<br>ssh's into VM by #quot;vagrant ssh#quot;"|mwvvm aom("Host #quot;Any Other Host#quot;;<hr> serves MediaWiki at port X") ynb("Physical Machine #quot;Your Workstation#quot;<hr>has IP 192.168.37.12") --> |"hosts VBox VM<br> browses it at localhost:8080<br> serves it at 192.168.37.12:8080"|mwvvm["VBox VM #quot;MediaWiki Vagrant#quot;"]

Set up VBox VM "MediaWiki Vagrant" on your Ubuntu workstation

Install Git

[email protected]:~$ sudo apt-get install git

Install Virtualbox

https://www.virtualbox.org/wiki/Downloads

Install Vagrant

The following commands install Vagrant 1.8.1 on Ubuntu (note that these commands are conditionally included in deploy_mediawiki-vagrant.sh below):

[email protected]:~/tmp$ wget https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb
[email protected]:~/tmp$ sudo dpkg -i vagrant_1.8.1_x86_64.deb

Use Case "Install VBox VM "MediaWiki Vagrant""

[email protected]:~$ ./deploy_mediawiki-vagrant.sh
#!/bin/bash

# This the content of deploy_mediawiki-vagrant.sh

# Ensure that Vagrant's apt version is installed
if [[ "$(vagrant --version)" == "Vagrant 1.8.1"* ]]; then
    echo "Vagrant 1.8.1 is installed"
  else
    wget https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb
    sudo dpkg -i vagrant_1.8.1_x86_64.deb
fi

# Create the core mediawiki-vagrant VM
git clone https://github.com/LinuxCompetenceCenter/mediawiki-vagrant.git
cd mediawiki-vagrant
git submodule update --init --recursive
./setup.sh
vagrant hiera mediawiki::branch REL1_26
vagrant config nfs_shares off # Note: This is only necessary if you have an encrypted home directory. See https://help.ubuntu.com/community/EncryptedHome
time vagrant up

# Add functionality by enabling roles
vagrant roles enable semanticmediawiki
vagrant roles enable semantictitle
vagrant provision --provision-with puppet
Notice:

At the end of this process your VBox VM "MediaWiki Vagrant" is ready for the next steps. If you want to log into the VM's XFCE desktop, see below Log into the VM's XFCE desktop.

Troubleshooting

The following observations and seemingly working solutions are based on my own experiences.

  • If you get a Failed to execute command `vagrant plugin list` (pid 30351 exit 1), then try this:
    1. [email protected]:~/mediawiki-vagrant$ vagrant destroy
    2. [email protected]:~$ mv .vagrant.d .vagrant.d_BACKUP
    3. [email protected]:~/mediawiki-vagrant$ time vagrant up
  • If you get a port forwarding collision, then either:
    • reconfigure port forwarding in the Vagrantfile to some unused host port, or
    • close any other VM using forwarding to host port 8080, or
    • remove VBox VM "MediaWiki Vagrant" and close and then reopen Virtualbox.
  • If vagrant up
    • fails saying The SSH command responded with a non-zero exit status. or
    • hangs at /Stage[main]/Mediawiki/Git::Clone[mediawiki/core]/File[/vagrant/mediawiki]/ensure: created, then try this:
    1. [email protected]:~/mediawiki-vagrant/mediawiki$ git pull origin master
    2. [email protected]:~/mediawiki-vagrant$ vagrant provision

How to access VBox VM "MediaWiki Vagrant"

Log into the VM (SSH or "shell access")

[email protected]:~/mediawiki-vagrant$ vagrant ssh

Mediawiki vagrant vagrant ssh.png

Browse devwiki from your workstation (host)

http://localhost:8080/wiki/Main_Page

Mediawiki vagrant main page.png

Log into the VM's XFCE desktop

  1. Upon a fresh set up only, run [email protected]:~/mediawiki-vagrant$ vagrant halt && vagrant up.
  2. Doubleclick the running machine in the Oracle VM VirtualBox Manager.
  3. Log in with username vagrant and password vagrant.
  4. For the time being DO NOT UPGRADE FIREFOX! due to https://github.com/SeleniumHQ/selenium/issues/2257.

The desktop environment used is Xfce.

Mediawiki vagrant xfce desktop.png

STEP 2: Add your extension, e.g. SMWCindyKate

Notice:

These instructions are under construction.

[email protected]:
  ~/SMWCindyKate/
    tests/
      phpunit/
        SomeTest.php     # How do these files have to look like?
        SomeMoreTest.php

STEP 3: Run tests

vagra[email protected]:~$ export MEDIAWIKI_URL=http://127.0.0.1:8080/wiki/

Run unit tests

[email protected]:~/mediawiki-vagrant$ vagrant ssh

Run MediaWiki core unit tests

[email protected]:~$ ./run-all-mw-core-unit-tests.sh

Run Semantic MediaWiki core unit tests

[email protected]:~$ ./run-all-SMW-core-unit-tests.sh

Run your extension unit tests, e.g. SMWCindyKate

Notice:

These instructions are under construction.

Run browser tests

[email protected]:~/mediawiki-vagrant$ vagrant ssh

Run MediaWiki core browser tests

[email protected]:~$ ./run-all-core-acceptance-tests.sh

Run extension browser tests, e.g. SMWCindyKate

Notice:

These instructions are under construction.