Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release version 5.0.1 #668

Merged
merged 40 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
8b10d1a
Add index to `PREFIX_orders.invoice_date`
AdrienPlx Feb 6, 2023
fbafb0e
Update 9.0.0.sql
AdrienPlx Feb 20, 2023
c4df783
delete local zip after usage
Sep 8, 2023
5e760cd
Merge branch 'dev' into patch-1
AdrienPlx Nov 24, 2023
d033afe
Merge pull request #623 from matthieu-rolland/fix-upgrade-local-module
nicosomb Dec 19, 2023
3dd77c6
Merge pull request #560 from AdrienPlx/patch-1
Hlavtox Dec 28, 2023
5fc94e6
Implement required database changes
Hlavtox Dec 28, 2023
ffe8c3a
Change device status
Hlavtox Dec 28, 2023
f23742d
Add debug cookie default configuration values
unlocomqx Dec 28, 2023
f218648
Merge pull request #660 from unlocomqx/debug-cookie
Hlavtox Dec 28, 2023
a8f4300
Fix normalizeVersion() levels on 8.x
Seb33300 Jan 6, 2024
2eeb3ad
Add version tests
Seb33300 Jan 6, 2024
6e68723
Check if function get_magic_quotes_gpc() exists before use it - remov…
xsbr Jan 6, 2024
28f5312
Add PrestaShop 8 to CI
Seb33300 Jan 7, 2024
cc8a09e
Bump follow-redirects from 1.15.3 to 1.15.4 in /tests/e2e
dependabot[bot] Jan 11, 2024
39dd3e8
Merge pull request #663 from PrestaShop/dependabot/npm_and_yarn/tests…
Progi1984 Jan 11, 2024
7f61c4c
Merge pull request #659 from Hlavtox/adapt-31151
Hlavtox Jan 11, 2024
5609c9c
Update classes/UpgradeTools/Translation.php
xsbr Jan 11, 2024
aabd603
Merge pull request #662 from xsbr/get_magic_quotes_gpc
Hlavtox Jan 12, 2024
05b00d2
Nightly : Migrate from endpoint `hook/add` to `hook/reports/import`
Progi1984 Jan 23, 2024
79e041a
Add EOL on .gitignore file
Progi1984 Jan 23, 2024
355ea03
Merge pull request #664 from Progi1984/qaNightlyMigrateEndpoint
Progi1984 Jan 23, 2024
146312b
Nightly Upgrade : Fixed date formatting
Progi1984 Jan 24, 2024
1a55c94
Merge pull request #665 from Progi1984/fixNightly
Progi1984 Jan 24, 2024
da11d7f
Nightly Upgrade : Fixed date formatting (Use of DateTime::RFC3339_EXT…
Progi1984 Jan 24, 2024
38c878a
Merge pull request #666 from Progi1984/fixNightly
Progi1984 Jan 24, 2024
e81b188
Merge pull request #661 from Seb33300/version-levels
kpodemski Jan 25, 2024
fbcc308
Add missing hooks
Hlavtox Jan 30, 2024
5e2c4ca
Merge pull request #667 from Hlavtox/add-hooks
Hlavtox Jan 30, 2024
bc324bb
Rename 8.1.4.sql to 8.1.5.sql
Hlavtox Feb 19, 2024
c010d57
Merge pull request #671 from Hlavtox/rename-814-815
Hlavtox Feb 20, 2024
815fb7f
Update hooks when they already exist
Hlavtox Feb 7, 2024
e0f0b59
Update comment
Hlavtox Feb 20, 2024
4965d1e
Merge pull request #669 from Hlavtox/update-hook-data
Hlavtox Feb 26, 2024
f677e3d
Fix docker env variable for version 8
jolelievre Feb 23, 2024
8c52545
Improve module base class
jolelievre Feb 26, 2024
afc3b55
Update hook position is not blocking for installation
jolelievre Feb 26, 2024
bc2378d
Merge pull request #673 from jolelievre/debug-ci
Hlavtox Feb 26, 2024
c226b61
Bump version 5.0.1
jolelievre Feb 27, 2024
6f57bd0
Merge pull request #674 from jolelievre/bump-version
kpodemski Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ runs:
- name: Build docker compose stack
env:
VERSION: ${{ matrix.from }}
BASE_VERSION: ${{ startsWith(matrix.from, '1.6') && '7.1-apache' || startsWith(matrix.from, '8.1') && '8.1-apache' || startsWith(matrix.from, '8.0') && '8.1-apache' || '7.2-apache' }}
shell: bash
run: |
bash -c 'if [[ "${VERSION}" == 1.6* ]]; then export BASE_VERSION=7.1-apache; \
elif [[ "${VERSION}" == 8.* ]]; then export BASE_VERSION=8.1-apache; \
else export BASE_VERSION=7.2-apache; fi && docker compose up -d'
docker compose up -d
bash -c 'while [[ "$(curl -L -s -o /dev/null -w %{http_code} http://localhost:8001/index.php)" != "200" ]]; do sleep 5; done'
- name: Copy autoupgrade module
shell: bash
Expand Down
183 changes: 107 additions & 76 deletions .github/get_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,58 +11,75 @@
$results[] = getTestResultFromFile($file);
}
$globalResults = getGlobalResults($results, $psBranch);
$totalDuration = getTotalDuration($globalResults);
$totalDuration = getTotalDuration($globalResults, $results[0]['branch']);

$data = [
'stats' => [
'start' => getDateStart($globalResults)->format('Y-m-d H:i:s'),
'end' => getDateEnd($globalResults)->format('Y-m-d H:i:s'),
'duration' => $totalDuration,
'skipped' => 0,
'pending' => 0,
'passes' => getPasses($globalResults),
'failures' => getFailures($globalResults),
'suites' => 1,
'tests' => count($results),
],
'suites' => [
'uuid' => uniqid(),
'title' => 'Upgrade to branch ' . $psBranch,
'file' => '',
'passes' => getPasses($globalResults),
'pending' => 0,
'failures' => getFailures($globalResults),
'testsRegistered' => count($results),
//passPercent
//pendingPercent
'other' => 0,
'hasOther' => 0,
'skipped' => 0,
'hasSkipped' => 0,
'start' => getDateStart($results)->format(\DateTime::RFC3339_EXTENDED),
'end' => getDateEnd($globalResults)->format(\DateTime::RFC3339_EXTENDED),
'duration' => $totalDuration,
'hasSkipped' => false,
'hasPending' => false,
'hasPasses' => getPasses($globalResults) > 0,
'hasFailures' => getFailures($globalResults) > 0,
'totalSkipped' => 0,
'totalPending' => 0,
'totalPasses' => getPasses($globalResults),
'totalFailures' => getFailures($globalResults),
'hasSuites' => true,
'hasTests' => false,
'tests' => [],
'suites' => [],
],
'results' => [],
];

foreach ($globalResults as $globalResult) {
$data['suites']['suites'][] = [
'uuid' => uniqid(),
'title' => $globalResult['title'],
$suiteTestsPasses = $suiteTestsFailures = $suiteTestsPending = $suiteTestsSkipped = [];
foreach($globalResult['tests'] as $test) {
if ($test['pass']) {
$suiteTestsPasses[] = $test['uuid'];
continue;
}
if ($test['fail']) {
$suiteTestsFailures[] = $test['uuid'];
continue;
}
if ($test['pending']) {
$suiteTestsPending[] = $test['uuid'];
continue;
}
}

$data['results'][] = [
'uuid' => $globalResult['uuid'],
'title' => 'Upgrade to branch ' . $psBranch,
'fullFile' => '',
'file' => '',
'duration' => $globalResult['duration'],
'hasSkipped' => false,
'hasPending' => false,
'hasPasses' => $globalResult['passes'] > 0,
'hasFailures' => $globalResult['failures'] > 0,
'totalSkipped' => 0,
'totalPending' => 0,
'totalPasses' => $globalResult['passes'],
'totalFailures' => $globalResult['failures'],
'hasSuites' => false,
'hasTests' => true,
'suites' => [],
'tests' => $globalResult['tests'],
'tests' => [],
'suites' => [
[
'uuid' => $globalResult['uuid'],
'title' => $globalResult['title'],
'file' => '',
'tests' => $globalResult['tests'],
'suites' => [],
'passes' => $suiteTestsPasses,
'failures' => $suiteTestsFailures,
'pending' => $suiteTestsPending,
'skipped' => $suiteTestsSkipped,
'duration' => $globalResult['duration'],
'root' => false,
'rootEmpty' => false,
],
],
'passes' => [],
'failures' => [],
'pending' => [],
'skipped' => [],
'duration' => $data['stats']['duration'],
'root' => true,
'rootEmpty' => true,
];
}

Expand Down Expand Up @@ -105,17 +122,19 @@ function getTestResultFromFile(string $file): array
}

return [
'uuid' => uniqid(),
'title' => '[' . $branch . '] Upgrade from ' . $data[1] . ' to ' . $data[2],
'context' => '{"value": "[' . $branch . '] Upgrade from ' . $data[1] . ' to ' . $data[2] . '"}',
'skipped' => [],
'pending' => [],
'duration' => $duration,
'state' => $state,
'pass' => $state === 'passed',
'fail' => $state === 'failed',
'pending' => false,
'context' => '{"title": "testIdentifier","value": "[' . $branch . '] Upgrade from ' . $data[1] . ' to ' . $data[2] . '"}',
'err' => $error,
'uuid' => uniqid(),
'skipped' => false,
'branch' => $branch,
'date_start' => $dateStart,
'date_end' => $dateEnd,
'branch' => $branch
];
}

Expand All @@ -129,25 +148,43 @@ function getGlobalResults(array $results, string $psBranch): array
$globalResults = [];

foreach ($results as $result) {
if (!isset($globalResults[$result['branch']])) {
$globalResults[$result['branch']] = [
'title' => '[' . $result['branch'] . '] Upgrade to branch ' . $psBranch,
$resultBranch = $result['branch'];
if (!isset($globalResults[$resultBranch])) {
$globalResults[$resultBranch] = [
'uuid' => uniqid(),
'title' => '[' . $resultBranch . '] Upgrade to branch ' . $psBranch,
'tests' => [],
'date_start' => null,
'date_end' => null,
'duration' => 0,
'passes' => 0,
'failures' => 0,
];
}
if (null === $globalResults[$result['branch']]['date_start'] || $result['date_start'] < $globalResults[$result['branch']]['date_start']) {
$globalResults[$result['branch']]['date_start'] = $result['date_start'];
if (null === $globalResults[$resultBranch]['date_start']
|| $result['date_start'] < $globalResults[$resultBranch]['date_start']) {
$globalResults[$resultBranch]['date_start'] = $result['date_start'];
}
if (null === $globalResults[$result['branch']]['date_end'] || $result['date_end'] > $globalResults[$result['branch']]['date_end']) {
$globalResults[$result['branch']]['date_end'] = $result['date_end'];
if (null === $globalResults[$resultBranch]['date_end']
|| $result['date_end'] > $globalResults[$resultBranch]['date_end']) {
$globalResults[$resultBranch]['date_end'] = $result['date_end'];
}
$globalResults[$result['branch']]['passes'] += $result['state'] === 'passed' ? 1 : 0;
$globalResults[$result['branch']]['failures'] += $result['state'] !== 'passed' ? 1 : 0;
$globalResults[$result['branch']]['tests'][] = $result;
$globalResults[$resultBranch]['passes'] += $result['state'] === 'passed' ? 1 : 0;
$globalResults[$resultBranch]['failures'] += $result['state'] !== 'passed' ? 1 : 0;
$globalResults[$resultBranch]['tests'][] = [
'title' => $result['title'],
'fullTitle' => $result['title'],
'timedOut' => false,
'duration' => $result['duration'],
'state' => $result['state'],
'pass' => $result['state'] === 'passed',
'fail' => $result['state'] === 'failed',
'pending' => $result['state'] === 'pending',
'context' => $result['context'],
'uuid' => $result['uuid'],
'parentUUID' => $globalResults[$resultBranch]['uuid'],
'isHook' => false,
'skipped' => $result['state'] === 'skipped',
];
}

foreach ($globalResults as &$globalResult) {
Expand All @@ -157,24 +194,24 @@ function getGlobalResults(array $results, string $psBranch): array
return $globalResults;
}

function getDateStart(array $globalResults): DateTime {
function getDateStart(array $results): DateTime {
$dateStart = null;

foreach ($globalResults as $globalResult) {
if (null === $dateStart || $globalResult['date_start'] < $dateStart) {
$dateStart = $globalResult['date_start'];
foreach ($results as $result) {
if (null === $dateStart || $result['date_start'] < $dateStart) {
$dateStart = $result['date_start'];
}
}

return $dateStart;
}

function getDateEnd(array $globalResults): DateTime {
function getDateEnd(array $results): DateTime {
$dateEnd = null;

foreach ($globalResults as $globalResult) {
if (null === $dateEnd || $globalResult['date_end'] < $dateEnd) {
$dateEnd = $globalResult['date_end'];
foreach ($results as $result) {
if (null === $dateEnd || $result['date_end'] < $dateEnd) {
$dateEnd = $result['date_end'];
}
}

Expand All @@ -201,18 +238,12 @@ function getFailures(array $globalResults): int {
return $failures;
}

function getTotalDuration(array $results): int {
$dateStart = null;
$dateEnd = null;
function getTotalDuration(array $results, string $branch): int {
$duration = 0;

foreach ($results as $result) {
if (null === $dateStart || $result['date_start'] < $dateStart) {
$dateStart = $result['date_start'];
}
if (null === $dateEnd || $result['date_end'] > $dateEnd) {
$dateEnd = $result['date_end'];
}
foreach ($results[$branch]['tests'] as $result) {
$duration += $result['duration'];
}

return ($dateEnd->getTimestamp() - $dateStart->getTimestamp()) * 1000;
return $duration;
}
2 changes: 1 addition & 1 deletion .github/workflows/nightly_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ jobs:
export FILENAME=autoupgrade_`date -u +"%Y-%m-%d"`-${{matrix.ps-versions.branch}}.json
./.github/workflows/nightly_scripts/push_results.sh ${{ env.nightly_api_url }} $FILENAME ${{ env.campaign }} ${{ env.platform }} ${{ secrets.QANB_TOKEN }}
env:
nightly_api_url: https://api-nightly.prestashop-project.org/hook/add
nightly_api_url: https://api-nightly.prestashop-project.org/hook/reports/import
campaign: autoupgrade
platform: cli
3 changes: 3 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: PHP tests
on: [push, pull_request]
concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# Check there is no syntax errors in the project
php-linter:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: Upgrades
on: [push, pull_request]
concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
upgrade:
strategy:
matrix:
from: ['1.7.6.9', '1.7.6.1', '1.7.7.0']
from: ['1.7.6.9', '1.7.6.1', '1.7.7.0', '8.0.0', '8.1.0']
ps-versions:
- channel: minor
- channel: major
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ nbproject
/config_*.xml
.php_cs.cache
.idea

## QA Nightly
/artifacts
/autoupgrade*.json
5 changes: 4 additions & 1 deletion AdminSelfUpgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
use PrestaShop\Module\AutoUpgrade\UpgradeSelfCheck;
use PrestaShop\Module\AutoUpgrade\UpgradeTools\FilesystemAdapter;

require_once _PS_ROOT_DIR_ . '/modules/autoupgrade/vendor/autoload.php';
$autoloadPath = __DIR__ . '/vendor/autoload.php';
if (file_exists($autoloadPath)) {
require_once $autoloadPath;
}

class AdminSelfUpgrade extends AdminController
{
Expand Down
12 changes: 10 additions & 2 deletions autoupgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct()
$this->name = 'autoupgrade';
$this->tab = 'administration';
$this->author = 'PrestaShop';
$this->version = '5.0.0';
$this->version = '5.0.1';
$this->need_instance = 1;

$this->bootstrap = true;
Expand Down Expand Up @@ -123,7 +123,15 @@ public function uninstall()
*/
public function registerHookAndSetToTop($hookName)
{
return $this->registerHook($hookName) && $this->updatePosition((int) Hook::getIdByName($hookName), false);
if (!$this->registerHook($hookName)) {
return false;
}

// Updating position is not blocking for installation esepcially since this method returns false when no other
// module is hooked, which doesn't mean the module can't work as expected.
$this->updatePosition((int) Hook::getIdByName($hookName), false);

return true;
}

public function hookDashboardZoneOne($params)
Expand Down
7 changes: 4 additions & 3 deletions classes/UpgradeTools/CoreUpgrader/CoreUpgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ protected function getPreUpgradeVersion()

/**
* Add missing levels in version.
* Example: 1.7 will become 1.7.0.0.
* Example: 1.7 will become 1.7.0.0 and 8.1 will become 8.1.0.
*
* @param string $version
*
Expand All @@ -245,8 +245,9 @@ protected function getPreUpgradeVersion()
public function normalizeVersion($version)
{
$arrayVersion = explode('.', $version);
if (count($arrayVersion) < 4) {
$arrayVersion = array_pad($arrayVersion, 4, '0');
$versionLevels = 1 == $arrayVersion[0] ? 4 : 3;
if (count($arrayVersion) < $versionLevels) {
$arrayVersion = array_pad($arrayVersion, $versionLevels, '0');
}

return implode('.', $arrayVersion);
Expand Down
1 change: 1 addition & 0 deletions classes/UpgradeTools/ModuleAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public function upgradeModule($id, $name, $isLocalModule = false)
$filesystem = new Filesystem();
$filesystem->copy($local_module_zip, $zip_fullpath);
$local_module_used = true;
unlink($local_module_zip);
}
} catch (IOException $e) {
// Do nothing, we will try to upgrade module from addons
Expand Down
3 changes: 0 additions & 3 deletions classes/UpgradeTools/Translation.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ public function mergeTranslationFile($orig, $dest, $type)
}
fwrite($fd, "<?php\n\nglobal \$" . $var_name . ";\n\$" . $var_name . " = array();\n");
foreach ($merge as $k => $v) {
if (get_magic_quotes_gpc()) {
$v = stripslashes($v);
}
if ('mail' == $type) {
fwrite($fd, '$' . $var_name . '[\'' . $this->escape($k) . '\'] = \'' . $this->escape($v) . '\';' . "\n");
} else {
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>autoupgrade</name>
<displayName><![CDATA[1-Click Upgrade]]></displayName>
<version><![CDATA[5.0.0]]></version>
<version><![CDATA[5.0.1]]></version>
<description><![CDATA[Upgrade to the latest version of PrestaShop in a few clicks, thanks to this automated method.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
Loading
Loading