Upgrade UI tests #1969
This file contains hidden or 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
| name: Upgrade UI tests | |
| on: | |
| ## Check each PR | |
| push: | |
| branches: | |
| - dev | |
| - master | |
| pull_request: | |
| ## Manual execution on branch | |
| workflow_dispatch: | |
| ## Nightly | |
| ### Needs secrets | |
| #### GC_PROJECT_ID | |
| #### GC_SERVICE_KEY | |
| #### NIGHTLY_TOKEN | |
| schedule: | |
| - cron: '0 0 * * *' | |
| env: | |
| CAMPAIGN: 'autoupgrade' | |
| jobs: | |
| ui_test_matrix: | |
| if: github.event.pull_request.draft == false | |
| name: Update UI - Generate Matrix | |
| runs-on: ubuntu-latest | |
| env: | |
| JSON_FILE: ${{ (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.event.pull_request.head.ref == 'dev' && github.event.pull_request.base.ref == 'master')) && 'nightly-ui.json' || 'pr-ui.json' }} | |
| outputs: | |
| matrix: ${{ steps.set-matrix.outputs.matrix }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Set matrix | |
| id: set-matrix | |
| run: echo "matrix=$(jq -c '. | del(.include[] | select(has("comment")))' .github/workflows/ui-test/${{ env.JSON_FILE }})" >> $GITHUB_OUTPUT | |
| ui_test: | |
| name: Upgrade UI | |
| runs-on: ubuntu-latest | |
| needs: ui_test_matrix | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJSON(needs.ui_test_matrix.outputs.matrix) }} | |
| env: | |
| PS_DOCKER: ${{ matrix.PS_VERSION_START }}-${{ matrix.PHP_VERSION }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Start containers | |
| working-directory: tests/UI/ | |
| env: | |
| PS_VERSION: ${{ env.PS_DOCKER }} | |
| run: | | |
| docker compose -f "docker-compose.yml" up -d --build | |
| bash -c 'while [[ "$(curl -L -s -o /dev/null -w %{http_code} http://localhost/)" != "200" ]]; do sleep 5; done' | |
| - name: Composer install | |
| run: composer install | |
| - name: Backup | |
| run: | | |
| docker exec -t prestashop php modules/autoupgrade/bin/console backup:create admin-dev | |
| - name: Get URLs of PrestaShop zip and xml | |
| if: matrix.UPGRADE_CHANNEL == 'local' | |
| id: links | |
| run: | | |
| wget -O prestashop_releases.json https://api.prestashop-project.org/prestashop | |
| echo "zip=$(jq -r '. | map(select(.version | test("${{ matrix.PS_VERSION_END }}")))[0].zip_download_url' prestashop_releases.json)" >> $GITHUB_OUTPUT | |
| echo "xml=$(jq -r '. | map(select(.version | test("${{ matrix.PS_VERSION_END }}")))[0].xml_download_url' prestashop_releases.json)" >> $GITHUB_OUTPUT | |
| - name: Download local ZIP and XML for local channel | |
| if: matrix.UPGRADE_CHANNEL == 'local' | |
| run: | | |
| docker exec -t prestashop curl --fail -L ${{ steps.links.outputs.zip }} -o admin-dev/autoupgrade/download/prestashop_${{ matrix.PS_VERSION_END }}.zip | |
| docker exec -t prestashop curl --fail -L ${{ steps.links.outputs.xml }} -o admin-dev/autoupgrade/download/prestashop_${{ matrix.PS_VERSION_END }}.xml | |
| - name: Install and build npm dependencies | |
| run: | | |
| npm install --prefix ./_dev | |
| npm run vite:build --prefix ./_dev | |
| docker exec -t prestashop chmod 777 -R /var/www/html/admin-dev/autoupgrade | |
| docker exec -t prestashop chmod 777 -R /var/www/html/modules | |
| - name: Install Update assistant module for PS version < 1.7.4 | |
| if: startsWith(matrix.PS_VERSION_START, '1.7.3') || | |
| startsWith(matrix.PS_VERSION_START, '1.7.2') || | |
| startsWith(matrix.PS_VERSION_START, '1.7.1') || | |
| startsWith(matrix.PS_VERSION_START, '1.7.0') | |
| run: | | |
| docker exec -t prestashop /usr/local/bin/install-update.sh | |
| - name: Install Update assistant module for PS version > 1.7.3 | |
| if: > | |
| startsWith(matrix.PS_VERSION_START, '1.7') && | |
| !( | |
| startsWith(matrix.PS_VERSION_START, '1.7.0') || | |
| startsWith(matrix.PS_VERSION_START, '1.7.1') || | |
| startsWith(matrix.PS_VERSION_START, '1.7.2') || | |
| startsWith(matrix.PS_VERSION_START, '1.7.3') | |
| ) | |
| run: | | |
| docker exec -t prestashop php bin/console prestashop:module install autoupgrade | |
| docker exec -t prestashop chmod 777 -R /var/www/html/var/cache | |
| - name: Setup node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20.x' | |
| - name: Install dependencies | |
| working-directory: tests/UI/ | |
| run: npm ci | |
| - name: Install Playwright Browsers | |
| working-directory: tests/UI/ | |
| run: npx playwright install chromium --with-deps | |
| - name: Upgrade online channel | |
| if: matrix.UPGRADE_CHANNEL == 'online' | |
| working-directory: tests/UI/ | |
| env: | |
| URL_FO: 'http://localhost/' | |
| PASSWD: 'prestashop' | |
| PS_VERSION: ${{ matrix.PS_VERSION_START }} | |
| DB_USER: prestashop | |
| DB_PASSWD: prestashop | |
| DB_NAME: prestashop | |
| DB_PREFIX: ps_ | |
| run: npm run test:upgradeOnline | |
| - name: Upgrade local channel | |
| if: matrix.UPGRADE_CHANNEL == 'local' | |
| working-directory: tests/UI/ | |
| env: | |
| URL_FO: 'http://localhost/' | |
| PASSWD: 'prestashop' | |
| PS_VERSION: ${{ matrix.PS_VERSION_START }} | |
| PS_VERSION_END: ${{ matrix.PS_VERSION_END }} | |
| DB_USER: prestashop | |
| DB_PASSWD: prestashop | |
| DB_NAME: prestashop | |
| DB_PREFIX: ps_ | |
| run: npm run test:upgradeLocal | |
| - name: Get PS version | |
| run: | | |
| echo "PS_VERSION_DB=$(docker exec --tty prestashop-mysql sh -c "mysql -pprestashop prestashop -e \"select value from ps_configuration where name LIKE 'PS_VERSION_DB'\" 2>&1 | grep '[0-9]' | tr -d [:space:]")" >> "$GITHUB_ENV" | |
| - name: Run Sanity tests | |
| working-directory: tests/UI/ | |
| env: | |
| URL_FO: 'http://localhost/' | |
| PASSWD: 'prestashop' | |
| PS_VERSION: ${{ env.PS_VERSION_DB }} | |
| DB_USER: prestashop | |
| DB_PASSWD: prestashop | |
| DB_NAME: prestashop | |
| DB_PREFIX: ps_ | |
| run: npm run test:sanity | |
| - name: Export Docker errors | |
| working-directory: tests/UI/ | |
| if: always() | |
| run: docker compose logs --no-color >& docker-compose.log | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| if: always() | |
| with: | |
| name: playwright-report-${{ matrix.PS_VERSION_START }}-${{ matrix.PS_VERSION_END }}-${{ matrix.UPGRADE_CHANNEL }}-${{ matrix.PHP_VERSION }} | |
| path: | | |
| tests/UI/reports/ | |
| tests/UI/report.json | |
| tests/UI/docker-compose.log | |
| retention-days: 30 | |
| nightly: | |
| name: Nightly Report | |
| if: ${{ github.event_name == 'schedule' && always() }} | |
| needs: | |
| - ui_test_matrix | |
| - ui_test | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: ${{ fromJSON(needs.ui_test_matrix.outputs.matrix) }} | |
| permissions: | |
| contents: 'read' | |
| id-token: 'write' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download report | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: playwright-report-${{ matrix.PS_VERSION_START }}-${{ matrix.PS_VERSION_END }}-${{ matrix.UPGRADE_CHANNEL }}-${{ matrix.PHP_VERSION }} | |
| path: tests/UI/ | |
| # Nightly : Rename file | |
| - name: "Nightly : Rename file" | |
| working-directory: tests/UI/ | |
| run: | | |
| mkdir -p nightly | |
| REPORT_NAME="${{ env.CAMPAIGN }}_$(date +%Y-%m-%d)-${{ matrix.PS_VERSION_START }}_(Channel:_${{ matrix.UPGRADE_CHANNEL }}_PHP:_${{ matrix.PHP_VERSION }})" | |
| mv report.json nightly/${REPORT_NAME}.json | |
| # Nightly : Auth GCP | |
| - name: "Nightly : Auth GCP" | |
| uses: google-github-actions/auth@v3 | |
| with: | |
| credentials_json: ${{ secrets.GC_SERVICE_KEY }} | |
| project_id: ${{ secrets.GC_PROJECT_ID }} | |
| # Nightly : Setup GCP | |
| - name: "Nightly : Setup GCP" | |
| uses: google-github-actions/setup-gcloud@v3 | |
| # Nightly : Upload to Google Cloud Storage (GCS) | |
| - name: "Nightly : Upload to Google Cloud Storage (GCS)" | |
| working-directory: tests/UI/ | |
| run: gsutil cp -r "nightly/**" gs://prestashop-core-nightly/reports | |
| # Nightly : Push Report | |
| - name: "Nightly : Push Report" | |
| run: | | |
| REPORT_NAME="${{ env.CAMPAIGN }}_$(date +%Y-%m-%d)-${{ matrix.PS_VERSION_START }}_(Channel:_${{ matrix.UPGRADE_CHANNEL }}_PHP:_${{ matrix.PHP_VERSION }})" | |
| curl -v "https://api-nightly.prestashop-project.org/import/report/playwright?token=${{ secrets.NIGHTLY_TOKEN }}&filename=${REPORT_NAME}.json&campaign=${{ env.CAMPAIGN }}&platform=cli" |