Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/179
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Aug 5, 2024
2 parents 8691d13 + 48978f1 commit 1f40105
Show file tree
Hide file tree
Showing 219 changed files with 14,930 additions and 39,508 deletions.
14 changes: 11 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module.exports = {
extends: ['plugin:@woocommerce/eslint-plugin/recommended'],
extends: [ 'plugin:@woocommerce/eslint-plugin/recommended' ],
globals: {
_: false,
Backbone: false,
jQuery: false,
wp: false,
wc: false,
wcSquareSettings: false,
},
settings: {
jsdoc: { mode: 'typescript' },
Expand All @@ -19,7 +21,7 @@ module.exports = {
],
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
},
},
},
Expand All @@ -30,10 +32,16 @@ module.exports = {
'react-hooks/rules-of-hooks': 'off',
'@woocommerce/dependency-group': 'off',
camelcase: 'off',
'@wordpress/i18n-text-domain': [
'error',
{
allowedTextDomain: 'woocommerce-square',
},
],
},
overrides: [
{
files: ['**/assets/blocks/**/**.js'],
files: [ '**/assets/blocks/**/**.js' ],
globals: {
jQuery: true,
browser: true,
Expand Down
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ docs export-ignore
mode_modules export-ignore
wordpress-org-assets export-ignore
tests export-ignore
src export-ignore
test-plugins export-ignore

# Files
.distignore export-ignore
Expand Down
52 changes: 35 additions & 17 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ on:
branches:
- smoke-testing
pull_request:
types: [opened, synchronize, reopened, labeled]
types: [opened, synchronize, reopened]
branches:
- trunk

jobs:
e2e:
if: "${{ ( github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'needs: e2e testing') ) || github.event_name == 'push' }}"
if: "${{ ( github.event_name == 'pull_request' ) || github.event_name == 'push' }}"
runs-on: ubuntu-latest
env:
WP_ADMIN_USERNAME: ${{ secrets.WP_ADMIN_USERNAME }}
WP_ADMIN_PASSWORD: ${{ secrets.WP_ADMIN_PASSWORD }}
SQUARE_APPLICATION_ID: ${{ secrets.SQUARE_APPLICATION_ID }}
SQUARE_ACCESS_TOKEN: ${{ secrets.SQUARE_ACCESS_TOKEN }}
SQUARE_LOCATION_ID: ${{ secrets.SQUARE_LOCATION_ID }}
GH_TOKEN: ${{ secrets.BOT_GH_TOKEN }}
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
Expand All @@ -37,23 +38,30 @@ jobs:
- name: Install playwright
run: npx playwright install

# Use compiled versions to avoid need for npm and composer installation and build step.
- name: Install required WP plugins
run: |
gh release download --repo woocommerce/woocommerce-pre-orders --pattern woocommerce-pre-orders.zip --dir ./test-plugins
gh release download --repo woocommerce/woocommerce-subscriptions --pattern woocommerce-subscriptions.zip --dir ./test-plugins
cd ./test-plugins
unzip -o woocommerce-pre-orders.zip
unzip -o woocommerce-subscriptions.zip
cd ..
- name: Set the core version
if: "${{ contains(github.event.pull_request.labels.*.name, 'needs: WP RC test') }}"
id: run-rc-test
run: ./tests/bin/set-core-version.js WordPress/WordPress#master

- name: Setup E2E environment
run: npm run test:env:start
run: npm run env:start

- name: Run E2E tests
id: square_e2e_tests
if: ${{ github.event_name == 'pull_request' }}
run: npm run test:e2e-run
run: npm run test:e2e

- name: Update Success Label
if: |
always() &&
steps.square_e2e_tests.conclusion == 'success'
- name: Remove existing labels
uses: actions/github-script@v6
continue-on-error: true
with:
Expand All @@ -62,29 +70,39 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['needs: e2e testing']
name: ['status: e2e tests passing']
})
github.rest.issues.addLabels({
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['status: e2e tests passing']
name: ['status: e2e tests failing']
})
- name: Update Failure Label
- name: Update Success Label
if: |
always() &&
steps.square_e2e_tests.conclusion == 'failure'
steps.square_e2e_tests.conclusion == 'success'
uses: actions/github-script@v6
continue-on-error: true
with:
script: |
github.rest.issues.removeLabel({
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ['needs: e2e testing']
labels: ['status: e2e tests passing']
})
- name: Update Failure Label
if: |
always() &&
steps.square_e2e_tests.conclusion == 'failure'
uses: actions/github-script@v6
continue-on-error: true
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
Expand All @@ -94,7 +112,7 @@ jobs:
- name: Run E2E Smoke Test
if: ${{ github.event_name == 'push' }}
run: npm run test:e2e-run
run: npm run test:e2e

- uses: actions/upload-artifact@v3
if: always()
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/generate-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

- name: Setup node version and npm cache
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'npm'
Expand All @@ -34,7 +34,7 @@ jobs:
run: npm run build && rm -rf ./woocommerce-square && unzip woocommerce-square.zip -d ./woocommerce-square

- name: Use the Upload Artifact GitHub Action
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: woocommerce-square
path: woocommerce-square/
38 changes: 32 additions & 6 deletions .github/workflows/qit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ on:
- api
- e2e
- phpstan
- phpcompat
- security
- malware
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
Expand All @@ -26,11 +28,11 @@ permissions:

jobs:
build:
if: "${{ ( inputs.test != '' && inputs.test != 'none' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit activation test') || contains(github.event.pull_request.labels.*.name, 'needs: qit api test') || contains(github.event.pull_request.labels.*.name, 'needs: qit e2e test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpstan test') || contains(github.event.pull_request.labels.*.name, 'needs: qit security test') }}"
if: "${{ ( inputs.test != '' && inputs.test != 'none' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit activation test') || contains(github.event.pull_request.labels.*.name, 'needs: qit api test') || contains(github.event.pull_request.labels.*.name, 'needs: qit e2e test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpstan test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpcompat test') || contains(github.event.pull_request.labels.*.name, 'needs: qit security test') || contains(github.event.pull_request.labels.*.name, 'needs: qit malware test') }}"
uses: woocommerce/woocommerce-square/.github/workflows/generate-zip.yml@trunk

test:
if: "${{ ( inputs.test != '' && inputs.test != 'none' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit activation test') || contains(github.event.pull_request.labels.*.name, 'needs: qit api test') || contains(github.event.pull_request.labels.*.name, 'needs: qit e2e test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpstan test') || contains(github.event.pull_request.labels.*.name, 'needs: qit security test') }}"
if: "${{ ( inputs.test != '' && inputs.test != 'none' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit activation test') || contains(github.event.pull_request.labels.*.name, 'needs: qit api test') || contains(github.event.pull_request.labels.*.name, 'needs: qit e2e test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpstan test') || contains(github.event.pull_request.labels.*.name, 'needs: qit phpcompat test') || contains(github.event.pull_request.labels.*.name, 'needs: qit security test') || contains(github.event.pull_request.labels.*.name, 'needs: qit malware test') }}"
needs: build
name: run
runs-on: ubuntu-latest
Expand All @@ -41,10 +43,10 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Download build
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}

Expand Down Expand Up @@ -79,7 +81,7 @@ jobs:
- name: Run API test
if: "${{ ( ( inputs.tests == 'default' || inputs.tests == 'api' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit api test') ) && ( success() || failure() ) }}"
id: run-api-test
run: ./vendor/bin/qit run:api ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > api-result.txt
run: ./vendor/bin/qit run:woo-api ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > api-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-api-test.conclusion == 'failure' }}
Expand All @@ -91,7 +93,7 @@ jobs:
- name: Run E2E test
if: "${{ ( ( inputs.tests == 'default' || inputs.tests == 'e2e' ) || contains(github.event.pull_request.labels.*.name, 'needs: qit default tests') || contains(github.event.pull_request.labels.*.name, 'needs: qit e2e test') ) && ( success() || failure() ) }}"
id: run-e2e-test
run: ./vendor/bin/qit run:e2e ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > e2e-result.txt
run: ./vendor/bin/qit run:woo-e2e ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > e2e-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-e2e-test.conclusion == 'failure' }}
Expand All @@ -112,6 +114,18 @@ jobs:
recreate: true
path: phpstan-result.txt

- name: Run PHPCompat test
if: "${{ inputs.tests == 'phpcompat' || contains(github.event.pull_request.labels.*.name, 'needs: qit phpcompat test') && ( success() || failure() ) }}"
id: run-phpcompat-test
run: ./vendor/bin/qit run:phpcompatibility ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > phpcompat-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-phpcompat-test.conclusion == 'failure' }}
with:
header: QIT PHPCompat result
recreate: true
path: phpcompat-result.txt

- name: Run security test
if: "${{ inputs.tests == 'security' || contains(github.event.pull_request.labels.*.name, 'needs: qit security test') && ( success() || failure() ) }}"
id: run-security-test
Expand All @@ -123,3 +137,15 @@ jobs:
header: QIT security result
recreate: true
path: security-result.txt

- name: Run malware test
if: "${{ inputs.tests == 'malware' || contains(github.event.pull_request.labels.*.name, 'needs: qit malware test') && ( success() || failure() ) }}"
id: run-malware-test
run: ./vendor/bin/qit run:malware ${{ github.event.repository.name }} --zip=${{ github.event.repository.name }}.zip --wait > malware-result.txt

- uses: marocchino/sticky-pull-request-comment@v2
if: ${{ failure() && steps.run-malware-test.conclusion == 'failure' }}
with:
header: QIT malware result
recreate: true
path: malware-result.txt
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ docker/logs
/test-results/
/playwright-report/
/playwright/.cache/
tests/e2e/test-results
tests/e2e/test-results
test-plugins/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v20
7 changes: 3 additions & 4 deletions .wp-env.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"plugins": [
"https://downloads.wordpress.org/plugin/woocommerce.zip",
"https://downloads.wordpress.org/plugin/email-log.zip",
"."
".",
"./test-plugins/woocommerce-subscriptions",
"./test-plugins/woocommerce-pre-orders"
],
"themes": [ "https://downloads.wordpress.org/theme/storefront.zip" ],
"env": {
Expand All @@ -16,8 +18,5 @@
"config": {
"WP_ALLOW_MULTISITE": true,
"ALTERNATE_WP_CRON": true
},
"lifecycleScripts": {
"afterStart": "bash ./tests/e2e/config/env-post-setup.sh"
}
}
Loading

0 comments on commit 1f40105

Please sign in to comment.