diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 3c179f7..1ee8229 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -22,74 +22,23 @@ concurrency: jobs: e2e-playwright: - name: Playwright - runs-on: ubuntu-latest - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} + uses: inpsyde/reusable-workflows/.github/workflows/test-playwright.yml@main + strategy: + matrix: + php: [ '8.2' ] + with: + COMPOSER_DEPS_INSTALL: true + PHP_VERSION: ${{ matrix.php }} + ARTIFACT_INCLUDE_HIDDEN_FILES: true + ARTIFACT_OVERWRITE: true + ARTIFACT_PATH: './artifacts' + NODE_VERSION: 20 + PLAYWRIGHT_BROWSER_ARGS: 'chromium --with-deps' + SCRIPT_NAME: 'ci-test-e2e' + secrets: + ENV_FILE_DATA: ${{ secrets.GTM_VARS }} + COMPOSER_AUTH_JSON: '${{ secrets.PACKAGIST_AUTH_JSON }}' GITHUB_USER_EMAIL: ${{ secrets.DEPLOYBOT_EMAIL }} GITHUB_USER_NAME: ${{ secrets.DEPLOYBOT_USER }} GITHUB_USER_SSH_KEY: ${{ secrets.DEPLOYBOT_SSH_PRIVATE_KEY }} - COMPOSER_AUTH: '${{secrets.PACKAGIST_AUTH_JSON}}' - strategy: - fail-fast: false - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up SSH - if: ${{ env.GITHUB_USER_SSH_KEY != '' }} - uses: webfactory/ssh-agent@v0.9.0 - with: - ssh-private-key: ${{ env.GITHUB_USER_SSH_KEY }} - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.2 - tools: composer - coverage: none - - - name: Install Composer dependencies - uses: ramsey/composer-install@v3 - with: - composer-options: '--prefer-dist' - - - name: Set up node - uses: actions/setup-node@v4 - with: - node-version: '20' - registry-url: 'https://npm.pkg.github.com/' - - - name: Github Packages Auth - run: | - npm config set @inpsyde:registry 'https://npm.pkg.github.com' - npm config set //npm.pkg.github.com/:_authToken ${{ secrets.DEPLOYBOT_PACKAGES_READ_ACCESS_TOKEN}} - - - name: Install dependencies - run: npm install - - - name: Npm build - run: npm run-script build - - - name: Install Playwright dependencies - run: | - npx playwright install chromium --with-deps - - - name: Install WordPress and start the server - run: | - npm run-script wp-env start - - - name: Run the tests - env: - PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1 - run: | - xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run-script test:e2e - - - name: Archive debug artifacts (screenshots, traces) - uses: actions/upload-artifact@v4 - if: ${{ !cancelled() }} - with: - name: artifacts - path: ./artifacts - if-no-files-found: ignore + NPM_REGISTRY_TOKEN: ${{ secrets.DEPLOYBOT_PACKAGES_READ_ACCESS_TOKEN}} diff --git a/package-lock.json b/package-lock.json index 94a347a..45c38a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,7 @@ "@wordpress/env": "^10.3.0", "@wordpress/scripts": "^26", "copy-webpack-plugin": "^12.0", + "dotenv-cli": "^8.0.0", "typescript": "^4.9.4" }, "engines": { @@ -15559,7 +15560,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dev": true, "license": "MIT", "dependencies": { @@ -16407,6 +16410,45 @@ "node": ">=8" } }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/dotenv-cli": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-8.0.0.tgz", + "integrity": "sha512-aLqYbK7xKOiTMIRf1lDPbI+Y+Ip/wo5k3eyp6ePysVaSqbyxjyK3dK35BTxG+rmd7djf5q2UPs4noPNH+cj0Qw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.6", + "dotenv": "^16.3.0", + "dotenv-expand": "^10.0.0", + "minimist": "^1.2.6" + }, + "bin": { + "dotenv": "cli.js" + } + }, + "node_modules/dotenv-expand": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz", + "integrity": "sha512-GopVGCpVS1UKH75VKHGuQFqS1Gusej0z4FyQkPdwjil2gNIv+LNsqBlboOzpJFZKVT95GkCyWJbBSdFEFUWI2A==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, "node_modules/downshift": { "version": "6.1.12", "license": "MIT", diff --git a/package.json b/package.json index 6fcc2bd..4cc9fd2 100644 --- a/package.json +++ b/package.json @@ -39,11 +39,12 @@ "react": "18.3.1" }, "devDependencies": { - "@wordpress/scripts": "^26", - "@wordpress/env": "^10.3.0", "@inpsyde/playwright-utils": "2.0.0-beta.2", "@playwright/test": "^1.45.1", + "@wordpress/env": "^10.3.0", + "@wordpress/scripts": "^26", "copy-webpack-plugin": "^12.0", + "dotenv-cli": "^8.0.0", "typescript": "^4.9.4" }, "scripts": { @@ -57,7 +58,10 @@ "test:e2e": "wp-scripts test-playwright --config tests/e2e/playwright.config.ts", "wp-env": "wp-env", "packages-update": "wp-scripts packages-update", - "plugin-zip": "wp-scripts plugin-zip" + "plugin-zip": "wp-scripts plugin-zip", + "ci-test-e2e:setup": "npm run build && npm run wp-env start", + "ci-test-e2e:test": "xvfb-run --auto-servernum --server-args=\"-screen 0 1280x960x24\" -- dotenv -e .env.ci -- npm run-script test:e2e", + "ci-test-e2e": "npm run-script ci-test-e2e:setup && npm run-script ci-test-e2e:test" }, "files": [ "index.php",