Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Jul 1, 2021
2 parents ef24332 + ed5dbe8 commit 7d4d806
Show file tree
Hide file tree
Showing 14 changed files with 189 additions and 155 deletions.
139 changes: 139 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: LimeSurvey - CI pipeline
# Triggers the workflow on push or pull request events on all branches
on:
pull_request:
push:
branches:
- '*'

jobs:
CI-pipeline:
runs-on: ubuntu-18.04 # ubuntu runner hosted by Github
strategy:
matrix:
# Specify what versions of php you want to test
php-versions: ['7.2', '8.0']
nodeJS-versions: [ '10.16.3' ]
# Env vars for this job
env:
DBENGINE: INNODB

name: PHP ${{ matrix.php-versions }} # Check each version of php specified in matrix
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# This will change the php version for every version specified in matrix https://github.com/marketplace/actions/setup-php-action
- name: Install specified PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}

# Start the MySQL service - https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu1804-README.md#mysql
- name: Start the MySQL service
run: |
sudo systemctl start mysql.service
- name: Initilize and check all dependencies
run: |
# Before running composer install, check that the autoloader is up-to-date and all classes can be loaded.
php tests/check_autoloader.php
# Test
echo $archive_url
php -r 'var_dump(PHP_INT_SIZE);'
# Install LimeSurvey.
php -m # Spit out all loaded PHP modules
mysql --version
touch enabletests
# NB: PHPUnit 6.5.* is installed with composer.
composer install -vvv
./third_party/bin/phpunit --version
- name: Set up Apache+PHP
run: |
# Set up the Apache and PHP
sudo apt-get update > /dev/null
sudo apt install php libapache2-mod-php -y
sudo cp -f ./tests/CI-pipeline/github-actions-apache /etc/apache2/sites-available/000-default.conf
sudo sed -e "s?%CI_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/000-default.conf
sudo service apache2 restart
# Give permision to access files for Apache
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./tmp
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./upload
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./themes
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./tests/tmp
setfacl -dR -m u:www-data:rwX -m u:$(whoami):rwx ./application/config
chmod -R 777 ./tmp
sudo chown -R www-data:docker ./tmp
chmod -R 777 ./upload
chmod -R 777 ./themes # Need 777 so both console and web server can cd into the folder.
chmod -R 777 ./tests/tmp
chmod -R 777 ./application/config
chmod +x ./tests/bin/lint-*
- name: Check MySQL service
run: |
# InnoDB needs large_file_prefix & Barracuda file format
# https://discuss.gogs.io/t/solved-mysql-error-1064-while-running-first-install/1604
# InnoDB variables ARE already set to desired values in Github runner (ubuntu-18.04)
sudo service mysql status
mysql -uroot -proot -e "Show variables like '%large%';"
mysql -uroot -proot -e "Show variables like '%innodb_file%';"
mysql -uroot -proot -e "Show variables like '%innodb_default%';"
- name: Load custom console and start the Application
run: |
php application/commands/console.php install admin password TravisLS no@email.com verbose
cp application/config/config-sample-mysql.php application/config/config.php
# Enable debug=2 in config file. OBS: This assumes debug is on line 61.
# TODO: Disable, a lines was added to config file and some tests started to fail.
# NB: EmCache is always disabled when debug => 2
# NB: There can be a difference in assets used when debug = 0 or 2 (minified version or not)
# sed -i '61s/.*/ "debug"=>2,/' application/config/config.php
# cat application/config/config.php

- name: Run syntax check, CodeSniffer, MessDetector, ...
run: composer test

- name: Test the server
run: |
# Test server.
wget localhost
cat index.html
# Chromedriver setup.
# Note: Keep getting timeout problems on Travis with chromedriver.
# wget https://chromedriver.storage.googleapis.com/2.33/chromedriver_linux64.zip
# unzip chromedriver_linux64.zip

- name: Set up Selenium with firefox
run: |
which firefox
firefox -v
# Setup Selenium with Firefox headless mode, Gecko driver already installed
wget "https://selenium-release.storage.googleapis.com/3.7/selenium-server-standalone-3.7.1.jar"
export MOZ_HEADLESS=1
java -jar selenium-server-standalone-3.7.1.jar -enablePassThrough false > /dev/null 2> /dev/null &
# Prepare the packages that need to be tested and update the nvm
- name: Prepare the nvm with Node ${{ matrix.nodeJS-versions }}
run: |
# Update
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
source ~/.nvm/nvm.sh
# Install Node.js
nvm install ${{ matrix.nodeJS-versions }}
nvm use ${{ matrix.nodeJS-versions }}
node ./buildVueComponents.js -s adminbasics -p
- name: Run the test script
run: |
DOMAIN=localhost ./third_party/bin/phpunit --testdox --stop-on-failure
yarn --cwd ./assets/packages/adminbasics run test
121 changes: 0 additions & 121 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion application/config/config-sample-mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
'connectionString' => 'mysql:host=localhost;port=3306;dbname=limesurvey;',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'password' => 'root',
'charset' => 'utf8mb4',
'tablePrefix' => 'lime_',
),
Expand Down
6 changes: 6 additions & 0 deletions application/helpers/admin/htmleditor_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ function getInlineEditor($fieldtype, $fieldname, $fieldtext, $surveyID = null, $
ckeConfig.editorplaceholder = $('#" . $fieldname . "').attr('placeholder');
}
// Show full toolbar if cookie is set
var toolbarCookie = CKEDITOR.tools.getCookie('LS_CKE_TOOLBAR');
if (toolbarCookie == 'full' && ckeConfig.toolbar == ckeConfig.basicToolbar) {
ckeConfig.toolbar = ckeConfig.fullToolbar;
}
$oCKeditorVarName = CKEDITOR.replace('$fieldname', ckeConfig);
\$('#$fieldname').parents('ul:eq(0)').addClass('editor-parent');
Expand Down
6 changes: 4 additions & 2 deletions application/helpers/update/updatedb_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -3319,8 +3319,8 @@ function db_upgrade_all($iOldDBVersion, $bSilent = false)
}
alterColumn('{{participants}}', 'firstname', "text");
alterColumn('{{participants}}', 'lastname', "text");
$oDB->createCommand()->addColumn('{{participant_attribute_names}}', 'encrypted', "string(5) NOT NULL");
$oDB->createCommand()->addColumn('{{participant_attribute_names}}', 'core_attribute', "string(5) NOT NULL");
$oDB->createCommand()->addColumn('{{participant_attribute_names}}', 'encrypted', "string(5) NOT NULL DEFAULT ''");
$oDB->createCommand()->addColumn('{{participant_attribute_names}}', 'core_attribute', "string(5) NOT NULL DEFAULT ''");
$aCoreAttributes = array('firstname', 'lastname', 'email');
foreach ($aCoreAttributes as $attribute) {
$oDB->createCommand()->insert(
Expand Down Expand Up @@ -3769,6 +3769,8 @@ function ($v) {
}
};
$insertPlugin('AuthLDAP');
$insertPlugin('Authdb');
$insertPlugin('ComfortUpdateChecker');
$insertPlugin('AuditLog');
$insertPlugin('Authwebserver');
$insertPlugin('ExportR', 1);
Expand Down
4 changes: 2 additions & 2 deletions application/views/questionAdministration/languageselector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
</button>
<ul class="dropdown-menu dropdown-menu-right">
<?php foreach ($oSurvey->allLanguages as $lang): ?>
<li>
<a href="#" class="lang-switch-button<?= $lang === $oSurvey->language ? ' active' : '' ?>" data-lang="<?= $lang; ?>">
<li class="<?= $lang === $oSurvey->language ? ' active' : '' ?>">
<a href="#" class="lang-switch-button" data-lang="<?= $lang; ?>">
<?= getLanguageNameFromCode($lang, false); ?>
</a>
</li>
Expand Down
8 changes: 8 additions & 0 deletions application/views/questionAdministration/textElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
</a>
</li>
<?php endif; ?>
<!-- Language label -->
<li class="pull-right">
<?php foreach($oSurvey->allLanguages as $lang): ?>
<h5 class="lang-hide lang-<?= $lang; ?>" style="<?= $lang != $oSurvey->language ? 'display: none;' : '' ?>">
<span class="label label-default"><?= strtoupper($lang) ?></span>
</h5>
<?php endforeach; ?>
</li>
</ul>
<div class="tab-content">
<!-- Question text tab content -->
Expand Down
4 changes: 3 additions & 1 deletion assets/packages/ckeditor/plugins/lsswitchtoolbars/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
if (isMaximized) {
editor.execCommand('maximize');
}
var switchToFull = config.toolbar == config.basicToolbar;
editor.destroy();
config.toolbar = config.toolbar == config.basicToolbar ? config.fullToolbar : config.basicToolbar;
config.toolbar = switchToFull ? config.fullToolbar : config.basicToolbar;
var newEditor = CKEDITOR.replace(name, config);
if (isMaximized) {
newEditor.on('instanceReady', function(event) {
this.execCommand('maximize');
});
}
CKEDITOR.tools.setCookie('LS_CKE_TOOLBAR', switchToFull ? 'full' : 'basic');
},

editorFocus: false,
Expand Down
5 changes: 5 additions & 0 deletions assets/scripts/admin/questionEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,11 @@ $(document).on('ready pjax:scriptcomplete', function () {
$('.lang-hide').hide();
$(langClass).show();
$('#language-dropdown-text').text($(this).text());
// Mark the selected option
$(this).closest('ul').find('li').each(function removeActiveClassFromLanguageListItems() {
$(this).removeClass('active');
});
$(this).closest('li').addClass('active');
});

// Hide all languages except main.
Expand Down
13 changes: 13 additions & 0 deletions tests/CI-pipeline/github-actions-apache
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<VirtualHost *:80>
# [...]

DocumentRoot %CI_BUILD_DIR%

<Directory "%CI_BUILD_DIR%/">
Options FollowSymLinks MultiViews ExecCGI
AllowOverride All
Require all granted
</Directory>

# [...]
</VirtualHost>
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public function testPluginsStats()
]
);
try {
self::$webDriver->get($url);
self::$webDriver->get($url);
sleep(1); // Page did not load properly

/* 1st page */
$submit = self::$webDriver->findElement(WebDriverBy::id('ls-button-submit'));
$submit->click();
Expand Down

0 comments on commit 7d4d806

Please sign in to comment.