Skip to content

Commit

Permalink
First step of autoupgrade is to fetch and install a target/branch
Browse files Browse the repository at this point in the history
  • Loading branch information
jolelievre committed Sep 25, 2023
1 parent 98c93cb commit e31501d
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 39 deletions.
44 changes: 31 additions & 13 deletions .github/workflows/actions/checkout-prestashop/action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: Checkout PrestaShop and prepare config
description: Checkout PrestaShop and prepare config
inputs:
pr_number:
description: Pull request Id
repository_ref:
description: Base branch/ref from the repository
required: true
base_branch:
description: Base branch to rebase the PR
ps_dir:
description: Directory target
required: true
pr_number:
description: Pull request Id
required: false
rebase_or_merge:
required: true
required: false
description: Rebase or merge the pull request
backoffice_layout:
description: Backoffice layout
required: true
ps_dir:
description: Directory target
required: true
required: false

runs:
using: "composite"
Expand All @@ -37,6 +37,7 @@ runs:

# Get the PR
- name: Get pull request
if: inputs.pr_number != ''
working-directory: ${{ inputs.ps_dir }}
run: |
git fetch origin pull/${{ inputs.pr_number }}/head:pr${{ inputs.pr_number }}
Expand All @@ -45,15 +46,32 @@ runs:

- name: Rebase
working-directory: ${{ inputs.ps_dir }}
if: ${{ inputs.rebase_or_merge == 'rebase' }}
if: inputs.pr_number != '' && inputs.rebase_or_merge == 'rebase'
run: |
git fetch origin ${{ inputs.repository_ref }}:${{ inputs.repository_ref }}
git rebase origin/${{ inputs.repository_ref }}
shell: bash

- name: Merge
working-directory: ${{ inputs.ps_dir }}
if: inputs.pr_number != '' && inputs.rebase_or_merge == 'merge'
run: |
git fetch origin ${{ inputs.repository_ref }}:${{ inputs.repository_ref }}
git merge origin/${{ inputs.repository_ref }}
shell: bash

# Or simply get the branch/tag
- name: Get ref from repository ${{ inputs.repository_ref }}
if: inputs.pr_number == '' && inputs.rebase_or_merge == ''
working-directory: ${{ inputs.ps_dir }}
run: |
git fetch origin ${{ inputs.base_branch }}:${{ inputs.base_branch }}
git rebase origin/${{ inputs.base_branch }}
git fetch origin ${{ inputs.repository_ref }}:${{ inputs.repository_ref }}
git checkout ${{ inputs.repository_ref }}
shell: bash

# Workaround until https://github.com/PrestaShop/PrestaShop/issues/29813 is fixed
- name: PrestaShop Configuration (Copy of Config API)
if: (inputs.base_branch == '8.1.x') || (inputs.base_branch == 'develop')
if: startsWith(inputs.repository_ref, '8.1') || (inputs.repository_ref == 'develop')
run: cp ./${{ inputs.ps_dir }}/app/config/security_test.yml ./${{ inputs.ps_dir }}/app/config/security_prod.yml
shell: bash

Expand Down
50 changes: 27 additions & 23 deletions .github/workflows/build-shop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,10 @@ name: Build PrestaShop and export sources and SQL dump as artifacts
on:
workflow_call:
inputs:
pr_number:
type: string
description: Pull request Id
required: true
base_branch:
repository_ref:
type: string
description: Base branch to rebase the PR
required: true
ps_mode_dev:
type: boolean
description: Enable/Disable the developer mode
required: true
rebase_or_merge:
type: string
required: true
description: Rebase or merge the pull request
php_version:
type: string
description: PHP version
Expand All @@ -26,10 +14,26 @@ on:
type: string
description: Node version
required: true
pr_number:
type: string
description: Pull request Id
required: false
default: ''
ps_mode_dev:
type: boolean
description: Enable/Disable the developer mode
required: false
default: false
rebase_or_merge:
type: string
required: false
description: Rebase or merge the pull request
default: ''
backoffice_layout:
type: string
description: Backoffice layout
required: true
required: false
default: 'legacy'

jobs:
build-shop-artifacts:
Expand All @@ -42,10 +46,10 @@ jobs:
PHP_VERSION: ${{ inputs.php_version }}
NODE_VERSION: ${{ inputs.node_version }}
VERSION: ${{ inputs.php_version }}-apache
PS_DOMAIN: ${{ ((inputs.base_branch == '8.0.x') || (inputs.base_branch == '1.7.8.x')) && 'localhost:8001' || 'localhost:8002' }}
PS_ENABLE_SSL: ${{ ((inputs.base_branch == '8.0.x') || (inputs.base_branch == '1.7.8.x')) && '0' || '1' }}
ADMIN_PASSWD: ${{ (inputs.base_branch == '1.7.8.x') && 'prestashop_demo' || 'Correct Horse Battery Staple' }}
URL_FO: ${{ ((inputs.base_branch == '8.0.x') || (inputs.base_branch == '1.7.8.x')) && 'http://localhost:8001/' || 'https://localhost:8002/' }}
PS_DOMAIN: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7.8')) && 'localhost:8001' || 'localhost:8002' }}
PS_ENABLE_SSL: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7.8')) && '0' || '1' }}
ADMIN_PASSWD: ${{ startsWith(inputs.repository_ref, '1.7.8') && 'prestashop_demo' || 'Correct Horse Battery Staple' }}
URL_FO: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7.8')) && 'http://localhost:8001/' || 'https://localhost:8002/' }}
# Fixed values
DB_USER: root
DB_PASSWD: prestashop
Expand Down Expand Up @@ -74,11 +78,11 @@ jobs:
- name: Checkout PrestaShop
uses: ./custom_actions/.github/workflows/actions/checkout-prestashop
with:
repository_ref: ${{ inputs.repository_ref }}
ps_dir: ${{ env.PS_DIR }}
pr_number: ${{ inputs.pr_number }}
base_branch: ${{ inputs.base_branch }}
rebase_or_merge: ${{ inputs.rebase_or_merge }}
backoffice_layout: ${{ inputs.backoffice_layout }}
ps_dir: ${{ env.PS_DIR }}

# Pre pull/build images
# For some reason keycloak must be started before the PrestaShop build or it fails
Expand Down Expand Up @@ -134,7 +138,7 @@ jobs:

# Certificate
- name: Generate a certificate
if: (inputs.base_branch == '8.1.x') || (inputs.base_branch == 'develop')
if: startsWith(inputs.repository_ref, '8.1') || inputs.repository_ref == 'develop'
run: |
## Install MkCert
sudo apt install libnss3-tools
Expand Down Expand Up @@ -175,8 +179,8 @@ jobs:
working-directory: ${{ env.PS_DIR }}
timeout-minutes: 5
env:
URL_FO: ${{ ((inputs.base_branch == '8.0.x') || (inputs.base_branch == '1.7.8.x')) && 'http://localhost:8001/' || 'https://localhost:8002/' }}
VERSION: ${{ (inputs.base_branch == '1.7.8.x') && inputs.php_version || env.VERSION }}
URL_FO: ${{ ((startsWith(inputs.repository_ref, '8.0')) || (startsWith(inputs.repository_ref, '1.7.8'))) && 'http://localhost:8001/' || 'https://localhost:8002/' }}
VERSION: ${{ (startsWith(inputs.repository_ref, '1.7.8')) && inputs.php_version || env.VERSION }}
# Initial build, install shop data but assets are already built
DISABLE_MAKE: 1
PS_INSTALL_AUTO: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
uses: ./.github/workflows/build-shop.yml
with:
pr_number: ${{ inputs.pr_number }}
base_branch: ${{ inputs.base_branch }}
repository_ref: ${{ inputs.base_branch }}
ps_mode_dev: ${{ inputs.ps_mode_dev }}
rebase_or_merge: ${{ inputs.rebase_or_merge }}
php_version: ${{ inputs.php_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr_test_single_campaign.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
uses: ./.github/workflows/build-shop.yml
with:
pr_number: ${{ inputs.pr_number }}
base_branch: ${{ inputs.base_branch }}
repository_ref: ${{ inputs.base_branch }}
ps_mode_dev: ${{ inputs.ps_mode_dev }}
rebase_or_merge: ${{ inputs.rebase_or_merge }}
php_version: ${{ inputs.php_version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-sanity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
- name: Checkout PrestaShop
uses: ./custom_actions/.github/workflows/actions/checkout-prestashop
with:
pr_number: ${{ inputs.pr_number }}
repository_ref: ${{ inputs.pr_number }}
base_branch: ${{ inputs.base_branch }}
rebase_or_merge: ${{ inputs.rebase_or_merge }}
backoffice_layout: ${{ inputs.backoffice_layout }}
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/upgrade_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Testing PrestaShop upgrade
on:
workflow_dispatch:
inputs:
source_ref:
type: choice
description: Use a source branch or tag to start the upgrade from
required: true
options:
- '8.1.x'
- '8.0.x'
- '1.7.8.x'
- '8.0.4'
- '1.7.8.9'
default: '8.0.x'
target_ref:
type: choice
description: Use a target branch or tag to upgrade to
required: true
options:
- 'develop'
- '8.1.x'
- '8.0.x'
- '8.0.4'
- '8.1.0'
default: '8.1.x'
php_version:
type: choice
description: PHP version
required: true
options:
- '7.3'
- '7.4'
- '8.0'
- '8.1'
- '8.2'
default: '8.1'
node_version:
type: choice
description: Node version
required: true
options:
- '14'
- '16'
default: '14'

jobs:
build-source:
name: Build source shop based on ref ${{ inputs.source_ref }}
uses: ./.github/workflows/build-shop.yml
with:
repository_ref: ${{ inputs.source_ref }}
php_version: ${{ inputs.php_version }}
node_version: ${{ inputs.node_version }}

0 comments on commit e31501d

Please sign in to comment.