Merge pull request #32804 from woocommerce/fix/e2e-tests

Fix/e2e tests
This commit is contained in:
Claudio Sanches 2022-04-27 14:57:16 -03:00 committed by GitHub
commit ca02a49bff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 113 additions and 157 deletions

View File

@ -11,20 +11,20 @@ jobs:
name: Build release zip file
runs-on: ubuntu-20.04
steps:
- name: Checkout code
- name: Checkout code.
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Build the zip file
id: build
uses: woocommerce/action-build@trunk
- name: Unzip the file (prevents double zip problem)
run: unzip ${{ steps.build.outputs.zip_path }} -d zipfile
- name: Install PNPM
run: npm install -g pnpm
- name: Build zip
run: pnpm nx build-zip woocommerce
- name: Upload the zip file as an artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: woocommerce
path: zipfile
path: plugins/woocommerce/woocommerce.zip
retention-days: 7

View File

@ -7,18 +7,22 @@ jobs:
name: Build release asset
runs-on: ubuntu-20.04
steps:
- name: Checkout code
- name: Checkout code.
uses: actions/checkout@v3
- name: Build
id: build
uses: woocommerce/action-build@trunk
- name: Install PNPM
run: npm install -g pnpm
- name: Build zip
run: pnpm nx build-zip woocommerce
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.build.outputs.zip_path }}
asset_path: plugins/woocommerce/woocommerce.zip
asset_name: woocommerce.zip
asset_content_type: application/zip
update-code-reference:

View File

@ -8,40 +8,49 @@ jobs:
name: Build WooCommerce zip
runs-on: ubuntu-20.04
steps:
- name: Checkout code
- name: Checkout code.
uses: actions/checkout@v3
- name: Build
id: build
uses: woocommerce/action-build@trunk
env:
BUILD_ENV: mirrors
- name: Upload PR zip
uses: actions/upload-artifact@v2
- name: Install PNPM
run: npm install -g pnpm
- name: Build zip
run: pnpm nx build-zip woocommerce
- name: Upload the zip file as an artifact
uses: actions/upload-artifact@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: woocommerce
path: ${{ steps.build.outputs.zip_path }}
path: plugins/woocommerce/woocommerce.zip
retention-days: 7
mirror:
if: github.repository == 'woocommerce/woocommerce'
name: Push to Mirror
runs-on: ubuntu-20.04
needs: [build]
runs-on: ubuntu-20.04
steps:
- name: Create directories
run: |
mkdir -p tmp/woocommerce-build
mkdir -p monorepo
- name: Checkout monorepo
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: monorepo
- name: Copy Composer over to production
run: cp monorepo/plugins/woocommerce/composer.json tmp/woocommerce-build
- name: Download WooCommerce ZIP
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: woocommerce
path: tmp/woocommerce-build
- name: Extract and replace WooCommerce zip.
working-directory: tmp/woocommerce-build
run: |
@ -49,11 +58,13 @@ jobs:
unzip woocommerce.zip -d woocommerce/woocommerce-production
mv woocommerce/woocommerce-production/woocommerce/* woocommerce/woocommerce-production
rm -rf woocommerce/woocommerce-production/woocommerce
- name: Set up mirror
working-directory: tmp/woocommerce-build
run: |
touch mirrors.txt
echo "woocommerce/woocommerce-production" >> mirrors.txt
- name: Push to mirror
uses: Automattic/action-push-to-mirrors@v1
with:

View File

@ -16,9 +16,13 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ matrix.build }}
- name: Build
id: build
uses: woocommerce/action-build@trunk
- name: Install PNPM
run: npm install -g pnpm
- name: Build zip
run: pnpm nx build-zip woocommerce
- name: Deploy nightly build
uses: WebFreak001/deploy-nightly@v1.1.0
env:
@ -26,7 +30,7 @@ jobs:
with:
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/25945111/assets{?name,label}
release_id: 25945111
asset_path: ${{ steps.build.outputs.zip_path }}
asset_path: plugins/woocommerce/woocommerce.zip
asset_name: woocommerce-${{ matrix.build }}-nightly.zip
asset_content_type: application/zip
max_releases: 1

View File

@ -1,83 +1,46 @@
name: Build zip for PR
name: Run tests against PR
on: pull_request
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build zip for PR
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build
id: build
uses: woocommerce/action-build@trunk
env:
BUILD_ENV: e2e
- name: Upload PR zip
uses: actions/upload-artifact@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: woocommerce
path: ${{ steps.build.outputs.zip_path }}
retention-days: 7
e2e-tests-run:
name: Runs E2E tests.
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Create dirs.
run: |
mkdir -p code/woocommerce
mkdir -p package/woocommerce
mkdir -p tmp/woocommerce
- name: Checkout code.
uses: actions/checkout@v3
with:
path: package/woocommerce
- name: Move current directory to code. We will install zip file in this dir later.
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
- name: Download WooCommerce ZIP.
uses: actions/download-artifact@v3
with:
name: woocommerce
path: tmp
- name: Extract and replace WooCommerce zip.
working-directory: tmp
run: |
unzip woocommerce.zip -d woocommerce
mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/
- name: Cache modules
uses: actions/cache@v3
id: cache-deps
with:
path: |
~/.pnpm-store
key: ${{ runner.os }}-npm-${{ hashFiles('**/pnpm-lock.yaml') }}
plugins/woocommerce/packages
plugins/woocommerce/**/vendor
key: ${{ runner.os }}-npm-composer-${{ hashFiles('**/composer.lock', '**/pnpm-lock.yaml') }}
- name: Install PNPM
run: npm install -g pnpm
- name: Install dependencies
working-directory: package/woocommerce
run: pnpm install
- name: Install Composer dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: pnpm nx composer-install-no-dev woocommerce
- name: Run build
run: pnpm nx build woocommerce
- name: Load docker images and start containers.
working-directory: package/woocommerce/plugins/woocommerce
working-directory: plugins/woocommerce
run: pnpm exec wc-e2e docker:up
- name: Run tests command.
working-directory: package/woocommerce/plugins/woocommerce
working-directory: plugins/woocommerce
env:
WC_E2E_SCREENSHOTS: 1
E2E_SLACK_TOKEN: ${{ secrets.E2E_SLACK_TOKEN }}
@ -89,63 +52,48 @@ jobs:
if: always()
with:
name: E2E Screenshots
path: package/woocommerce/plugins/woocommerce/tests/e2e/screenshots
path: plugins/woocommerce/tests/e2e/screenshots
if-no-files-found: ignore
retention-days: 5
api-tests-run:
name: Runs API tests.
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Create dirs.
run: |
mkdir -p code/woocommerce
mkdir -p package/woocommerce
mkdir -p tmp/woocommerce
- name: Checkout code.
uses: actions/checkout@v3
with:
path: package/woocommerce
- name: Move current directory to code. We will install zip file in this dir later.
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
- name: Download WooCommerce ZIP.
uses: actions/download-artifact@v3
with:
name: woocommerce
path: tmp
- name: Extract and replace WooCommerce zip.
working-directory: tmp
run: |
unzip woocommerce.zip -d woocommerce
mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/
- name: Cache modules
uses: actions/cache@v3
id: cache-deps
with:
path: |
~/.pnpm-store
key: ${{ runner.os }}-npm-${{ hashFiles('**/pnpm-lock.yaml') }}
plugins/woocommerce/packages
plugins/woocommerce/**/vendor
key: ${{ runner.os }}-npm-composer-${{ hashFiles('**/composer.lock', '**/pnpm-lock.yaml') }}
- name: Install PNPM
run: npm install -g pnpm
- name: Install dependencies
working-directory: package/woocommerce
run: pnpm install
- name: Install Composer dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: pnpm nx composer-install woocommerce
- name: Run build
run: pnpm nx build woocommerce
- name: Load docker images and start containers.
working-directory: package/woocommerce/plugins/woocommerce
working-directory: plugins/woocommerce
run: pnpm exec wc-e2e docker:up
- name: Run tests command.
working-directory: package/woocommerce/plugins/woocommerce
working-directory: plugins/woocommerce
env:
BASE_URL: http://localhost:8084
BASE_URL: http://localhost:8086
USER_KEY: admin
USER_SECRET: password
run: pnpm exec wc-api-tests test api
@ -155,62 +103,47 @@ jobs:
with:
name: api-test-report---pr-${{ github.event.number }}
path: |
package/woocommerce/packages/js/api-core-tests/allure-results
package/woocommerce/packages/js/api-core-tests/allure-report
packages/js/api-core-tests/allure-results
packages/js/api-core-tests/allure-report
retention-days: 7
k6-tests-run:
name: Runs k6 Performance tests
runs-on: ubuntu-20.04
needs: [build]
steps:
- name: Create dirs.
run: |
mkdir -p code/woocommerce
mkdir -p package/woocommerce
mkdir -p tmp/woocommerce
- name: Checkout code.
uses: actions/checkout@v3
with:
path: package/woocommerce
- name: Move current directory to code. We will install zip file in this dir later.
run: mv ./package/woocommerce/plugins/woocommerce/* ./code/woocommerce
- name: Download WooCommerce ZIP.
uses: actions/download-artifact@v3
with:
name: woocommerce
path: tmp
- name: Extract and replace WooCommerce zip.
working-directory: tmp
run: |
unzip woocommerce.zip -d woocommerce
mv woocommerce/woocommerce/* ../package/woocommerce/plugins/woocommerce/
- name: Cache modules
uses: actions/cache@v3
id: cache-deps
with:
path: |
~/.pnpm-store
key: ${{ runner.os }}-npm-${{ hashFiles('**/pnpm-lock.yaml') }}
plugins/woocommerce/packages
plugins/woocommerce/**/vendor
key: ${{ runner.os }}-npm-composer-${{ hashFiles('**/composer.lock', '**/pnpm-lock.yaml') }}
- name: Install PNPM
run: npm install -g pnpm
- name: Install dependencies
working-directory: package/woocommerce
run: pnpm install
- name: Install Composer dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: pnpm nx composer-install woocommerce
- name: Run build
run: pnpm nx build woocommerce
- name: Workaround to use initialization file with prepopulated data.
working-directory: package/woocommerce/plugins/woocommerce/tests/e2e/docker
working-directory: plugins/woocommerce/tests/e2e/docker
run: |
cp init-sample-products.sh initialize.sh
- name: Load docker images and start containers.
working-directory: package/woocommerce/plugins/woocommerce
working-directory: plugins/woocommerce
run: pnpm exec wc-e2e docker:up
- name: Install k6
@ -219,4 +152,4 @@ jobs:
- name: Run k6 tests
run: |
./k6 run package/woocommerce/plugins/woocommerce/tests/performance/tests/gh-action-pr-requests.js
./k6 run plugins/woocommerce/tests/performance/tests/gh-action-pr-requests.js

View File

@ -12,7 +12,6 @@ jobs:
mkdir -p code/woocommerce
mkdir -p package/woocommerce
mkdir -p tmp/woocommerce
mkdir -p node_modules
- name: Checkout code.
uses: actions/checkout@v3
@ -59,11 +58,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Build
id: build
uses: woocommerce/action-build@trunk
env:
BUILD_ENV: e2e
- name: Install PNPM
run: npm install -g pnpm
- name: Build zip
run: pnpm nx build-zip woocommerce
- name: Upload PR zip
uses: actions/upload-artifact@v3
@ -71,7 +70,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: woocommerce
path: ${{ steps.build.outputs.zip_path }}
path: plugins/woocommerce/woocommerce.zip
retention-days: 7
test-plugins:
@ -101,10 +100,9 @@ jobs:
mkdir -p code/woocommerce
mkdir -p package/woocommerce
mkdir -p tmp/woocommerce
mkdir -p node_modules
- name: Checkout code.
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
path: package/woocommerce

View File

@ -16,7 +16,8 @@ echo "Running JS Build..."
pnpm run build || exit "$?"
echo "Cleaning up PHP dependencies..."
composer install --no-dev || exit "$?"
echo "Run makepot..."
composer run-script makepot
echo "Syncing files..."
rsync -rc --exclude-from="$PROJECT_PATH/.distignore" "$PROJECT_PATH/" "$DEST_PATH/" --delete --delete-excluded

View File

@ -0,0 +1,5 @@
Significance: patch
Type: dev
Comment: Related to QOL

View File

@ -14,7 +14,7 @@
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"build": "WC_ADMIN_PHASE=core pnpm run build:feature-config && pnpm nx build woocommerce-admin && pnpm nx build woocommerce-legacy-assets && pnpm run makepot",
"build": "WC_ADMIN_PHASE=core pnpm run build:feature-config && pnpm nx build woocommerce-admin && pnpm nx build woocommerce-legacy-assets",
"build:feature-config": "php bin/generate-feature-config.php",
"build:zip": "./bin/build-zip.sh",
"lint:js": "eslint assets/js --ext=js",

View File

@ -1,5 +1,5 @@
{
"url": "http://localhost:8084/",
"url": "http://localhost:8086/",
"users": {
"admin": {
"username": "admin",

View File

@ -1,5 +1,5 @@
export const base_url = __ENV.URL || 'http://localhost:8084';
export const base_host = __ENV.HOST || 'localhost:8084';
export const base_url = __ENV.URL || 'http://localhost:8086';
export const base_host = __ENV.HOST || 'localhost:8086';
export const admin_username = __ENV.A_USER || 'admin';
export const admin_password = __ENV.A_PW || 'password';