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

Add Nightly upgrades using User Interface #387

Merged
merged 35 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c46feee
Add e2e tests for upgrade
Mar 6, 2021
a68558e
Add CI to test upgrade on core nightly builds
Mar 8, 2021
3d71606
Update run test command
Mar 8, 2021
3fa40a4
Fix get target versions job
Mar 8, 2021
7a34aff
Fix docker-compose env var
Mar 8, 2021
7ca726a
Install PrestaShop on Language 'en' and Country 'fr'
Mar 8, 2021
a09635a
Add configClassMap.js
Mar 8, 2021
571290b
Fix VERSION on docker-compose.yml
Mar 8, 2021
8e11a71
Update Url to wait before running tests
Mar 8, 2021
caf0005
Add composer install step
Mar 8, 2021
dac9c77
Update docker files
Mar 9, 2021
538f7f0
Add install test
Mar 9, 2021
f4216cd
Add working directory to install module step
Mar 9, 2021
76b5e5e
Fix Version on docker-compose.yml
Mar 9, 2021
dec0b1c
Give full permission to folder
Mar 9, 2021
eb1f934
Do not use composer action
Mar 11, 2021
11dd464
Ignore requirement error
Mar 11, 2021
609f98f
Fix permissions error
Mar 11, 2021
069d761
Delete unused function
Mar 11, 2021
c8ada94
Delete changes on twig
Mar 11, 2021
b095a39
Fix end of files
Mar 11, 2021
ef3122b
Move some steps to scripts
Mar 15, 2021
929ddef
Fix call for env var
Mar 15, 2021
d56a3e3
Use outputs instead of env vars
Mar 16, 2021
89ca880
FIx yaml file
Mar 16, 2021
1dd798d
fix call to docker script
Mar 16, 2021
86bf5bb
Fix scripts permissions
Mar 16, 2021
bbac7a0
Not adding FILENAME to github env
Mar 16, 2021
df41ebc
Add checkout actions to 'Upload nightly report' job
Mar 16, 2021
15d7928
Fix push results step
Mar 16, 2021
dbc5f1f
Fix push results script
Mar 16, 2021
ea9a7af
Push Target version on github env
Mar 17, 2021
45ca2bb
Get env var for get_ps_target_versions job
Mar 17, 2021
f32cbe0
Use outputs on all jobs
Mar 17, 2021
ad1b2c2
Moving scripts to tests/e2e folder
Mar 17, 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
Empty file modified .github/Dockerfile
100644 → 100755
Empty file.
193 changes: 193 additions & 0 deletions .github/workflows/e2e_nightly_upgrade.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
name: Nightly upgrades with user inferfaces

on:
push:
schedule:
- cron: "0 6 * * *" # Every day at 06:00Am

env:
reports_path: ./json-reports
combined_report_name: upgrade_tests.json

jobs:
# Pre-job : Get Upgrade target versions
get_ps_target_versions:
name: Get Upgrade target versions
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2

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

- name: Install dependencies
shell: bash
run: npm install
working-directory: ./tests/e2e

- id: set-target-versions
run: echo "TARGET_VERSIONS=$(node ./scripts/getTargetVersions.js)" >> $GITHUB_ENV
env:
API_URL: https://api-nightly.prestashop.com/reports
working-directory: ./tests/e2e


# First job: upgrade
upgrade:
name: Testing Autoupgrade module on UI
continue-on-error: true
needs: get_ps_target_versions
runs-on: ubuntu-18.04
env:
nightly_storage: https://storage.googleapis.com/prestashop-core-nightly

# Testing upgrade from '1.7.4.4', '1.7.5.2', '1.7.6.9', '1.7.7.1' to the last '1.7.7.x' and '1.7.8.x'(develop)
strategy:
matrix:
ps_start_version: ['1.7.4.4', '1.7.5.2', '1.7.6.9', '1.7.7.1']

ps_target_version: ${{ fromJson(env.TARGET_VERSIONS) }}

fail-fast: false

steps:

# Setup PrestaShop and Install Autoupgrade module
- uses: actions/checkout@v2

# Build PrestaShop with docker-compose
- uses: shivammathur/setup-php@v2
name: Setup PHP
with:
php-version: '7.1'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv

- name: Install Module dependencies
shell: bash
run: composer install

- name: Build PrestaShop ${{ matrix.ps_start_version }} on docker
env:
VERSION: ${{ matrix.ps_start_version }}
shell: bash
run : ./.github/workflows/e2e_tests/docker_build.sh

# Install Module with user interface
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 10

- name: Install dependencies
run: npm install
working-directory: ./tests/e2e

- name: Install autoupgrade module
run: npm run install-module
working-directory: ./tests/e2e
env:
URL_FO: "http://localhost:8001/"
PS_VERSION: ${{ matrix.ps_start_version }}

- name: Download nightly build
shell: bash
run: ./.github/workflows/e2e_tests/download_nightly_archive.sh ${{ env.ARCHIVE_URL }} ${{ env.FILENAME }}
env:
ARCHIVE_URL: ${{ matrix.ps_target_version.archive_zip }}
FILENAME: ${{ matrix.ps_target_version.filename }}


# Run Upgrade tests
- name: Run tests
run: npm run upgrade-test
working-directory: ./tests/e2e
env:
URL_FO: "http://localhost:8001/"
PS_VERSION: ${{ matrix.ps_start_version }}
PS_VERSION_UPGRADE_TO: ${{ matrix.ps_target_version.for_test }}
ZIP_NAME: ${{ matrix.ps_target_version.filename }}

- uses: actions/upload-artifact@v2
name: Upload failed screenshots
if: ${{ always() }}
with:
name: failed-steps-for-test-${{ matrix.ps_start_version }}-${{ matrix.ps_target_version.for_test }}
path: ./tests/e2e/screenshots/

# Upload Mochawesome reports
- name: Rename Mochawesome report
if: ${{ always() }}
run: ./.github/workflows/e2e_tests/copy_reports.sh ${{ env.reports_path }} ${{ matrix.ps_start_version }} ${{ matrix.ps_target_version.for_test }}

- uses: actions/upload-artifact@v2
name: Upload Mochawesome report
if: ${{ always() }}
with:
name: tests-reports
path: ${{ env.reports_path }}

# Second job: merge reports (depends on upgrade job)
merge-reports:
name: Combine all tests reports
needs: upgrade
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v2
name: Download reports
with:
name: tests-reports
path: ${{ env.reports_path }}

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Combine reports
shell: bash
run: ./.github/workflows/e2e_tests/combine_reports.sh ${{ env.reports_path }} ${{ env.combined_report_name }}

- uses: actions/upload-artifact@v2
name: Upload combined report
with:
name: combined-report
path: ${{ env.reports_path }}/${{ env.combined_report_name }}

# Third job: Upload report on GCP (Depends on merge-reports job)
upload-report:
name: Upload nightly report
needs: merge-reports
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v2
name: Download report
with:
name: combined-report
path: ${{ env.reports_path }}

- uses: google-github-actions/setup-gcloud@master
name: Setup Cloud Sdk
with:
project_id: ${{ secrets.GC_PROJECT_ID }}
service_account_key: ${{ secrets.GC_SERVICE_KEY }}
export_default_credentials: true

- name: Push result to the nightly board
shell: bash
run: |
export FILENAME=autoupgrade_ui_`date -u +"%Y-%m-%d"`.json
cp ${{ env.reports_path }}/${{ env.combined_report_name }} $FILENAME
./.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.com/hook/add
campaign: autoupgrade
platform: chromium
7 changes: 7 additions & 0 deletions .github/workflows/e2e_tests/combine_reports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

REPORTS_PATH=$1
COMBINE_REPORT_NAME=$2

# Run python script
./tests/e2e/scripts/combine-reports.py $REPORTS_PATH $REPORTS_PATH/$COMBINE_REPORT_NAME
8 changes: 8 additions & 0 deletions .github/workflows/e2e_tests/copy_reports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

REPORTS_PATH=$1
PS_START_VERSION=$2
PS_TARGET_VERSION=$3

mkdir -p $REPORTS_PATH
cp ./tests/e2e/mochawesome-report/mochawesome.json $REPORTS_PATH/upgrade-from-$PS_START_VERSION-to-$PS_TARGET_VERSION.json
4 changes: 4 additions & 0 deletions .github/workflows/e2e_tests/docker_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

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'
8 changes: 8 additions & 0 deletions .github/workflows/e2e_tests/download_nightly_archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

ARCHIVE_URL=$1
FILENAME=$2

docker exec -u www-data prestashop_autoupgrade mkdir -p admin-dev/autoupgrade/download
docker exec -u www-data prestashop_autoupgrade curl $ARCHIVE_URL -o admin-dev/autoupgrade/download/$FILENAME
docker exec -u root prestashop_autoupgrade chmod 777 -R /var/www/html
19 changes: 19 additions & 0 deletions .github/workflows/nightly_scripts/push_results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Nightly api URL
NIGHTLY_API_URL=$1

# Filename to upload
FILENAME=$2

# Name of tests campaign of nightly database
CAMPAIGN=$3

# Tests platform: chromium or cli
PLATFORM=$4

# Token for GCP
QANB_TOKEN=$5

gsutil cp $FILENAME gs://prestashop-core-nightly/reports
curl -X GET "$NIGHTLY_API_URL?filename=$FILENAME&platform=$PLATFORM&campaign=$CAMPAIGN&token=$QANB_TOKEN"
16 changes: 8 additions & 8 deletions .github/workflows/nigthly_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@ jobs:
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 }}
run: echo "ps_matrix=$(php ./.github/get_matrix.php)" >> $GITHUB_ENV
upgrade:
continue-on-error: true
needs: get_matrix
strategy:
fail-fast: false
matrix:
from: ['1.7.6.9', '1.7.7.0', '1.6.1.24']
ps-versions: ${{ fromJson(needs.get_matrix.outputs.matrix) }}
ps-versions: ${{ fromJson(env.ps_matrix) }}
runs-on: ubuntu-latest
name: Upgrade
outputs:
Expand Down Expand Up @@ -72,7 +70,9 @@ jobs:
export_default_credentials: true
- name: Push results to the nightly board
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 }}"
export FILENAME=autoupgrade_ui_`date -u +"%Y-%m-%d"`.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.com/hook/add
campaign: autoupgrade
platform: cli
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ services:
PS_ERASE_DB: 1
PS_FOLDER_ADMIN: admin-dev
PS_FOLDER_INSTALL: install-dev
PS_LANGUAGE: en
PS_COUNTRY: fr
depends_on:
- mysql
ports:
Expand Down
27 changes: 27 additions & 0 deletions tests/e2e/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
env: {
node: true,
es6: true,
mocha: true,
},
extends: [
'prestashop',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
rules: {
'no-plusplus': [2, {allowForLoopAfterthoughts: true}],
'func-names': 'off',
'no-await-in-loop': 'off',
'class-methods-use-this': 'off',
'max-len': [2, {code: 120}],
'no-underscore-dangle': 'off',
'no-shadow': 'off'
},
};
3 changes: 3 additions & 0 deletions tests/e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
*/node_modules
.idea
5 changes: 5 additions & 0 deletions tests/e2e/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"slow": 45000,
"timeout": 0,
"reporter": "mochawesome"
}
38 changes: 38 additions & 0 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Autoupgrade tests
Tests for 1 click upgrade module.

Test is compatible with different PS versions
- `1.7.4` to `1.7.5 - 1.7.6 - 1.7.7 - 1.7.8`
- `1.7.5` to `1.7.6 - 1.7.7 - 1.7.8`
- `1.7.6` to `1.7.7 - 1.7.8`
- `1.7.7` to `1.7.8`

We use [Mocha](https://mochajs.org/), [Playwright](https://github.com/microsoft/playwright) and
[Chai](https://www.chaijs.com/) as our base stack.

## How to install your environment

```bash
# Download the new PS version that you want to upgrade
https://www.prestashop.com/fr/versions-precedentes
cd autoupgrade_tests/
npm install
```

### Test parameters
| Parameter | Description |
|-----------------------|----------------- |
| URL_FO | URL of your PrestaShop website Front Office (default to **`http://localhost/prestashop/`**) |
| LOGIN | LOGIN of your PrestaShop website (default to **`demo@prestashop.com`**) |
| PASSWD | PASSWD of your PrestaShop website (default to **`prestashop_demo`**) |
| PS_VERSION | Your prestashop version (expl **`1.7.5`**) |
| PS_VERSION_UPGRADE_TO | The new version to upgrade (example **`1.7.7`**) |
| ZIP_NAME | The new version to upgrade zip name (example **`prestashop_1.7.7.0.zip`**) |

Before running upgrade test, you should install an old version of PS.

### Launch the script

`URL_FO=your_shop_url PS_VERSION=your_ps_version PS_VERSION_UPGRADE_TO=new_ps_version ZIP_NAME=zip_name.zip npm run upgrade-test`

Enjoy :wink: :v:
15 changes: 15 additions & 0 deletions tests/e2e/configClassMap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const path = require('path');

const basePath = path.resolve(__dirname);

module.exports = [
{
file: 'BO/modules/autoupgrade/index.js',
versions: {
'1.7.4': `${basePath}/pages/BO/modules/autoupgrade/index.js`,
'1.7.5': `${basePath}/pages/BO/modules/autoupgrade/index.js`,
'1.7.6': `${basePath}/pages/BO/modules/autoupgrade/index.js`,
'1.7.7': `${basePath}/pages/BO/modules/autoupgrade/index.js`,
},
},
];
7 changes: 7 additions & 0 deletions tests/e2e/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
global.PS_VERSION_UPGRADE_FROM = global.PS_VERSION;
global.PS_VERSION_UPGRADE_TO = process.env.PS_VERSION_UPGRADE_TO || '1.7.8';
global.PS_RESOLVER_VERSION = {
FROM: global.PS_VERSION.substr(0, global.PS_VERSION.lastIndexOf('.')),
TO: global.PS_VERSION_UPGRADE_TO.substr(0, global.PS_VERSION_UPGRADE_TO.lastIndexOf('.')),
};
global.ZIP_NAME = process.env.ZIP_NAME;
Loading