Skip to content

Fix duplicate order creation for stock-1 articles during PayPal check… #3732

Fix duplicate order creation for stock-1 articles during PayPal check…

Fix duplicate order creation for stock-1 articles during PayPal check… #3732

Workflow file for this run

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'
jobs:
install_shop_with_module:
strategy:
matrix:
php: [ '7.4', '8.0', '8.1' ]
runs-on: ubuntu-latest
steps:
- name: Clone testing environment v3.0.0
run: git clone https://github.com/OXID-eSales/docker-eshop-sdk.git . && git reset --hard v3.0.0
- name: Clone the shop
run: git clone --depth 1 https://github.com/OXID-eSales/oxideshop_ce.git --branch b-6.5.x --single-branch source
- name: Download datagen
run: |
git clone https://${{ secrets.DATGEN_GH_TOKEN }}@github.com/dantweb/datagen.git \
source/extensions/datagen \
--branch=b-6.5.x-gha-plwrt-fork
- name: Prepare container configuration
run: |
make setup
make addbasicservices
perl -pi\
-e "s#PHP_VERSION=.*#PHP_VERSION='${{ matrix.php }}'#g;"\
.env
perl -pi\
-e 's#display_errors =.*#display_errors = false#g;'\
-e 'print "xdebug.max_nesting_level=1000\nxdebug.mode=coverage\n\n"'\
containers/php-fpm/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: |
docker compose up -d
sleep 2
- name: Checkout current module
uses: actions/checkout@v4
with:
path: source/test-module
- name: Install module
run: |
docker compose exec -T \
php composer require symfony/dotenv:* --no-update
docker compose exec -T \
php composer require codeception/module-rest:1.4.2 --no-update
docker compose exec -T \
php composer require codeception/module-phpbrowser:^1.0.2 --no-update
docker compose exec -T \
php composer require oxid-esales/flow-theme:^v3.4.1 --no-update
docker compose exec -T \
php composer config repositories.${{ env.CLIENT_PACKAGE_NAME }} git ${{ env.CLIENT_REPO_NAME }}
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.CLIENT_PACKAGE_NAME }}:dev-b-7.0.x --no-interaction --no-update
docker compose exec -T \
php composer require ${{ env.PACKAGE_NAME }}:* --no-interaction
- name: Reset shop
continue-on-error: true
run: |
set -x
docker compose exec -T php php vendor/bin/reset-shop 2>&1
- name: Set module settings
continue-on-error: true
run: |
set -x
mkdir -p source/var/configuration/environment/
echo "${{ secrets.MODULE_SETTINGS }}" > source/var/configuration/environment/1.yaml
echo "${{ secrets.MODULE_ENV }}" > source/vendor/${{ env.PACKAGE_NAME }}/tests/.env
- name: Install Paypal module
continue-on-error: true
run: |
set -x
docker compose exec -T php bin/oe-console oe:module:install-configuration source/modules/osc/paypal
- name: Apply module configuration
continue-on-error: true
run: |
set -x
docker compose exec -T php php bin/oe-console oe:module:apply-configuration
- name: Activate Paypal module
continue-on-error: true
run: |
set -x
docker compose exec -T php bin/oe-console oe:module:activate osc_paypal 2>&1
- name: Install datagen and create user
run: |
set -x
docker compose exec -T \
php composer config repositories.dantweb/datagen \
--json '{"type":"path", "url":"./extensions/datagen", "options": { "symlink": true } }'
docker compose exec -T php composer require dantweb/datagen:dev-b-6.5.x-gha-plwrt-fork --no-interaction
- name: Configure datagen services
run: |
# Add datagen services to generated_services.yaml (from host)
echo "Configuring datagen services..."
SERVICES_FILE="source/var/generated/generated_services.yaml"
if [ -f "$SERVICES_FILE" ]; then
# Check if the datagen service is already configured
if ! grep -q "vendor/dantweb/datagen/services.yaml" "$SERVICES_FILE"; then
echo "Adding datagen services to $SERVICES_FILE"
cat >> "$SERVICES_FILE" << 'EOF'
- resource: ../../vendor/dantweb/datagen/services.yaml
EOF
echo "Successfully added datagen services configuration"
else
echo "Datagen services already configured"
fi
else
echo "Warning: $SERVICES_FILE not found"
echo "Available files in source/var/generated/:"
ls -la source/var/generated/ 2>/dev/null || echo "source/var/generated directory not found"
fi
- name: Cache current installation
uses: actions/cache@v4
with:
path: |
./*
key: moduleDevelopmentInstallation-${{ matrix.php }}-${{ github.sha }}
- name: Stop containers
run: |
docker compose down
sleep 2
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: InstallShop-${{ matrix.php }}
path: |
source/var/*
source/source/log/oxideshop.log
source/composer.json
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
working-directory: source/test-module
run: composer style:commit # Runs oll style checks
- 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
matrix:
php: [ '7.4', '8.0', '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: moduleDevelopmentInstallation-${{ matrix.php }}-${{ github.sha }}
restore-keys: |
moduleDevelopmentInstallation-${{ matrix.php }}-${{ github.sha }}
- name: Start containers
run: |
docker compose up -d
sleep 2
- name: Clean cache
run: |
rm -rf source/source/tmp/*
- name: Run tests
run: |
docker compose exec -T \
-e PARTIAL_MODULE_PATHS=osc/paypal \
-e ACTIVATE_ALL_MODULES=1 \
-e RUN_TESTS_FOR_SHOP=0 \
-e RUN_TESTS_FOR_MODULES=0 \
-e XDEBUG_MODE=coverage \
-e ADDITIONAL_TEST_PATHS='/var/www/vendor/oxid-solution-catalysts/paypal-module/tests' \
php php vendor/bin/runtests \
--log-junit=/var/www/phpunit.xml \
AllTestsUnit
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: TestsLog-${{ matrix.php }}
path: |
source/coverage.xml
source/phpunit.xml
source/source/log/oxideshop.log
source/composer.json
source/composer.lock
source/vendor/composer
playwright:
strategy:
fail-fast: false
matrix:
php: [ '8.0' ]
needs: [ install_shop_with_module ]
runs-on: ubuntu-latest
steps:
- name: Load current installation from cache
uses: actions/cache@v4
with:
path: |
./*
key: moduleDevelopmentInstallation-${{ matrix.php }}-${{ github.sha }}
restore-keys: |
moduleDevelopmentInstallation-${{ matrix.php }}-${{ github.sha }}
- name: Start containers
run: |
docker compose up -d
sleep 2
- name: Create .env file
working-directory: source/test-module/tests/e2e/playwright
run: |
cp .env.dist.Razvan .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: Set module settings
continue-on-error: true
run: |
set -x
mkdir -p source/var/configuration/environment/
echo "${{ secrets.MODULE_SETTINGS }}" > source/var/configuration/environment/1.yaml
ls -la source/var/configuration/environment/
cat source/var/configuration/environment/1.yaml
cat source/var/configuration/shops/1.yaml
echo "${{ secrets.MODULE_ENV }}" > source/vendor/${{ env.PACKAGE_NAME }}/tests/.env
- name: Apply module configuration
continue-on-error: true
run: |
set -x
docker compose exec -T php php bin/oe-console oe:module:apply-configuration
- name: Activate Paypal module
continue-on-error: true
run: |
set -x
docker compose exec -T php bin/oe-console oe:module:activate osc_paypal 2>&1
- name: Create user
run: |
docker compose exec -T php bin/oe-console datagen:shop:create_user ${{ secrets.SHOP_USER_EMAIL }} ${{ secrets.SHOP_USER_PASSWORD }}
- name: Check container logs
if: failure()
run: docker compose logs php
- name: Install Playwright
working-directory: source/test-module/tests/e2e/playwright
run: |
npm install dotenv --save-dev
npm install
npx playwright install
- name: Run Playwright tests
working-directory: source/test-module/tests/e2e/playwright
run: |
make test
- name: Upload log artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: Playwright-${{ matrix.php }}
path: |
source/source/log/oxideshop.log
source/data/php/logs/error_log.txt
source/test-module/tests/e2e/playwright/_output/
source/test-module/tests/e2e/playwright/_generated/
source/test-module/tests/e2e/playwright/_screenshots/