Skip to content

Commit

Permalink
Merge branch 'dev' into pr-35843
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaikina committed May 27, 2024
2 parents 88bea96 + d4f360b commit 8ebd38a
Show file tree
Hide file tree
Showing 48 changed files with 237,950 additions and 701 deletions.
27 changes: 26 additions & 1 deletion .github/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,35 @@ description: Test PrestaShop upgrade process
runs:
using: composite
steps:
- name: Get base version
id: get_base_version
shell: bash
run: |
case ${{ matrix.from }} in
1.6* | 1.7.[1-4]*)
echo "BASE_VERSION=7.1-apache" >> "$GITHUB_OUTPUT"
;;
1.7.[5-6]*)
echo "BASE_VERSION=7.2-apache" >> "$GITHUB_OUTPUT"
;;
1.7.7*)
echo "BASE_VERSION=7.3-apache" >> "$GITHUB_OUTPUT"
;;
1.7.8*)
echo "BASE_VERSION=7.4-apache" >> "$GITHUB_OUTPUT"
;;
8.0* | 8.1*)
echo "BASE_VERSION=8.1-apache" >> "$GITHUB_OUTPUT"
;;
*)
echo "BASE_VERSION=7.1-apache" >> "$GITHUB_OUTPUT"
;;
esac
- 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' }}
BASE_VERSION: ${{ steps.get_base_version.outputs.BASE_VERSION }}
shell: bash
run: |
docker compose up -d
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/e2e_nightly_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3

- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16

Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
steps:

# Setup PrestaShop and Install Autoupgrade module
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3

- run: |
cp -r .github .github_dev
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:

# Install Module with user interface
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16

Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
ZIP_NAME: ${{ matrix.ps_target_version.filename }}
AUTOUPGRADE_VERSION: ${{ matrix.module_branch }}

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload failed screenshots
if: ${{ always() }}
with:
Expand All @@ -140,7 +140,7 @@ jobs:
if: ${{ always() }}
run: ./tests/e2e/scripts/copy_reports.sh ${{ env.reports_directory }} ${{ matrix.ps_start_version }} ${{ matrix.ps_target_version.branch }} ${{ matrix.module_branch }}

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload Mochawesome report
if: ${{ always() }}
with:
Expand All @@ -162,16 +162,16 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
name: Download reports
with:
name: tests-reports-${{ matrix.ps_target_version.branch }}
path: ${{ env.reports_directory }}

- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: 16

Expand All @@ -185,7 +185,7 @@ jobs:
run: npx mochawesome-merge "${{ env.reports_directory }}/*.json" -o "${{ env.reports_directory }}/${{ env.combined_report_name }}"
working-directory: ./tests/e2e

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
name: Upload combined report
with:
name: combined-report-${{ matrix.ps_target_version.branch }}
Expand All @@ -206,15 +206,15 @@ jobs:
fail-fast: false

steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
name: Download report
with:
name: combined-report-${{ matrix.ps_target_version.branch }}
path: ${{ env.reports_directory }}

- uses: google-github-actions/setup-gcloud@v0
- uses: google-github-actions/setup-gcloud@v2.1.0
name: Setup Cloud Sdk
with:
project_id: ${{ secrets.GC_PROJECT_ID }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/nightly_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Set up matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
Expand Down Expand Up @@ -37,7 +37,7 @@ jobs:
outputs:
result: ${{ steps.export-result.outputs.result }}
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3
- if: ${{ matrix.branch != 'dev' }}
run: |
cp -r .github .github_dev
Expand All @@ -59,7 +59,7 @@ jobs:
echo "${{ matrix.branch }}|${{matrix.from}}|${{matrix.ps-versions.branch}}|${{matrix.ps-versions.version}}|$START_DATE|$END_DATE|${{steps.upgrade-rollback.outcome}}" > ${{ matrix.branch }}_${{matrix.from}}_${{matrix.ps-versions.branch}}.txt
- name: Upload artifact
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.branch }}_${{matrix.from}}_${{matrix.ps-versions.branch}}
path: ${{ matrix.branch }}_${{matrix.from}}_${{matrix.ps-versions.branch}}.txt
Expand All @@ -74,14 +74,14 @@ jobs:
matrix:
ps-versions: ${{ fromJson(needs.get_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/download-artifact@v2
- uses: actions/checkout@v4.1.3
- uses: actions/download-artifact@v4
with:
path: ./artifacts/
- name: Format results
run: php ./.github/get_results.php ${{matrix.ps-versions.branch}}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
uses: google-github-actions/setup-gcloud@v2.1.0
with:
project_id: ${{ secrets.GC_PROJECT_ID }}
service_account_key: ${{ secrets.GC_SERVICE_KEY }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.1.0
uses: actions/checkout@v4.1.3

- name: PHP syntax checker 5.6
uses: prestashop/github-action-php-lint/5.6@master
Expand Down Expand Up @@ -53,10 +53,10 @@ jobs:
php-version: '5.6'

- name: Checkout
uses: actions/checkout@v3.1.0
uses: actions/checkout@v4.1.3

- name: Cache dependencies
uses: actions/cache@v3
uses: actions/cache@v4.0.2
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}
Expand All @@ -79,7 +79,7 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv, ext-zip
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3
with:
fetch-depth: 0

Expand All @@ -95,18 +95,18 @@ jobs:
presta-versions: ['1.7.2.5', '1.7.3.4', '1.7.4.4', '1.7.5.1', '1.7.6', '1.7.7', '1.7.8', '8.0.0', 'latest']
steps:
- name: Checkout
uses: actions/checkout@v3.1.0
uses: actions/checkout@v4.1.3

# Add vendor folder in cache to make next builds faster
- name: Cache vendor folder
uses: actions/cache@v3
uses: actions/cache@v4.0.2
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

# Add composer local folder in cache to make next builds faster
- name: Cache composer folder
uses: actions/cache@v3
uses: actions/cache@v4.0.2
with:
path: ~/.composer/cache
key: php-composer-cache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
upgrade:
strategy:
matrix:
from: ['1.7.6.9', '1.7.6.1', '1.7.7.0', '8.0.0', '8.1.0']
from: ['1.7.0.6', '1.7.6.9', '1.7.6.1', '1.7.7.0', '8.0.0', '8.1.0']
ps-versions:
- channel: minor
- channel: major
runs-on: ubuntu-latest
name: Upgrade
steps:
- uses: actions/checkout@v3.1.0
- uses: actions/checkout@v4.1.3
- name: Composer Install
run: composer install
- name: Upgrade & Rollback
Expand Down
6 changes: 3 additions & 3 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.1';
$this->version = '5.0.2';
$this->need_instance = 1;

$this->bootstrap = true;
Expand Down Expand Up @@ -143,9 +143,9 @@ public function hookDashboardZoneOne($params)
require_once __DIR__ . '/vendor/autoload.php';

$upgradeContainer = new \PrestaShop\Module\AutoUpgrade\UpgradeContainer(_PS_ROOT_DIR_, _PS_ADMIN_DIR_);
$upgrader = $upgradeContainer->getUpgrader();
$upgradeSelfCheck = new \PrestaShop\Module\AutoUpgrade\UpgradeSelfCheck(
$upgrader,
$upgradeContainer->getUpgrader(),
$upgradeContainer->getPrestaShopConfiguration(),
_PS_ROOT_DIR_,
_PS_ADMIN_DIR_,
__DIR__
Expand Down
8 changes: 5 additions & 3 deletions classes/TaskRunner/Miscellaneous/CheckFilesVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

use PrestaShop\Module\AutoUpgrade\Parameters\UpgradeFileNames;
use PrestaShop\Module\AutoUpgrade\TaskRunner\AbstractTask;
use PrestaShop\Module\AutoUpgrade\UpgradeContainer;

/**
* List the files modified in the current installation regards to the original version.
Expand All @@ -39,8 +40,9 @@ public function run()
{
// do nothing after this request (see javascript function doAjaxRequest )
$this->next = '';
$upgrader = $this->container->getUpgrader();
$changedFileList = $upgrader->getChangedFilesList();
$checksumCompare = $this->container->getChecksumCompare();
$currentPrestaShopVersion = $this->container->getProperty(UpgradeContainer::PS_VERSION);
$changedFileList = $checksumCompare->getTamperedFilesOnShop($currentPrestaShopVersion);

if ($changedFileList === false) {
$this->nextParams['status'] = 'error';
Expand All @@ -55,7 +57,7 @@ public function run()
}
}

if ($upgrader->isAuthenticPrestashopVersion() === true) {
if ($checksumCompare->isAuthenticPrestashopVersion($currentPrestaShopVersion)) {
$this->nextParams['status'] = 'ok';
$this->nextParams['msg'] = $this->translator->trans('Core files are ok', [], 'Modules.Autoupgrade.Admin');
} else {
Expand Down
21 changes: 9 additions & 12 deletions classes/TaskRunner/Miscellaneous/CompareReleases.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function run()
$this->next = '';
$channel = $this->container->getUpgradeConfiguration()->get('channel');
$upgrader = $this->container->getUpgrader();
$checksumCompare = $this->container->getChecksumCompare();
switch ($channel) {
case 'archive':
$version = $this->container->getUpgradeConfiguration()->get('archive.version_num');
Expand All @@ -63,23 +64,19 @@ public function run()

// Get list of differences between these two versions. The differences will be fetched from a local
// XML file if it exists, or from PrestaShop API.
$diffFileList = $upgrader->getDiffFilesList(_PS_VERSION_, $version);
$diffFileList = $checksumCompare->getFilesDiffBetweenVersions(_PS_VERSION_, $version);
if (!is_array($diffFileList)) {
$this->nextParams['status'] = 'error';
$this->nextParams['msg'] = sprintf('Unable to generate diff file list between %1$s and %2$s.', _PS_VERSION_, $version);
} else {
$this->container->getFileConfigurationStorage()->save($diffFileList, UpgradeFileNames::FILES_DIFF_LIST);
if (count($diffFileList) > 0) {
$this->nextParams['msg'] = $this->translator->trans(
'%modifiedfiles% files will be modified, %deletedfiles% files will be deleted (if they are found).',
[
'%modifiedfiles%' => count($diffFileList['modified']),
'%deletedfiles%' => count($diffFileList['deleted']),
],
'Modules.Autoupgrade.Admin');
} else {
$this->nextParams['msg'] = $this->translator->trans('No diff files found.', [], 'Modules.Autoupgrade.Admin');
}
$this->nextParams['msg'] = $this->translator->trans(
'%modifiedfiles% files will be modified, %deletedfiles% files will be deleted (if they are found).',
[
'%modifiedfiles%' => count($diffFileList['modified']),
'%deletedfiles%' => count($diffFileList['deleted']),
],
'Modules.Autoupgrade.Admin');
$this->nextParams['result'] = $diffFileList;
}
}
Expand Down
Loading

0 comments on commit 8ebd38a

Please sign in to comment.