Skip to content

Commit

Permalink
make plugin compatibile with matomo 4
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Sep 1, 2020
1 parent aeb6c9d commit 677df05
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 29 deletions.
127 changes: 103 additions & 24 deletions .travis.yml
@@ -1,41 +1,120 @@
# do not edit this file manually, instead run the generate:travis-yml console command

language: php

php:
- 5.3
- 7.2
- 7.4
# - hhvm

services:
- redis-server
- mysql

addons:
apt:
packages:
- nginx
- coreutils
- lftp

git:
lfs_skip_smudge: true

# Separate different test suites
env:
global:
- PLUGIN_NAME=LiveTab
- PIWIK_ROOT_DIR=$TRAVIS_BUILD_DIR/matomo
# this variable controls the version of Matomo your tests will run against.
# by default it will run against the maximum support version read from plugin.json
# (PIWIK_TEST_TARGET=maximum_supported_piwik).
# You can also specify a specific Matomo version
# (PIWIK_TEST_TARGET=2.16.0-b1).
- PIWIK_TEST_TARGET=4.x-dev
matrix:
- TEST_SUITE=CoreTests MYSQL_ADAPTER=PDO_MYSQL
- TEST_SUITE=PluginTests MYSQL_ADAPTER=PDO_MYSQL
- TEST_SUITE=UITests MYSQL_ADAPTER=PDO_MYSQL TEST_AGAINST_PIWIK_BRANCH=$PIWIK_TEST_TARGET

matrix:
exclude:
# execute UI tests only w/ PHP 5.6
- php: 7.4
env: TEST_SUITE=UITests MYSQL_ADAPTER=PDO_MYSQL TEST_AGAINST_PIWIK_BRANCH=$PIWIK_TEST_TARGET

dist: bionic

script: ./travis.sh
sudo: false

script: $PIWIK_ROOT_DIR/tests/travis/travis.sh

before_install:

install:
- TEST_PIWIK_VERSION=$(wget builds.piwik.org/LATEST_BETA -q -O -)
- echo $TEST_PIWIK_VERSION
- TEST_PIWIK_VERSION=`echo $TEST_PIWIK_VERSION | tr -d ' ' | tr -d '\n'`
- mkdir LiveTab
- cp -R !(LiveTab) LiveTab
- git clone https://github.com/piwik/piwik.git piwik
- cd piwik
- git checkout "$TEST_PIWIK_VERSION"
- git submodule init
# move all contents of current repo (which contains the plugin) to a new directory
- mkdir $PLUGIN_NAME
- cp -R !($PLUGIN_NAME) $PLUGIN_NAME
- cp -R .git/ $PLUGIN_NAME/
- cp .travis.yml $PLUGIN_NAME
# checkout matomo in the current directory
- git clone -q https://github.com/matomo-org/matomo.git matomo
- cd matomo
- git fetch -q --all
- git submodule update
- composer install
- rm -rf plugins/LiveTab
- cd ../
- mv LiveTab piwik/plugins

# make sure travis-scripts repo is latest for initial travis setup
- '[ -d ./tests/travis/.git ] || sh -c "rm -rf ./tests/travis && git clone https://github.com/matomo-org/travis-scripts.git ./tests/travis"'
- cd ./tests/travis ; git checkout master ; cd ../..

- export GENERATE_TRAVIS_YML_COMMAND="php ./tests/travis/generator/main.php generate:travis-yml --plugin=\"LiveTab\" --php-versions=\"7.2,7.4\" --distribution=\"bionic\" --sudo-false --verbose"
- '[[ "$TRAVIS_JOB_NUMBER" != *.1 || "$TRAVIS_PULL_REQUEST" != "false" ]] || ./tests/travis/autoupdate_travis_yml.sh'

- ./tests/travis/checkout_test_against_branch.sh

- '[ "$PLUGIN_NAME" == "" ] || [ ! -f ./tests/travis/check_plugin_compatible_with_piwik.php ] || php ./tests/travis/check_plugin_compatible_with_piwik.php "$PLUGIN_NAME"'

- ./tests/travis/configure_git.sh

# travis now complains about this failing 9 times out of 10, so removing it
#- travis_retry composer self-update
- '[ "$SKIP_COMPOSER_INSTALL" == "1" ] || travis_retry composer install'

# move plugin contents to folder in the plugins subdirectory
- rm -rf plugins/$PLUGIN_NAME
- mv ../$PLUGIN_NAME plugins

# clone dependent repos
- ./tests/travis/checkout_dependent_plugins.sh

before_script:
- cd piwik
- uname -a
- date
- mysql -e 'create database piwik_tests;'
- phpenv config-rm xdebug.ini

# add always_populate_raw_post_data=-1 to php.ini
- echo "always_populate_raw_post_data=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

# disable opcache to avoid random failures on travis
- echo "opcache.enable=0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini

# make tmpfs and run MySQL on it for reasonnable performance
- ./tests/travis/setup_mysql_tmpfs.sh

- ./tests/travis/prepare.sh
- ./tests/travis/setup_webserver.sh
- wget https://raw.github.com/piwik/piwik-tests-plugins/master/activateplugin.php
- php activateplugin.php LiveTab
- ./tests/travis/install_phantomjs.sh; export PATH=$PWD/travis_phantomjs/phantomjs-2.1.1-linux-x86_64/bin:$PATH;

- cd tests/PHPUnit

after_script:
- cat /var/log/nginx/error.log
# change directory back to root travis dir
- cd $PIWIK_ROOT_DIR

# output contents of files w/ debugging info to screen
- cat $PIWIK_ROOT_DIR/tests/travis/error.log
- cat $PIWIK_ROOT_DIR/tmp/php-fpm.log
- cat $PIWIK_ROOT_DIR/tmp/logs/matomo.log
- cat $PIWIK_ROOT_DIR/config/config.ini.php

# upload test artifacts (for debugging travis failures)
- ./tests/travis/upload_artifacts.sh

after_success:
- cd $PIWIK_ROOT_DIR
2 changes: 1 addition & 1 deletion API.php
Expand Up @@ -22,7 +22,7 @@ public function getSettings()
{
Piwik::checkUserHasSomeViewAccess();

$settings = new UserSettings('LiveTab');
$settings = new UserSettings();

return array(
'metric' => $settings->metric->getValue(),
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,8 @@
## Changelog

__4.0.0__
* Compatible with Piwik 4.0

__3.0.1__
* Rename Piwik to Matomo

Expand Down
4 changes: 2 additions & 2 deletions javascripts/api.js
Expand Up @@ -19,12 +19,12 @@ var LiveTabApi = LiveTabApi || (function () {
ajaxRequest.setErrorCallback(function () {});
ajaxRequest.setCallback(
function (response) {
if (!response || !$.isArray(response) || !response[0]) {
if (!response || typeof response != 'object') {

return;
}

onSuccess(response[0]);
onSuccess(response);
}
);
ajaxRequest.send(false);
Expand Down
4 changes: 2 additions & 2 deletions plugin.json
@@ -1,15 +1,15 @@
{
"name": "LiveTab",
"description": "Keep an eye on the number of live visitors in the browser tab. It displays the number of visitors in the last 30 minutes in the browser tab.",
"version": "3.0.1",
"version": "4.0.0",
"keywords": [
"live",
"tab"
],
"homepage": "https://matomo.org",
"license": "GPL-3.0+",
"require": {
"piwik": ">=3.0.0-b1,<4.0.0-b1"
"piwik": ">=4.0.0-b1,<5.0.0-b1"
},
"support": {
"issues": "https://github.com/tsteur/matomo-livetab-plugin/issues",
Expand Down

0 comments on commit 677df05

Please sign in to comment.