[0007928] Harden Pay upon Invoice (PUI) against `DEVICE_DATA_NOT_AVAI… #3771
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: Development | |
| on: [ push, pull_request ] | |
| env: | |
| PACKAGE_NAME: 'oxid-solution-catalysts/paypal-module' | |
| CLIENT_PACKAGE_NAME: 'oxid-solution-catalysts/paypal-client' | |
| CLIENT_REPO_NAME: 'https://github.com/OXID-eSales/paypal-client.git' | |
| MODULE_PATH: 'osc/paypal' | |
| SONARCLOUD_ORGANIZATION: 'oxid-esales' | |
| SONARCLOUD_PROJECT_KEY: 'OXID-eSales_module-paypal_checkout' | |
| PHP_VERSION: '8.0' | |
| MYSQL_VERSION: '5.7' | |
| TEMPLATE_ENGINE: 'twig' | |
| jobs: | |
| install_shop_with_module: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Print run parameters | |
| run: | | |
| echo "Running job with:\ | |
| PHP version: ${{ env.PHP_VERSION }}\ | |
| MySQL version: ${{ env.MYSQL_VERSION }}\ | |
| Template engine: ${{ env.TEMPLATE_ENGINE }}\ | |
| Trigger event: ${{ github.event_name }}" | |
| - name: Cleanup workspace | |
| run: | | |
| ls -la ./ | |
| sudo rm -rf ./* || true | |
| sudo rm -rf ./.??* || true | |
| ls -la ./ | |
| - name: Clone testing environment | |
| run: git clone https://github.com/OXID-eSales/docker-eshop-sdk.git . | |
| - name: Clone the shop | |
| run: git clone --depth 1 https://github.com/OXID-eSales/oxideshop_ce.git --branch b-7.0.x --single-branch source | |
| - name: Download detagen | |
| run: | | |
| git clone --depth 1 https://${{ secrets.DATGEN_GH_TOKEN }}@github.com/OXID-eSales/datagen.git source/extensions/datagen --branch=b-7.0.x | |
| - name: Cache current installation | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ./* | |
| key: installation-${{ env.PHP_VERSION }}-${{ env.MYSQL_VERSION }}-${{ env.TEMPLATE_ENGINE }}-${{ github.run_number }}-${{ github.run_attempt }} | |
| - name: Prepare container configuration | |
| run: | | |
| make setup | |
| make addbasicservices | |
| perl -pi\ | |
| -e 's#PHP_VERSION=.*#PHP_VERSION=${{ env.PHP_VERSION }}#g;'\ | |
| -e "s#MYSQL_VERSION=.*#MYSQL_VERSION=${{ env.MYSQL_VERSION }}#g;"\ | |
| .env | |
| perl -pi\ | |
| -e 's#display_errors =.*#display_errors = false#g;'\ | |
| -e 's#error_reporting = .*#error_reporting = E_ALL ^ E_WARNING ^ E_DEPRECATED#g;'\ | |
| -e 'print "xdebug.max_nesting_level=1000\nxdebug.mode=coverage\n\n"'\ | |
| containers/php/custom.ini | |
| perl -pi\ | |
| -e 's#/var/www/#/var/www/source/#g;'\ | |
| containers/httpd/project.conf | |
| - name: Prepare shop configuration | |
| run: | | |
| cp source/source/config.inc.php.dist source/source/config.inc.php | |
| sed -i "1s+^+SetEnvIf Authorization "\(.*\)" HTTP_AUTHORIZATION=\$1\n\n+" source/source/.htaccess | |
| sed -i -e 's/<dbHost>/mysql/'\ | |
| -e 's/<dbUser>/root/'\ | |
| -e 's/<dbName>/example/'\ | |
| -e 's/<dbPwd>/root/'\ | |
| -e 's/<dbPort>/3306/'\ | |
| -e 's/<sShopURL>/https:\/\/${{ secrets.NGROK_CUSTOM_DOMAIN }}\//'\ | |
| -e 's/<sShopDir>/\/var\/www\/source\//'\ | |
| -e 's/<sCompileDir>/\/var\/www\/source\/tmp\//'\ | |
| source/source/config.inc.php | |
| - name: Start containers | |
| run: | | |
| make up | |
| sleep 2 | |
| - name: Checkout current module | |
| uses: actions/checkout@v3 | |
| with: | |
| path: source/test-module | |
| - name: Install module | |
| run: | | |
| docker compose exec -T \ | |
| php composer config repositories.${{ env.PACKAGE_NAME }} \ | |
| --json '{"type":"path", "url":"./test-module", "options": {"symlink": true}}' | |
| docker compose exec -T \ | |
| php composer require ${{ env.PACKAGE_NAME }}:* --no-interaction --no-update | |
| docker compose exec -T \ | |
| php composer require ${{ env.CLIENT_PACKAGE_NAME }}:dev-b-7.0.x --no-interaction --no-update | |
| - name: Install demodata | |
| run: | | |
| docker compose exec -T \ | |
| php composer config repositories.oxid-esales/oxideshop-demodata-ce \ | |
| --json '{"type":"git", "url":"https://github.com/OXID-eSales/oxideshop_demodata_ce"}' | |
| docker compose exec -T php composer require oxid-esales/oxideshop-demodata-ce:dev-master --no-update | |
| docker compose exec -T php composer require oxid-esales/apex-theme:dev-b-7.0.x --no-update | |
| - name: Install datagen | |
| run: | | |
| docker compose exec -T \ | |
| php composer config repositories.oxid-esales/datagen \ | |
| --json '{"type":"path", "url":"./extensions/datagen", "options": { "symlink": true } }' | |
| docker compose exec -T php composer require oxid-esales/datagen:dev-b-7.0.x --no-update | |
| - name: Install dependencies and reset shop | |
| run: | | |
| docker compose exec -T php composer update --no-interaction | |
| docker compose exec -T php bin/oe-console oe:database:reset \ | |
| --db-host=mysql --db-port=3306 --db-name=example --db-user=root --db-password=root --force | |
| docker compose exec -T php bin/oe-console oe:setup:demodata | |
| docker compose exec -T php bin/oe-console oe:theme:activate apex | |
| docker compose exec -T php bin/oe-console oe:module:activate osc_paypal | |
| ls -la | |
| ls -la source | |
| - name: Put module settings | |
| continue-on-error: true | |
| run: | | |
| mkdir -p source/var/configuration/environment/shops/1/modules | |
| echo "${{ secrets.MODULE_SETTINGS_OXID7 }}" > source/var/configuration/environment/shops/1/modules/osc_paypal.yaml | |
| echo "${{ secrets.MODULE_ENV }}" > source/vendor/${{ env.PACKAGE_NAME }}/tests/.env | |
| docker compose exec -T php php bin/oe-console oe:module:activate osc_paypal | |
| - name: Show docker log | |
| if: always() | |
| run: | | |
| docker compose logs | |
| - name: Stop containers | |
| if: always() | |
| run: | | |
| docker compose down | |
| sleep 2 | |
| - name: Upload configuration artifacts | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Configs-${{ env.PHP_VERSION }}-${{ env.MYSQL_VERSION }}-${{ env.TEMPLATE_ENGINE }} | |
| path: | | |
| docker-compose.yml | |
| source/composer.json | |
| source/composer.lock | |
| source/config.inc.php | |
| source/var/configuration/shops/1/modules/osc-unzer.yaml | |
| data/php/logs/error_log.txt | |
| styles: | |
| strategy: | |
| matrix: | |
| php: [ '8.0' ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout current module | |
| uses: actions/checkout@v4 | |
| with: | |
| path: source/test-module | |
| fetch-depth: 0 # Fetch all commits for accurate diff | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| coverage: xdebug | |
| extensions: gd, zip | |
| - name: Install module dependencies | |
| id: dependencies | |
| working-directory: source/test-module | |
| run: composer install | |
| - name: Codestyle check of the affected files (phpcs, phpmd, phpstan) | |
| id: phpcs | |
| continue-on-error: false | |
| working-directory: source/test-module | |
| run: composer style-commit || exit 1 | |
| - name: Upload log artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: StylesLog-${{ matrix.php }} | |
| path: | | |
| source/test-module/tests/reports/phpstan.report.json | |
| source/test-module/tests/reports/phpmd.report.json | |
| unit_tests: | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 1 | |
| matrix: | |
| php: [ '8.2', '8.3' ] | |
| mysql: [ '5.7', '8.1' ] | |
| needs: [ install_shop_with_module ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Load current installation from cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ./* | |
| key: installation-${{ env.PHP_VERSION }}-${{ env.MYSQL_VERSION }}-${{ env.TEMPLATE_ENGINE }}-${{ github.run_number }}-${{ github.run_attempt }} | |
| restore-keys: | | |
| installation-${{ env.PHP_VERSION }}-${{ env.MYSQL_VERSION }}-${{ env.TEMPLATE_ENGINE }}-${{ github.run_number }}-${{ github.run_attempt }} | |
| - name: Start containers | |
| run: | | |
| make up | |
| sleep 2 | |
| - name: Install testing dependencies | |
| run: | | |
| docker compose exec -T php composer require symfony/dotenv --no-update --dev | |
| docker compose exec -T php composer update | |
| - name: Run tests | |
| run: | | |
| docker compose exec -T -e XDEBUG_MODE=coverage php vendor/bin/phpunit \ | |
| -c /var/www/test-module/tests/phpunit.xml \ | |
| --bootstrap=/var/www/source/bootstrap.php \ | |
| --verbose | |
| - name: Upload log artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: TestsLog-${{ matrix.php }}-${{ matrix.mysql }} | |
| path: | | |
| source/coverage.xml | |
| source/phpunit.xml | |
| source/source/log/oxideshop.log | |
| source/data/php/logs/error_log.txt | |
| playwright: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: [ '8.2' ] | |
| mysql: [ '5.7' ] | |
| needs: [ install_shop_with_module ] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Load current installation from cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ./* | |
| key: installation-${{ env.PHP_VERSION }}-${{ env.MYSQL_VERSION }}-${{ env.TEMPLATE_ENGINE }}-${{ github.run_number }}-${{ github.run_attempt }} | |
| restore-keys: | | |
| installation-${{ env.PHP_VERSION }}-${{ env.MYSQL_VERSION }}-${{ env.TEMPLATE_ENGINE }}-${{ github.run_number }}-${{ github.run_attempt }} | |
| - name: Start containers | |
| run: | | |
| make up | |
| sleep 2 | |
| - name: Set up ngrok | |
| run: | | |
| curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && \ | |
| echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && \ | |
| sudo apt-get update && sudo apt-get install ngrok | |
| - name: Create .env file | |
| working-directory: source/test-module/tests/e2e/playwright | |
| run: | | |
| echo "${{ secrets.PLAYWRIGHT_TEST_ENV }}" > .env | |
| echo "Created .env file with the following content:" | |
| cat .env | |
| - name: Load .env file into GitHub environment if present | |
| working-directory: source/test-module/tests/e2e/playwright | |
| run: | | |
| if [ -f .env ]; then | |
| while IFS='=' read -r key value || [ -n "$key" ]; do | |
| if [[ ! "$key" =~ ^# && -n "$key" ]]; then | |
| echo "$key=$value" >> $GITHUB_ENV | |
| fi | |
| done < .env | |
| echo ".env variables successfully loaded into GitHub environment." | |
| else | |
| echo ".env file not found. Skipping..." | |
| fi | |
| - name: Debug GitHub Environment Variables | |
| run: | | |
| echo "Loaded environment variables:" | |
| printenv | grep -E 'BASE_URL|PAYPAL_EMAIL|PAYPAL_PASSWORD|SHOP_USER_EMAIL|SHOP_USER_PASSWORD' | |
| - name: Validate Environment Variables | |
| run: | | |
| if [[ -z "$BASE_URL" || -z "$PAYPAL_EMAIL" || -z "$PAYPAL_PASSWORD" || -z "$SHOP_USER_EMAIL" || -z "$SHOP_USER_PASSWORD" ]]; then | |
| echo "Error: Required environment variables not found. Exiting." | |
| exit 1 | |
| fi | |
| echo "Environment variables successfully loaded." | |
| - name: Start ngrok with custom domain and keepalive | |
| run: | | |
| ngrok config add-authtoken ${{ secrets.NGROK_AUTH_TOKEN }} | |
| nohup ngrok http --hostname=${{ secrets.NGROK_CUSTOM_DOMAIN }} --log=stdout 80 > ngrok.log 2>&1 & | |
| NGROK_PID=$! | |
| echo "NGROK_PID=$NGROK_PID" >> $GITHUB_ENV | |
| sleep 10 | |
| if ! kill -0 $NGROK_PID 2>/dev/null; then | |
| echo "Ngrok failed to start properly" | |
| cat ngrok.log | |
| exit 1 | |
| fi | |
| echo "Ngrok started successfully with PID $NGROK_PID" | |
| - name: Test ngrok tunnel connection | |
| run: | | |
| for i in {1..5}; do | |
| echo "Testing ngrok connection attempt $i/5" | |
| if curl -I https://${{ secrets.NGROK_CUSTOM_DOMAIN }} --max-time 10; then | |
| echo "Ngrok connection successful" | |
| break | |
| else | |
| echo "Connection failed, retrying in 5 seconds..." | |
| sleep 5 | |
| fi | |
| done | |
| - name: Monitor ngrok during tests | |
| run: | | |
| # Create a script to monitor ngrok | |
| cat > monitor_ngrok.sh << 'EOF' | |
| #!/bin/bash | |
| while true; do | |
| if ! kill -0 $NGROK_PID 2>/dev/null; then | |
| echo "WARNING: Ngrok process died, restarting..." | |
| ngrok http --hostname=${{ secrets.NGROK_CUSTOM_DOMAIN }} --log=stdout 80 > ngrok.log 2>&1 & | |
| NGROK_PID=$! | |
| echo "NGROK_PID=$NGROK_PID" >> $GITHUB_ENV | |
| sleep 5 | |
| fi | |
| sleep 30 | |
| done | |
| EOF | |
| chmod +x monitor_ngrok.sh | |
| ./monitor_ngrok.sh & | |
| echo "Ngrok monitor started" | |
| - name: Install Playwright | |
| working-directory: source/test-module/tests/e2e/playwright | |
| run: | | |
| npm install dotenv --save-dev | |
| npm install | |
| npx playwright install | |
| - name: Creating the playwright user in the shop | |
| run: | | |
| docker compose exec -T php bin/oe-console datagen:shop:create_user \ | |
| --user-email ${{ secrets.SHOP_USER_EMAIL }} \ | |
| --user-password ${{ secrets.SHOP_USER_PASSWORD }} | |
| - name: Run Playwright tests | |
| working-directory: source/test-module/tests/e2e/playwright | |
| run: | | |
| # Verify ngrok is still running before tests | |
| if ! kill -0 $NGROK_PID 2>/dev/null; then | |
| echo "Ngrok is not running, restarting..." | |
| ngrok http --hostname=${{ secrets.NGROK_CUSTOM_DOMAIN }} --log=stdout 80 > ngrok.log 2>&1 & | |
| NGROK_PID=$! | |
| sleep 10 | |
| fi | |
| # Run tests with timeout protection | |
| timeout 600 make test || { | |
| echo "Test timed out or failed, checking ngrok status..." | |
| if kill -0 $NGROK_PID 2>/dev/null; then | |
| echo "Ngrok is still running" | |
| else | |
| echo "Ngrok died during test execution" | |
| cat ngrok.log | |
| fi | |
| exit 1 | |
| } | |
| - name: Cleanup ngrok | |
| if: always() | |
| run: | | |
| if [[ -n "$NGROK_PID" ]] && kill -0 $NGROK_PID 2>/dev/null; then | |
| echo "Stopping ngrok process $NGROK_PID" | |
| kill $NGROK_PID | |
| fi | |
| # Also kill any remaining ngrok processes | |
| pkill -f ngrok || true | |
| # Show ngrok logs for debugging | |
| if [ -f ngrok.log ]; then | |
| echo "Ngrok logs:" | |
| cat ngrok.log | |
| fi | |
| - name: Upload log artifact | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Playwright-${{ matrix.php }} | |
| path: | | |
| source/test-module/tests/e2e/playwright/_generated/ | |
| source/coverage.xml | |
| source/phpunit.xml | |
| source/source/log/oxideshop.log | |
| source/data/php/logs/error_log.txt |