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 4.12.0 #381

Merged
merged 27 commits into from
Feb 11, 2021
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7eab3f8
Add some badges in README
matks Dec 2, 2020
d00f76f
Add LICENSE file
matks Dec 2, 2020
56d69a3
Merge pull request #370 from matks/add-more-badges
PierreRambaud Dec 3, 2020
8cd3328
Merge pull request #371 from matks/add-license
PierreRambaud Dec 3, 2020
0c4a6e2
Improve README
matks Dec 3, 2020
0970583
Merge pull request #372 from matks/improve-readme
PierreRambaud Dec 3, 2020
f2095f0
Fix error with private method and upgrade
nenes25 Dec 13, 2020
db74f00
Migrate upgrade test to Github Actions
atomiix Jan 8, 2021
d40089b
Migrate phpstan to Github Actions
atomiix Jan 13, 2021
2f45e42
Add nightly upgrade results to the nightly-board
atomiix Jan 18, 2021
8c19e50
Delete travis
atomiix Jan 19, 2021
33c257d
Simplify CLI parameters handling
atomiix Jan 22, 2021
f6a0ac6
Merge pull request #377 from atomiix/travis-to-GA
PierreRambaud Jan 26, 2021
0e17be6
Clear cache before enabling theme
atomiix Jan 8, 2021
0bbc6f4
Use official phpstan with php 7.4
atomiix Jan 29, 2021
d3a9d54
Fix phpstan
atomiix Jan 29, 2021
6789a91
Merge pull request #378 from atomiix/fix-phpstan
atomiix Feb 5, 2021
9cd76ec
Merge pull request #376 from atomiix/fix-enable-theme
PierreRambaud Feb 5, 2021
0384690
Merge pull request #374 from nenes25/dev
PierreRambaud Feb 5, 2021
e3e686d
Bump v4.12.0
matks Feb 9, 2021
76aa8fb
Merge pull request #380 from matks/bump-v412
matks Feb 9, 2021
bf396cf
Fix phpstan
atomiix Feb 9, 2021
77513ee
Merge pull request #383 from atomiix/fix-phpstan
matks Feb 9, 2021
4816de1
Replace Travis (deprecated) badge by GitHub Action Upgrade badge
matks Feb 9, 2021
6a75862
Merge pull request #382 from matks/remove-travis-badge
Progi1984 Feb 9, 2021
9d403e2
Update GCP secret keys
atomiix Feb 10, 2021
b72f76d
Merge pull request #384 from atomiix/update-GCP-secret
PierreRambaud Feb 10, 2021
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
14 changes: 14 additions & 0 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM prestashop/base:7.1-apache
LABEL maintainer="PrestaShop Core Team <coreteam@prestashop.com>"

ARG VERSION
ENV PS_VERSION $VERSION

# Get PrestaShop
ADD https://www.prestashop.com/download/old/prestashop_${PS_VERSION}.zip /tmp/prestashop.zip

# Extract
RUN mkdir -p /tmp/data-ps \
&& unzip -q /tmp/prestashop.zip -d /tmp/data-ps/ \
&& bash /tmp/ps-extractor.sh /tmp/data-ps \
&& rm /tmp/prestashop.zip
37 changes: 37 additions & 0 deletions .github/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Upgrade
description: Test PrestaShop upgrade process
runs:
using: composite
steps:
- name: Build docker compose stack
env:
VERSION: ${{ matrix.ps-versions.from }}
shell: bash
run: |
docker-compose -f docker-compose.yml 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
run: docker exec -u www-data prestashop_autoupgrade cp modules/autoupgrade/ -R admin-dev
- name: Upgrade (major)
env:
CHANNEL: ${{ matrix.ps-versions.channel }}
ARCHIVE_URL: ${{ matrix.ps-versions.file }}
VERSION: ${{ matrix.ps-versions.version }}
shell: bash
run: ${{ github.action_path }}/action_upgrade.sh
- name: Check endpoints response
shell: bash
run: |
bash -c '[ "$(curl -L -s -o /dev/null -w %{http_code} http://localhost:8001/index.php)" == "200" ]'
bash -c '[ "$(curl -L -s -o /dev/null -w %{http_code} http://localhost:8001/admin-dev/index.php)" == "200" ]'
- name: Rollback
shell: bash
run: docker exec -u www-data prestashop_autoupgrade php modules/autoupgrade/tests/testCliProcess.php \
admin-dev/autoupgrade/cli-rollback.php --dir="admin-dev" \
--backup=`docker exec prestashop_autoupgrade bash -c "ls -td -- /var/www/html/admin-dev/autoupgrade/backup/*/ | head -n 1 | cut -d'/' -f8 | tr -d '\n'"`;
- name: Check endpoints response
shell: bash
run: |
bash -c '[ "$(curl -L -s -o /dev/null -w %{http_code} http://localhost:8001/index.php)" == "200" ]'
bash -c '[ "$(curl -L -s -o /dev/null -w %{http_code} http://localhost:8001/admin-dev/index.php)" == "200" ]'
10 changes: 10 additions & 0 deletions .github/action_upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

if [[ $CHANNEL == "archive" ]]; then
docker exec -u www-data prestashop_autoupgrade mkdir admin-dev/autoupgrade/download
docker exec -u www-data prestashop_autoupgrade curl $ARCHIVE_URL -o admin-dev/autoupgrade/download/prestashop.zip
echo "{\"channel\":\"archive\",\"archive_prestashop\":\"prestashop.zip\",\"archive_num\":\"${VERSION}\"}" > config.json
docker exec -u www-data prestashop_autoupgrade php admin-dev/autoupgrade/cli-updateconfig.php --from=modules/autoupgrade/config.json --dir=admin-dev
fi

docker exec -u www-data prestashop_autoupgrade php modules/autoupgrade/tests/testCliProcess.php admin-dev/autoupgrade/cli-upgrade.php --dir="admin-dev" --channel="$CHANNEL"
32 changes: 32 additions & 0 deletions .github/get_matrix.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

$matrix = [];

$nightlyEndpoint = "https://api-nightly.prestashop.com/reports";

$reports = json_decode(file_get_contents($nightlyEndpoint), true);
$currentDate = "";
foreach ($reports as $report) {
$date = strtotime($report['date']);
if ("" === $currentDate) {
$currentDate = $date;
}
if ($date === $currentDate) {
$matrix[] = [
"from" => "1.7.6.9",
"channel" => "archive",
"branch" => $report['version'],
"version" => getVersionFromFilename($report['download']),
"file" => $report['download']
];
}
}

function getVersionFromFilename($filename) {
$matches = [];
preg_match('/^.*prestashop_(.*)\.zip$/', $filename, $matches);

return $matches[1];
}

echo json_encode($matrix);
96 changes: 96 additions & 0 deletions .github/get_results.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

$result = getTestResultFromFile('result.txt');
$testPassed = $result['state'] === 'passed';
$branch = $result['branch'];

$data = [
'stats' => [
'start' => $result['date_start']->format('Y-m-d H:i:s'),
'end' => $result['date_end']->format('Y-m-d H:i:s'),
'duration' => $result['duration'],
'skipped' => 0,
'pending' => 0,
'passes' => $testPassed ? 1 : 0,
'failures' => $testPassed ? 0 : 1,
'suites' => 1,
'tests' => 1,
],
'suites' => [
'uuid' => uniqid(),
'title' => $result['title'],
'file' => '',
'duration' => $result['duration'],
'hasSkipped' => false,
'hasPending' => false,
'hasPasses' => $testPassed > 0,
'hasFailures' => $testPassed === 0,
'totalSkipped' => 0,
'totalPending' => 0,
'totalPasses' => $testPassed ? 1 : 0,
'totalFailures' => $testPassed ? 0 : 1,
'hasSuites' => true,
'hasTests' => false,
'tests' => [],
'suites' => [[
'uuid' => uniqid(),
'title' => $result['title'],
'file' => '',
'duration' => $result['duration'],
'hasSkipped' => false,
'hasPending' => false,
'hasPasses' => $testPassed > 0,
'hasFailures' => $testPassed === 0,
'totalSkipped' => 0,
'totalPending' => 0,
'totalPasses' => $testPassed ? 1 : 0,
'totalFailures' => $testPassed ? 0 : 1,
'hasSuites' => false,
'hasTests' => true,
'suites' => [],
'tests' => [$result],
]],
],
];

$filename = 'autoupgrade_' . date('Y-m-d') . '-' . $branch . '.json';
file_put_contents($filename, json_encode($data));

function getTestResultFromFile($file)
{
$data = explode('|', trim(file_get_contents($file)));
$dateStart = getDateTimeFromString($data[2]);
$dateEnd = getDateTimeFromString($data[3]);
$duration = ($dateEnd->getTimestamp() - $dateStart->getTimestamp()) * 1000;
$state = $data[4] === 'success' ? 'passed' : 'failed';
$error = null;
if ($state !== 'passed') {
$error = [
'message' => sprintf(
'%s/%s/actions/runs/%s',
getenv('GITHUB_SERVER_URL'),
getenv('GITHUB_REPOSITORY'),
getenv('GITHUB_RUN_ID')
)
];
}

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

function getDateTimeFromString($datetime)
{
return DateTime::createFromFormat('Y-m-d\TH:i:s\Z', $datetime, new DateTimeZone('UTC'));
}
57 changes: 57 additions & 0 deletions .github/workflows/nigthly_upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Nightly Upgrades
on:
schedule:
- cron: '0 0 * * *'
jobs:
get_matrix:
name: Set up matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
- id: set-matrix
run: echo "::set-output name=matrix::$(php ./.github/get_matrix.php)"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
upgrade:
continue-on-error: true
needs: get_matrix
strategy:
fail-fast: false
matrix:
ps-versions: ${{ fromJson(needs.get_matrix.outputs.matrix) }}
runs-on: ubuntu-latest
name: Upgrade
outputs:
result: ${{ steps.export-result.outputs.result }}
steps:
- uses: actions/checkout@v2
- name: Composer Install
run: |
composer install
echo "START_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`" >> $GITHUB_ENV
- name: Upgrade & Rollback
id: upgrade-rollback
uses: ./.github/
- name: Format result
if: ${{ always() }}
run: |
export END_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
echo "${{matrix.ps-versions.branch}}|${{matrix.ps-versions.version}}|$START_DATE|$END_DATE|${{steps.upgrade-rollback.outcome}}" > result.txt
php ./.github/get_results.php
- name: Set up Cloud SDK
if: ${{ always() }}
uses: google-github-actions/setup-gcloud@master
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: Push results to the nightly board
if: ${{ always() }}
run: |
export TODAY=`date -u +"%Y-%m-%d"`
export FILENAME=autoupgrade_$TODAY-${{matrix.ps-versions.branch}}.json
gsutil cp $FILENAME gs://prestashop-core-nightly/reports
curl -X GET "https://api-nightly.prestashop.com/hook/add?filename=$FILENAME&platform=cli&campaign=autoupgrade&token=${{ secrets.QANB_TOKEN }}"
46 changes: 43 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: PHP tests
on: [push, pull_request]
jobs:
build:
php-unit:
strategy:
matrix:
php-versions: ['5.6', '7.1', '7.2','7.4']
Expand All @@ -13,9 +13,49 @@ jobs:
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv, ext-zip
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
fetch-depth: 0

- run: composer install --prefer-dist
- run: ./vendor/phpunit/phpunit/phpunit tests
- run: ./vendor/phpunit/phpunit/phpunit tests

phpstan:
name: PHPStan
runs-on: ubuntu-latest
strategy:
matrix:
presta-versions: [ '1.6.1.18', '1.7.6.9', 'latest' ]
steps:
- name: Checkout
uses: actions/checkout@v2.0.0

- name: Cache vendor folder
uses: actions/cache@v1
with:
path: vendor
key: php-${{ hashFiles('composer.lock') }}

- name: Cache composer folder
uses: actions/cache@v1
with:
path: ~/.composer/cache
key: php-composer-cache

- run: composer install

- name: Execute PHPStan on PrestaShop (Tag ${{ matrix.presta-versions }})
env:
PS_VERSION: ${{ matrix.presta-versions }}
IS_16: ${{ startsWith(matrix.presta-versions, '1.6') }}
run: |
PHPSTAN_FILE="phpstan.neon" && [[ $IS_16 == true ]] && PHPSTAN_FILE="phpstan-PS-16.neon"
echo $PHPSTAN_FILE
docker rm -f temp-ps || true
docker volume rm -f ps-volume || true
docker run -d --rm -v ps-volume:/var/www/html --name temp-ps prestashop/prestashop:$PS_VERSION
docker exec -t temp-ps rm -rf /var/www/html/modules/autoupgrade
docker build -t phpstan:php-7.4 ./tests/phpstan/
docker run --rm --volumes-from temp-ps -v $PWD:/var/www/html/modules/autoupgrade \
-e _PS_ROOT_DIR_=/var/www/html --workdir=/var/www/html/modules/autoupgrade phpstan:php-7.4 \
analyse --configuration=/var/www/html/modules/autoupgrade/tests/phpstan/$PHPSTAN_FILE
26 changes: 26 additions & 0 deletions .github/workflows/upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Upgrades
on: [push, pull_request]
jobs:
upgrade:
strategy:
matrix:
ps-versions:
- from: 1.6.1.11
channel: minor
# Failing for now
#- from: 1.6.1.24
# channel: major
- from: 1.7.6.9
channel: major
- from: 1.7.6.1
channel: minor
- from: 1.7.7.0
channel: minor
runs-on: ubuntu-latest
name: Upgrade
steps:
- uses: actions/checkout@v2
- name: Composer Install
run: composer install
- name: Upgrade & Rollback
uses: ./.github/
57 changes: 0 additions & 57 deletions .travis.yml

This file was deleted.

Loading