-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #381 from PrestaShop/dev
Release 4.12.0
- Loading branch information
Showing
29 changed files
with
548 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.GC_PROJECT_ID }} | ||
service_account_key: ${{ secrets.GC_SERVICE_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 }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.