diff --git a/.github/workflows/actions/run-tests/action.yml b/.github/workflows/actions/run-tests/action.yml index 7aed5a0b..034f5aa9 100644 --- a/.github/workflows/actions/run-tests/action.yml +++ b/.github/workflows/actions/run-tests/action.yml @@ -10,9 +10,6 @@ inputs: php_version: description: PHP version required: true - node_version: - description: Node version - required: true test_command: description: Test command to run required: true @@ -35,9 +32,6 @@ runs: # Input values PS_MODE_DEV: ${{ fromJson(inputs.ps_mode_dev) && '1' || '0' }} PS_DEV_MODE: ${{ fromJson(inputs.ps_mode_dev) && '1' || '0' }} - PHP_VERSION: ${{ inputs.php_version }} - NODE_VERSION: ${{ inputs.node_version }} - VERSION: ${{ inputs.php_version }}-apache PS_DOMAIN: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && 'localhost:8001' || 'localhost:8002' }} PS_ENABLE_SSL: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && '0' || '1' }} ADMIN_PASSWD: ${{ startsWith(inputs.repository_ref, '1.7') && 'prestashop_demo' || 'Correct Horse Battery Staple' }} diff --git a/.github/workflows/actions/setup-build-env/action.yml b/.github/workflows/actions/setup-build-env/action.yml new file mode 100644 index 00000000..41f59958 --- /dev/null +++ b/.github/workflows/actions/setup-build-env/action.yml @@ -0,0 +1,53 @@ +name: Setup env variables dynamically +description: Some environment variables are a bit complex to specify and can not be set with simple native functions from GA so we use this action to define them and force them in the Github environment +inputs: + repository_ref: + description: Base branch/ref from the repository + required: true + php_version: + description: PHP version + required: true + +runs: + using: "composite" + steps: + - name: Set dynamic environment variables + run: | + function version { printf "%03d%03d%03d%03d" $(echo "$1" | sed s/x/999/ | tr '.' ' '); } + if [ $(version $repository_ref) -lt $(version 1.7.7) ]; then + echo Version under 1.7.7 use Node 8 + nodeVersion=8 + elif [ $(version $repository_ref) -lte $(version 1.7.7.x) ]; then + echo Version 1.7.7 uses Node 10 + nodeVersion=10 + elif [ $(version $repository_ref) -lte $(version 1.7.8.x) ]; then + echo Version 1.7.8 uses Node 14 + nodeVersion=14 + else + echo Versions after 1.7.8 use Node 16 + nodeVersion=16 + fi + echo "NODE_VERSION=$nodeVersion" >> $GITHUB_ENV + + phpVersion=${{ inputs.php_version }} + if [ $(version $repository_ref) -lte $(version 1.7.4.x) ] && [ $(version $phpVersion) -gt $(version 7.1.x) ]; then + echo Max PHP version for PrestaShop lower than 1.7.4 is 7.1 + phpVersion=7.1 + elif [ $(version $repository_ref) -lte $(version 1.7.6.x) ] && [ $(version $phpVersion) -gt $(version 7.2.x) ]; then + echo Max PHP version for PrestaShop 1.7.5 and 1.7.6 is 7.2 + phpVersion=7.2 + elif [ $(version $repository_ref) -lte $(version 1.7.7.x) ] && [ $(version $phpVersion) -gt $(version 7.3.x) ]; then + echo Max PHP version for PrestaShop 1.7.7 is 7.3 + phpVersion=7.3 + elif [ $(version $repository_ref) -lte $(version 1.7.8.x) ] && [ $(version $phpVersion) -gt $(version 7.4.x) ]; then + echo Max PHP version for PrestaShop 1.7.8 is 7.4 + phpVersion=7.3 + elif [ $(version $repository_ref) -lte $(version 8.1.x) ] && [ $(version $phpVersion) -gt $(version 8.1.x) ]; then + echo Max PHP version for PrestaShop 8.0 and 8.1 is 8.1 + phpVersion=8.1 + fi + + echo "PHP_VERSION=$phpVersion" >> $GITHUB_ENV + # Docker version to use based on PHP versions + echo "VERSION=$phpVersion-apache" >> $GITHUB_ENV + shell: bash diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 21c72979..6e518a43 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -15,10 +15,6 @@ on: type: string description: PHP version required: true - node_version: - type: string - description: Node version - required: true jobs: build-target: @@ -31,6 +27,11 @@ jobs: - uses: actions/checkout@v3 with: path: custom_actions + - name: Setup PrestaShop build env variables + uses: ./custom_actions/.github/workflows/actions/setup-build-env + with: + repository_ref: ${{ inputs.target_ref }} + php_version: ${{ inputs.php_version }} - name: Checkout PrestaShop uses: ./custom_actions/.github/workflows/actions/checkout-prestashop @@ -38,10 +39,10 @@ jobs: repository_ref: ${{ inputs.target_ref }} ps_dir: ${{ env.PS_TARGET }} - - name: Setup Node ${{ inputs.node_version }} + - name: Setup Node ${{ env.NODE_VERSION }} uses: actions/setup-node@v3 with: - node-version: ${{ inputs.node_version }} + node-version: ${{ env.NODE_VERSION }} - name: Build release working-directory: ${{ env.PS_TARGET }} diff --git a/.github/workflows/build-shop.yml b/.github/workflows/build-shop.yml index 43d1f08b..e0c4f29d 100644 --- a/.github/workflows/build-shop.yml +++ b/.github/workflows/build-shop.yml @@ -10,10 +10,6 @@ on: type: string description: PHP version required: true - node_version: - type: string - description: Node version - required: true pr_number: type: string description: Pull request Id @@ -48,9 +44,6 @@ jobs: # Input values PS_MODE_DEV: ${{ inputs.ps_mode_dev && '1' || '0' }} PS_DEV_MODE: ${{ inputs.ps_mode_dev && '1' || '0' }} - PHP_VERSION: ${{ inputs.php_version }} - NODE_VERSION: ${{ inputs.node_version }} - VERSION: ${{ inputs.php_version }}-apache PS_DOMAIN: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && 'localhost:8001' || 'localhost:8002' }} PS_ENABLE_SSL: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && '0' || '1' }} ADMIN_PASSWD: ${{ startsWith(inputs.repository_ref, '1.7') && 'prestashop_demo' || 'Correct Horse Battery Staple' }} @@ -79,6 +72,11 @@ jobs: - uses: actions/checkout@v3 with: path: custom_actions + - name: Setup PrestaShop build env variables + uses: ./custom_actions/.github/workflows/actions/setup-build-env + with: + repository_ref: ${{ inputs.repository_ref }} + php_version: ${{ inputs.php_version }} - name: Checkout PrestaShop uses: ./custom_actions/.github/workflows/actions/checkout-prestashop @@ -128,10 +126,10 @@ jobs: key: ${{ steps.composer-cache.outputs.cache-primary-key }} # Install node dependencies and build assets - - name: Setup Node ${{ inputs.node_version }} + - name: Setup Node ${{ env.NODE_VERSION }} uses: actions/setup-node@v3 with: - node-version: ${{ inputs.node_version }} + node-version: ${{ env.NODE_VERSION }} - name: Build assets in parallel and in background run: | (pushd ${{ env.PS_DIR }}/admin-dev/themes/new-theme; touch buildLock; npm ci; npm run build; rm buildLock; popd) & @@ -184,7 +182,7 @@ jobs: timeout-minutes: 5 env: URL_FO: ${{ ((startsWith(inputs.repository_ref, '8.0')) || (startsWith(inputs.repository_ref, '1.7'))) && 'http://localhost:8001/' || 'https://localhost:8002/' }} - VERSION: ${{ (startsWith(inputs.repository_ref, '1.7')) && inputs.php_version || env.VERSION }} + 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 9898ec70..aaef64f0 100644 --- a/.github/workflows/pr_test.yml +++ b/.github/workflows/pr_test.yml @@ -51,14 +51,6 @@ on: - '8.1' - '8.2' default: '8.1' - node_version: - type: choice - description: Node version - required: true - options: - - '14.21.3' - - '16.20.1' - default: '14.21.3' jobs: # Sanity tests are run independently because it's the only campaign that handles the installation itself, since it tests it @@ -71,7 +63,6 @@ jobs: ps_mode_dev: ${{ inputs.ps_mode_dev }} rebase_or_merge: ${{ inputs.rebase_or_merge }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} backoffice_layout: ${{ inputs.backoffice_layout }} fast_fail: ${{ inputs.fast_fail }} @@ -85,7 +76,6 @@ jobs: ps_mode_dev: ${{ inputs.ps_mode_dev }} rebase_or_merge: ${{ inputs.rebase_or_merge }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} backoffice_layout: ${{ inputs.backoffice_layout }} # These campaigns are run first because they are longer, so we try to optimize the total run However this list must not @@ -99,7 +89,6 @@ jobs: repository_ref: ${{ inputs.base_branch }} ps_mode_dev: ${{ inputs.ps_mode_dev }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} test_command: ${{ matrix.TEST_COMMAND }} fast_fail: ${{ inputs.fast_fail }} strategy: @@ -135,7 +124,6 @@ jobs: repository_ref: ${{ inputs.base_branch }} ps_mode_dev: ${{ inputs.ps_mode_dev }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} test_command: ${{ matrix.TEST_COMMAND }} fast_fail: ${{ inputs.fast_fail }} strategy: diff --git a/.github/workflows/pr_test_single_campaign.yml b/.github/workflows/pr_test_single_campaign.yml index 4a9933f0..c0d0e5bc 100644 --- a/.github/workflows/pr_test_single_campaign.yml +++ b/.github/workflows/pr_test_single_campaign.yml @@ -99,14 +99,6 @@ on: - '8.1' - '8.2' default: '8.1' - node_version: - type: choice - description: Node version - required: true - options: - - '14.21.3' - - '16.20.1' - default: '14.21.3' jobs: build-shop: @@ -119,7 +111,6 @@ jobs: ps_mode_dev: ${{ inputs.ps_mode_dev }} rebase_or_merge: ${{ inputs.rebase_or_merge }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} backoffice_layout: ${{ inputs.backoffice_layout }} test-pr: @@ -131,7 +122,6 @@ jobs: repository_ref: ${{ inputs.base_branch }} ps_mode_dev: ${{ inputs.ps_mode_dev }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} test_command: ${{ inputs.test_command }} fast_fail: ${{ inputs.fast_fail }} @@ -146,6 +136,5 @@ jobs: ps_mode_dev: ${{ inputs.ps_mode_dev }} rebase_or_merge: ${{ inputs.rebase_or_merge }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} backoffice_layout: ${{ inputs.backoffice_layout }} fast_fail: ${{ inputs.fast_fail }} diff --git a/.github/workflows/test-sanity.yml b/.github/workflows/test-sanity.yml index 60391f76..4cbe86b3 100644 --- a/.github/workflows/test-sanity.yml +++ b/.github/workflows/test-sanity.yml @@ -22,10 +22,6 @@ on: type: string description: PHP version required: true - node_version: - type: string - description: Node version - required: true backoffice_layout: type: string description: Backoffice layout @@ -44,9 +40,6 @@ jobs: # Input values PS_MODE_DEV: ${{ inputs.ps_mode_dev && '1' || '0' }} PS_DEV_MODE: ${{ inputs.ps_mode_dev && '1' || '0' }} - PHP_VERSION: ${{ inputs.php_version }} - NODE_VERSION: ${{ inputs.node_version }} - VERSION: ${{ inputs.php_version }}-apache PS_DOMAIN: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && 'localhost:8001' || 'localhost:8002' }} PS_ENABLE_SSL: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && '0' || '1' }} ADMIN_PASSWD: ${{ startsWith(inputs.repository_ref, '1.7') && 'prestashop_demo' || 'Correct Horse Battery Staple' }} @@ -72,6 +65,11 @@ jobs: - uses: actions/checkout@v3 with: path: custom_actions + - name: Setup PrestaShop build env variables + uses: ./custom_actions/.github/workflows/actions/setup-build-env + with: + repository_ref: ${{ inputs.repository_ref }} + php_version: ${{ inputs.php_version }} - name: Checkout PrestaShop uses: ./custom_actions/.github/workflows/actions/checkout-prestashop @@ -145,7 +143,7 @@ jobs: timeout-minutes: 15 env: URL_FO: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && 'http://localhost:8001/' || 'https://localhost:8002/' }} - VERSION: ${{ startsWith(inputs.repository_ref, '1.7') && inputs.php_version || env.VERSION }} + VERSION: ${{ env.VERSION }} # No assets built, already done and no install since the campaign handles it DISABLE_MAKE: 1 PS_INSTALL_AUTO: 0 @@ -159,10 +157,10 @@ jobs: USER_ID=$(id -u) GROUP_ID=$(id -g) docker-compose -f docker-compose.yml up -d --build prestashop-git mysql # Install node dependencies and build assets - - name: Setup Node ${{ inputs.node_version }} + - name: Setup Node ${{ env.NODE_VERSION }} uses: actions/setup-node@v3 with: - node-version: ${{ inputs.node_version }} + node-version: ${{ env.NODE_VERSION }} - name: Build assets in parallel and in background run: | (pushd ${{ env.PS_DIR }}/tests/UI; touch buildLock; npm ci; npm run build; rm buildLock; popd) & @@ -202,7 +200,6 @@ jobs: repository_ref: ${{ inputs.repository_ref }} ps_mode_dev: ${{ inputs.ps_mode_dev }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} test_command: sanity fast_fail: ${{ inputs.fast_fail }} ps_dir: ${{ env.PS_DIR }} diff --git a/.github/workflows/test-with-prebuilt-shop.yml b/.github/workflows/test-with-prebuilt-shop.yml index 10dfaee1..7c850f3e 100644 --- a/.github/workflows/test-with-prebuilt-shop.yml +++ b/.github/workflows/test-with-prebuilt-shop.yml @@ -14,10 +14,6 @@ on: type: string description: PHP version required: true - node_version: - type: string - description: Node version - required: true test_command: type: string description: Test command to run @@ -41,9 +37,6 @@ jobs: # Input values PS_MODE_DEV: ${{ inputs.ps_mode_dev && '1' || '0' }} PS_DEV_MODE: ${{ inputs.ps_mode_dev && '1' || '0' }} - PHP_VERSION: ${{ inputs.php_version }} - NODE_VERSION: ${{ inputs.node_version }} - VERSION: ${{ inputs.php_version }}-apache PS_DOMAIN: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && 'localhost:8001' || 'localhost:8002' }} PS_ENABLE_SSL: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && '0' || '1' }} ADMIN_PASSWD: ${{ startsWith(inputs.repository_ref, '1.7') && 'prestashop_demo' || 'Correct Horse Battery Staple' }} @@ -69,6 +62,11 @@ jobs: - uses: actions/checkout@v3 with: path: custom_actions + - name: Setup PrestaShop build env variables + uses: ./custom_actions/.github/workflows/actions/setup-build-env + with: + repository_ref: ${{ inputs.repository_ref }} + php_version: ${{ inputs.php_version }} - name: Download docker artifacts id: download-shop @@ -143,7 +141,7 @@ jobs: working-directory: ${{ env.PS_DIR }} timeout-minutes: 5 env: - VERSION: ${{ startsWith(inputs.repository_ref, '1.7') && inputs.php_version || env.VERSION }} + VERSION: ${{ env.VERSION }} URL_FO: ${{ (startsWith(inputs.repository_ref, '8.0') || startsWith(inputs.repository_ref, '1.7')) && 'http://localhost:8001/' || 'https://localhost:8002/' }} # No install we force the sources and load the SQL dump PS_INSTALL_AUTO: 0 @@ -163,10 +161,10 @@ jobs: # Test dependencies are installed manually in each sub job that test the build, it could have been integrated inside the archive to reduce time here # but it turns out the archive is much bigger with all this code and it makes upload/download phase so much longer that it is more efficient to install # this here - - name: Setup Node ${{ inputs.node_version }} + - name: Setup Node ${{ env.NODE_VERSION }} uses: actions/setup-node@v3 with: - node-version: ${{ inputs.node_version }} + node-version: ${{ env.NODE_VERSION }} - name: Build test dependencies working-directory: ${{ env.PS_DIR }}/tests/UI run: | @@ -183,7 +181,6 @@ jobs: repository_ref: ${{ inputs.repository_ref }} ps_mode_dev: ${{ inputs.ps_mode_dev }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} test_command: ${{ inputs.test_command }} fast_fail: ${{ inputs.fast_fail }} ps_dir: ${{ env.PS_DIR }} diff --git a/.github/workflows/upgrade-shop.yml b/.github/workflows/upgrade-shop.yml index f9c61907..5cefe605 100644 --- a/.github/workflows/upgrade-shop.yml +++ b/.github/workflows/upgrade-shop.yml @@ -26,10 +26,6 @@ on: type: string description: PHP version required: true - node_version: - type: string - description: Node version - required: true upgrade_module_pr_number: type: string description: Autoupgrade module Pull request Id @@ -44,9 +40,6 @@ jobs: # Input values PS_MODE_DEV: ${{ inputs.ps_mode_dev && '1' || '0' }} PS_DEV_MODE: ${{ inputs.ps_mode_dev && '1' || '0' }} - PHP_VERSION: ${{ inputs.php_version }} - NODE_VERSION: ${{ inputs.node_version }} - VERSION: ${{ inputs.php_version }}-apache PS_DOMAIN: ${{ (startsWith(inputs.source_ref, '8.0') || startsWith(inputs.source_ref, '1.7')) && 'localhost:8001' || 'localhost:8002' }} PS_ENABLE_SSL: ${{ (startsWith(inputs.source_ref, '8.0') || startsWith(inputs.source_ref, '1.7')) && '0' || '1' }} ADMIN_PASSWD: ${{ startsWith(inputs.source_ref, '1.7') && 'prestashop_demo' || 'Correct Horse Battery Staple' }} @@ -68,6 +61,11 @@ jobs: - uses: actions/checkout@v3 with: path: custom_actions + - name: Setup PrestaShop build env variables + uses: ./custom_actions/.github/workflows/actions/setup-build-env + with: + repository_ref: ${{ inputs.source_ref }} + php_version: ${{ inputs.php_version }} - name: Download docker artifacts id: download-shop @@ -128,7 +126,7 @@ jobs: working-directory: ${{ env.PS_DIR }} timeout-minutes: 5 env: - VERSION: ${{ (startsWith(inputs.source_ref, '1.7')) && inputs.php_version || env.VERSION }} + VERSION: ${{ env.VERSION }} URL_FO: ${{ ((startsWith(inputs.source_ref, '8.0')) || (startsWith(inputs.source_ref, '1.7'))) && 'http://localhost:8001/' || 'https://localhost:8002/' }} # No install we force the sources and load the SQL dump PS_INSTALL_AUTO: 0 diff --git a/.github/workflows/upgrade_test.yml b/.github/workflows/upgrade_test.yml index f182f9f0..0eb9ead4 100644 --- a/.github/workflows/upgrade_test.yml +++ b/.github/workflows/upgrade_test.yml @@ -64,14 +64,6 @@ on: - '8.1' - '8.2' default: '8.1' - node_version: - type: choice - description: Node version - required: true - options: - - '14' - - '16' - default: '14' jobs: build-source: @@ -81,7 +73,6 @@ jobs: repository_ref: ${{ inputs.source_ref }} ps_mode_dev: ${{ inputs.ps_mode_dev }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} artifact_name: source_shop build-target: @@ -90,7 +81,6 @@ jobs: with: target_ref: ${{ inputs.target_ref }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} artifact_name: target_shop upgrade-shop: @@ -105,7 +95,6 @@ jobs: source_artifact: source_shop target_artifact: target_shop php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} test-upgraded-shop: name: Run UI tests from ${{ inputs.target_ref }} @@ -115,7 +104,6 @@ jobs: repository_ref: ${{ inputs.target_ref }} ps_mode_dev: ${{ inputs.ps_mode_dev }} php_version: ${{ inputs.php_version }} - node_version: ${{ inputs.node_version }} test_command: ${{ matrix.TEST_COMMAND }} artifact_name: upgraded_shop strategy: