Recipe "How to turn an idea into a certified SMW extension"
|
Content
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
<mermaid2> 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;"] </mermaid2>
Set up VBox VM "MediaWiki Vagrant" on your Ubuntu workstation
Install Git
user@workstation:~$ sudo apt-get install git
Install Virtualbox
https://www.virtualbox.org/wiki/Downloads
Install Vagrant
- IMPORTANT: Vagrant's version must match https://github.com/LinuxCompetenceCenter/mediawiki-vagrant/blob/master/Gemfile.lock.
- Here's the list of Vagrant release downloads.
The following commands install Vagrant 1.8.1 on Ubuntu (note that these commands are conditionally included in deploy_mediawiki-vagrant.sh
below):
user@workstation:~/tmp$ wget https://releases.hashicorp.com/vagrant/1.8.1/vagrant_1.8.1_x86_64.deb user@workstation:~/tmp$ sudo dpkg -i vagrant_1.8.1_x86_64.deb
Use Case "Install VBox VM "MediaWiki Vagrant""
user@workstation:~$ ./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
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:
user@workstation:~/mediawiki-vagrant$ vagrant destroy
user@workstation:~$ mv .vagrant.d .vagrant.d_BACKUP
user@workstation:~/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:
user@workstation:~/mediawiki-vagrant/mediawiki$ git pull origin master
user@workstation:~/mediawiki-vagrant$ vagrant provision
How to access VBox VM "MediaWiki Vagrant"
Log into the VM (SSH or "shell access")
user@workstation:~/mediawiki-vagrant$ vagrant ssh
Browse devwiki from your workstation (host)
http://localhost:8080/wiki/Main_Page
Log into the VM's XFCE desktop
- Upon a fresh set up only, run
user@workstation:~/mediawiki-vagrant$ vagrant halt && vagrant up
. - Doubleclick the running machine in the Oracle VM VirtualBox Manager.
- Log in with username
vagrant
and passwordvagrant
. - For the time being DO NOT UPGRADE FIREFOX! due to https://github.com/SeleniumHQ/selenium/issues/2257.
The desktop environment used is Xfce.
STEP 2: Add your extension, e.g. SMWCindyKate
These instructions are under construction.
user@workstation: ~/SMWCindyKate/ tests/ phpunit/ SomeTest.php # How do these files have to look like? SomeMoreTest.php
STEP 3: Run tests
- These instructions are based on Setup_instructions#Environment_variables.
- See all predesigned test runs.
vagrant@mediawiki-vagrant:~$ export MEDIAWIKI_URL=http://127.0.0.1:8080/wiki/
Run unit tests
- These instructions are based on MediaWiki-Vagrant#Running_and_debugging_unit_tests.
- See MediaWiki core unit tests
- See PHPUnit command line options
user@workstation:~/mediawiki-vagrant$ vagrant ssh
Run MediaWiki core unit tests
vagrant@mediawiki-vagrant:~$ ./run-all-mw-core-unit-tests.sh
Run Semantic MediaWiki core unit tests
vagrant@mediawiki-vagrant:~$ ./run-all-SMW-core-unit-tests.sh
Run your extension unit tests, e.g. SMWCindyKate
These instructions are under construction.
Run browser tests
- Also known as acceptance, integration or Cucumber tests.
- These instructions are based on Quality_Assurance/Browser_testing.
- See MediaWiki core browser tests
- UseCase "Ensure that the correct combination of versions of Firefox and of selenium-webdriver is installed" Use Case
user@workstation:~/mediawiki-vagrant$ vagrant ssh
Run MediaWiki core browser tests
vagrant@mediawiki-vagrant:~$ ./run-all-core-acceptance-tests.sh
Run extension browser tests, e.g. SMWCindyKate
These instructions are under construction.