From e31501df8fad321afd239214d572c86ae31270ec Mon Sep 17 00:00:00 2001 From: Jonathan Lelievre Date: Mon, 25 Sep 2023 20:08:10 +0200 Subject: [PATCH] First step of autoupgrade is to fetch and install a target/branch --- .../actions/checkout-prestashop/action.yml | 44 ++++++++++----- .github/workflows/build-shop.yml | 50 +++++++++-------- .github/workflows/pr_test.yml | 2 +- .github/workflows/pr_test_single_campaign.yml | 2 +- .github/workflows/test-sanity.yml | 2 +- .github/workflows/upgrade_test.yml | 54 +++++++++++++++++++ 6 files changed, 115 insertions(+), 39 deletions(-) create mode 100644 .github/workflows/upgrade_test.yml diff --git a/.github/workflows/actions/checkout-prestashop/action.yml b/.github/workflows/actions/checkout-prestashop/action.yml index 82d972b1..115398df 100644 --- a/.github/workflows/actions/checkout-prestashop/action.yml +++ b/.github/workflows/actions/checkout-prestashop/action.yml @@ -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" @@ -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 }} @@ -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 diff --git a/.github/workflows/build-shop.yml b/.github/workflows/build-shop.yml index 0e1ff6c4..83c4ddba 100644 --- a/.github/workflows/build-shop.yml +++ b/.github/workflows/build-shop.yml @@ -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 @@ -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: @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/pr_test.yml b/.github/workflows/pr_test.yml index 3beb34af..e8f475cf 100644 --- a/.github/workflows/pr_test.yml +++ b/.github/workflows/pr_test.yml @@ -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 }} diff --git a/.github/workflows/pr_test_single_campaign.yml b/.github/workflows/pr_test_single_campaign.yml index aab523f5..ccfbef9f 100644 --- a/.github/workflows/pr_test_single_campaign.yml +++ b/.github/workflows/pr_test_single_campaign.yml @@ -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 }} diff --git a/.github/workflows/test-sanity.yml b/.github/workflows/test-sanity.yml index 7f76b6fa..0d0105a7 100644 --- a/.github/workflows/test-sanity.yml +++ b/.github/workflows/test-sanity.yml @@ -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 }} diff --git a/.github/workflows/upgrade_test.yml b/.github/workflows/upgrade_test.yml new file mode 100644 index 00000000..1528ff78 --- /dev/null +++ b/.github/workflows/upgrade_test.yml @@ -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 }}