Skip to content

Commit

Permalink
Merge branch 'trunk' into fix/89-phpcs-sniffs
Browse files Browse the repository at this point in the history
  • Loading branch information
faisal-alvi committed Dec 12, 2023
2 parents 842bc37 + 865acc8 commit bde1fb2
Show file tree
Hide file tree
Showing 37 changed files with 4,336 additions and 3,143 deletions.
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ phpunit.xml.dist export-ignore
.tx export-ignore
.prettierrc.js export-ignore
webpack.config.js export-ignore
phpcs.xml export-ignore
phpcs.xml.dist export-ignore
phpcs-compat.xml.dist export-ignore
composer.lock export-ignore
.prettierignore export-ignore
.nvmrc export-ignore
.wp-env.json export-ignore
49 changes: 22 additions & 27 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
<!-- Source of this Pull Request. Remove any that are not applicable. -->
### All Submissions:

**Issue**: #

**Ticket**:

**Slack Thread**:
<!-- Mark completed items with an [x] -->
* [ ] Does your code follow the [WooCommerce Sniffs](https://github.com/woocommerce/woocommerce-sniffs/) variant of WordPress coding standards?
* [ ] Have you written new tests for your changes, as applicable?
* [ ] Have you successfully run tests with your changes locally?
* [ ] Will this change require new documentation or changes to existing documentation?

---

### Description

<!-- Describe the changes made in this Pull Request and the reason for these changes. -->

### Steps to Test

<!-- Describe the steps to replicate the issue and confirm the fix. -->
<!-- Include as many details as possible. -->
### Changes proposed in this Pull Request:
<!-- Describe the changes made to this Pull Request and the reason for such changes. -->

1. Go to '…'
2. Click on '…'
3. Scroll down to …'

### Documentation

<!-- Will this change require new documentation or changes to existing documentation? -->
<!-- A good way to answer it is to ask: will more than one customer ever need to know about this? -->
- [ ] This PR needs documentation (has the "Documentation" label).
<!-- For an extra 💯 include further details about which change requires documentation. -->
Closes # .

### Changelog Entry
### Steps to test the changes in this Pull Request:
<!-- Describe the steps to replicate the issue and confirm the fix -->
<!-- Try to include as many details as possible. -->

> Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.
1.
1.
1.

Closes # .
### Changelog entry
<!--
Each line should start with change type prefix`(Add|Fix|Dev) - `.
If you remove the "Changelog entry" header, the Pull Request title will be used as the changelog entry.
Add the `changelog: none` label if no changelog entry is needed.
-->

> Add - Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.
39 changes: 39 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Basic set up for three package managers
# - Disables version-updates

version: 2
updates:
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: 'weekly'
# Disable version updates for GitHub Actions dependencies
open-pull-requests-limit: 0
labels:
- "changelog: none"
- "type: dependency"
- "github_actions"

# Maintain dependencies for npm
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: 'weekly'
# Disable version updates for npm dependencies
open-pull-requests-limit: 0
labels:
- "changelog: none"
- "type: dependency"
- "javascript"

# Maintain dependencies for Composer
- package-ecosystem: 'composer'
directory: '/'
schedule:
interval: 'weekly'
# Disable version updates for Composer dependencies
open-pull-requests-limit: 0
labels:
- "changelog: none"
- "type: dependencies"
- "php"
112 changes: 112 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: E2E test

on:
push:
branches:
- smoke-testing
pull_request:
types: [ opened, synchronize, reopened, labeled ]
branches:
- trunk

jobs:
e2e:
if: "${{ ( github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'needs: e2e testing') ) || github.event_name == 'push' }}"
name: E2E Test
runs-on: ubuntu-latest
env:
PAYFAST_MERCHANT_ID: ${{secrets.PAYFAST_MERCHANT_ID}}
PAYFAST_MERCHANT_KEY: ${{secrets.PAYFAST_MERCHANT_KEY}}
PAYFAST_PASSPHRASE: ${{secrets.PAYFAST_PASSPHRASE}}

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

- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Node cache
uses: actions/cache@v3
with:
path: |
node_modules
~/.npm
key: node-${{ hashFiles('package-lock.json') }}

- name: Node install
run: npm install

- name: Build
run: npm run build

- name: Install Playwright Browsers
run: npx playwright install chromium

- name: Install required WP plugins
run: |
URL_CONFIG="url.https://${{ secrets.BOT_GITHUB_TOKEN }}:[email protected]/.insteadOf [email protected]:"
git config --global $URL_CONFIG
npm run env:install-plugins
git config --global --unset $URL_CONFIG
- name: Setup WP environment
run: npm run env:start

- name: Run E2E Foundational Test
id: payfast_e2e_tests
if: ${{ github.event_name == 'pull_request' }}
run: npm run test:e2e-foundational

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

- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: tests/e2e/test-results/report
retention-days: 2
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v2.3.2
uses: actions/checkout@v3

- name: ⚙️ Install Utilities
run: sudo apt-get update && sudo apt-get install -y lftp --allow-downgrades;
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/php-compat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PHP Compatibility

on: pull_request

jobs:
php-compatibility:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup proper PHP version
uses: shivammathur/setup-php@v2
with:
php-version: 7.3
tools: composer

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install

- name: Run PHP Compatibility
run: ./vendor/bin/phpcs --standard=phpcs-compat.xml.dist -p .
56 changes: 0 additions & 56 deletions .github/workflows/php-compatibility.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: PHP Coding Standards

on: pull_request

jobs:
phpcs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup proper PHP version
uses: shivammathur/setup-php@v2
with:
php-version: 7.3
tools: composer

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
files: |
**/*.php
- name: Install dependencies
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
run: composer install

- name: Run PHP_CodeSniffer
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
run: |
HEAD_REF=$(git rev-parse HEAD)
git checkout $HEAD_REF
./vendor/bin/phpcs-changed -s --git --git-base origin/${{ github.base_ref }} ${{ steps.changed-files.outputs.all_changed_files }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ tests/e2e/config/local-*
build

woocommerce-gateway-payfast.zip
tests/e2e/test-results
tests/e2e/test-plugins/woocommerce-subscriptions/

tests/e2e/config/.env
Loading

0 comments on commit bde1fb2

Please sign in to comment.