Skip to content

Commit

Permalink
Merge branch 'develop' into fix/optimise-capture-charge-calls
Browse files Browse the repository at this point in the history
  • Loading branch information
anu-rock authored Sep 14, 2023
2 parents 4958980 + 4fa9b05 commit 2fb4c9b
Show file tree
Hide file tree
Showing 982 changed files with 39,915 additions and 13,822 deletions.
6 changes: 4 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
"definedTags": [ "format" ]
}
],
"yoda": [ "error", "always" ],
/* partially disable rules to get @woocommerce/eslint-plugin integration done */
"jsdoc/no-undefined-types": "off",
"jsdoc/require-param": "off",
Expand Down Expand Up @@ -138,7 +137,10 @@
"wpcalypso/jsx-classname-namespace": "off",
"react/react-in-jsx-scope": "error",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
"@typescript-eslint/no-shadow": "error",
"jsdoc/require-param-type": 0,
"jsdoc/require-returns-type": 0,
"valid-jsdoc": "off"
}
}
]
Expand Down
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# See: https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

# Each line is a file pattern followed by one or more owners.

# Harmony owns any files in the .github directory at the root of the repository and any of its subdirectories.
/.github/ @Automattic/harmony
27 changes: 27 additions & 0 deletions .github/actions/commit-push-as-bot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Commit and push as the github-actions bot"
description: "Commit and push as the github-actions bot"

inputs:
release-version:
description: "The release version to be used in the commit message"
required: true
branch:
description: "The branch where the commit will be pushed"
required: true

runs:
using: composite
steps:
- name: "Commit and push changes"
id: build_plugin
shell: bash
env:
RELEASE_VERSION: ${{ inputs.release-version }}
BRANCH_NAME: ${{ inputs.branch }}
run: |
git config user.name "github-actions[bot]"
# We could consider fetching the bot's ID through an API call to be future-proof. Hardcoded for now.
# See https://github.com/Automattic/woocommerce-payments/pull/5200#discussion_r1034560144
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -am "Update version and add changelog entries for release $RELEASE_VERSION"
git push --set-upstream origin $BRANCH_NAME
8 changes: 2 additions & 6 deletions .github/actions/e2e/env-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ runs:
run: echo -e "machine github.com\n login $E2E_GH_TOKEN" > ~/.netrc

# PHP setup
- name: PHP Setup
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none
- name: "Set up PHP"
uses: ./.github/actions/setup-php

# Composer setup
- name: Setup Composer
Expand Down
64 changes: 46 additions & 18 deletions .github/actions/process-changelog/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,47 +22,75 @@ outputs:
runs:
using: composite
steps:
- name: "Verify the action type"
id: verify_action_type
if: ${{ inputs.action-type == 'generate' }}
shell: bash
env:
RELEASE_VERSION: ${{ inputs.release-version }}
RELEASE_DATE: ${{ inputs.release-date }}
ACTION_TYPE: ${{ inputs.action-type }}
run: |
FINAL_RELEASE_VERSION=$(echo "$RELEASE_VERSION" | grep -Po '\d.\d.\d(.*?)') # Keep only x.y.z from x.y.z(-test-n)
CURRENT_RELEASE_VERSION=$(jq '.version' package.json -r)
# If the changelog directory is empty (except .gitkeep) and the final release version is already defined in package.json, we need to switch to amend
# This use case is mainly for the last test package created from the release branch, to avoid an empty changelog
if [ "$(ls -A changelog | wc -l)" -eq 1 ] && [[ "$FINAL_RELEASE_VERSION" == "$CURRENT_RELEASE_VERSION" ]]; then
echo "ACTION_TYPE=amend-version" >> $GITHUB_OUTPUT
echo "CURRENT_VERSION=$CURRENT_RELEASE_VERSION" >> $GITHUB_OUTPUT
fi
- name: "Process changelog for changelog.txt"
id: process_changelog
shell: bash
env:
ACTION_TYPE: ${{ inputs.action-type }}
ACTION_TYPE: ${{ steps.verify_action_type.outputs.ACTION_TYPE || inputs.action-type }}
CURRENT_VERSION: ${{ steps.verify_action_type.outputs.CURRENT_VERSION }}
RELEASE_VERSION: ${{ inputs.release-version }}
RELEASE_DATE: ${{ inputs.release-date }}
run: |
# Install this dev package globally to gather changelog entries while not including it into the release package
composer global require automattic/jetpack-changelogger:^3.0.7
if ${{ env.ACTION_TYPE == 'generate' }}; then
CHANGELOG_FLAG=""
echo "Generating the changelog entries." >> $GITHUB_STEP_SUMMARY
if ${{ env.ACTION_TYPE == 'amend-version' }}; then
sed -i "s/^= $CURRENT_VERSION - .* =$/= $RELEASE_VERSION - $RELEASE_DATE =/" changelog.txt
else
CHANGELOG_FLAG="--amend"
echo "Amending the changelog entries." >> $GITHUB_STEP_SUMMARY
fi
# Install this dev package globally to gather changelog entries while not including it into the release package
composer global require automattic/jetpack-changelogger:^3.0.7
~/.composer/vendor/bin/changelogger write --use-version="$RELEASE_VERSION" --release-date="$RELEASE_DATE" $CHANGELOG_FLAG --no-interaction --yes
if ${{ env.ACTION_TYPE == 'generate' }}; then
CHANGELOG_FLAG=""
echo "Generating the changelog entries." >> $GITHUB_STEP_SUMMARY
else
CHANGELOG_FLAG="--amend"
echo "Amending the changelog entries." >> $GITHUB_STEP_SUMMARY
fi
~/.composer/vendor/bin/changelogger write --use-version="$RELEASE_VERSION" --release-date="$RELEASE_DATE" $CHANGELOG_FLAG --no-interaction --yes
fi
echo "Picking up changelog for version '$RELEASE_VERSION'..."
CHANGELOG=$(awk '/^= / { if (p) { exit }; p=1; next } p && NF' changelog.txt)
echo "$CHANGELOG"
# Escape backslash, new line and ampersand characters. The order is important.
CHANGELOG=${CHANGELOG//\\/\\\\}
CHANGELOG=${CHANGELOG//$'\n'/\\n}
CHANGELOG=${CHANGELOG//&/\\&}
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_OUTPUT
- name: "Process changelog for readme.txt"
shell: bash
env:
ACTION_TYPE: ${{ inputs.action-type }}
ACTION_TYPE: ${{ steps.verify_action_type.outputs.ACTION_TYPE || inputs.action-type }}
CURRENT_VERSION: ${{ steps.verify_action_type.outputs.CURRENT_VERSION }}
RELEASE_VERSION: ${{ inputs.release-version }}
RELEASE_DATE: ${{ inputs.release-date }}
CHANGELOG: ${{ steps.process_changelog.outputs.CHANGELOG }}
run: |
if ${{ env.ACTION_TYPE == 'amend' }}; then
perl -i -p0e "s/= $RELEASE_VERSION.*?(\n){2}//s" readme.txt # Delete the existing changelog for the release version first
fi
if ${{ env.ACTION_TYPE == 'amend-version' }}; then
sed -i "s/^= $CURRENT_VERSION - .* =$/= $RELEASE_VERSION - $RELEASE_DATE =/" readme.txt
else
if ${{ env.ACTION_TYPE == 'amend' }}; then
perl -i -p0e "s/= $RELEASE_VERSION.*?(\n){2}//s" readme.txt # Delete the existing changelog for the release version first
fi
sed -ri "s|(== Changelog ==)|\1\n\n= $RELEASE_VERSION - $RELEASE_DATE =\n$CHANGELOG|" readme.txt
sed -ri "s|(== Changelog ==)|\1\n\n= $RELEASE_VERSION - $RELEASE_DATE =\n$CHANGELOG|" readme.txt
fi
19 changes: 19 additions & 0 deletions .github/actions/setup-php/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "Set up PHP"
description: "Extracts the required PHP version from plugin file and uses it to build PHP."

runs:
using: composite
steps:
- name: "Get minimum PHP version"
shell: bash
id: get_min_php_version
run: |
MIN_PHP_VERSION=$(sed -n 's/.*PHP: //p' woocommerce-payments.php)
echo "MIN_PHP_VERSION=$MIN_PHP_VERSION" >> $GITHUB_OUTPUT
- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ steps.get_min_php_version.outputs.MIN_PHP_VERSION }}
tools: composer
coverage: none
19 changes: 5 additions & 14 deletions .github/actions/setup-repo/action.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
name: "Setup WooCommerce Payments repository"
description: "Handles the installation, building, and caching of the projects within the repository."

inputs:
php-version:
description: "The version of PHP that the action should set up."
default: "7.4"

runs:
using: composite
steps:
- name: "Setup Node"
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
node-version-file: ".nvmrc"
cache: "npm"

- name: "Enable composer dependencies caching"
uses: actions/cache@v3
with:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}

- name: "Setup PHP"
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: composer
coverage: none

- name: "Set up PHP"
uses: ./.github/actions/setup-php
2 changes: 1 addition & 1 deletion .github/workflows/build-zip-and-run-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
jobs:
build-zip:
name: "Build the zip file"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
uses: actions/checkout@v3
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/check-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ concurrency:
jobs:
check-changelog:
name: Check changelog
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
# clone the repository
- uses: actions/checkout@v3
Expand All @@ -22,11 +22,8 @@ jobs:
path: ~/.cache/composer/
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
# setup PHP, but without debug extensions for reasonable performance
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
coverage: none
- name: "Set up PHP"
uses: ./.github/actions/setup-php
# Install composer packages.
- run: composer self-update && composer install --no-progress
# Fetch the target branch before running the check.
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on:
pull_request

env:
WC_MIN_SUPPORTED_VERSION: '7.5.0'
WP_MIN_SUPPORTED_VERSION: '6.0'
PHP_MIN_SUPPORTED_VERSION: '7.3'
WC_MIN_SUPPORTED_VERSION: '7.7.0'
WP_MIN_SUPPORTED_VERSION: '6.1'
PHP_MIN_SUPPORTED_VERSION: '7.4'
GUTENBERG_VERSION_FOR_WP_MIN: '15.7.0'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -15,21 +16,21 @@ concurrency:
jobs:
generate-wc-compat-matrix:
name: "Generate the matrix for woocommerce compatibility dynamically"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
- name: "Generate matrix"
id: generate_matrix
run: |
WC_VERSIONS=$( echo "[\"$WC_MIN_SUPPORTED_VERSION\", \"latest\", \"beta\"]" )
MATRIX_INCLUDE=$( echo "[{\"woocommerce\":\"$WC_MIN_SUPPORTED_VERSION\",\"wordpress\":\"$WP_MIN_SUPPORTED_VERSION\",\"gutenberg\":\"13.6.0\",\"php\":\"$PHP_MIN_SUPPORTED_VERSION\"}]" )
MATRIX_INCLUDE=$( echo "[{\"woocommerce\":\"$WC_MIN_SUPPORTED_VERSION\",\"wordpress\":\"$WP_MIN_SUPPORTED_VERSION\",\"gutenberg\":\"$GUTENBERG_VERSION_FOR_WP_MIN\",\"php\":\"$PHP_MIN_SUPPORTED_VERSION\"}]" )
echo "matrix={\"woocommerce\":$WC_VERSIONS,\"wordpress\":[\"latest\"],\"gutenberg\":[\"latest\"],\"php\":[\"7.4\"], \"include\":$MATRIX_INCLUDE}" >> $GITHUB_OUTPUT
woocommerce-compatibility:
name: "WC compatibility"
needs: generate-wc-compat-matrix
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
WP_VERSION: ${{ matrix.wordpress }}
WC_VERSION: ${{ matrix.woocommerce }}
Expand Down Expand Up @@ -57,7 +58,7 @@ jobs:

generate-wc-compat-beta-matrix:
name: "Generate the matrix for compatibility-woocommerce-beta dynamically"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
Expand All @@ -71,7 +72,7 @@ jobs:
compatibility-woocommerce-beta:
name: Environment - WC beta
needs: generate-wc-compat-beta-matrix
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-wc-compat-beta-matrix.outputs.matrix) }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ concurrency:
jobs:
woocommerce-coverage:
name: Code coverage
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 10
Expand Down
27 changes: 18 additions & 9 deletions .github/workflows/create-pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defaults:
jobs:
create-release:
name: "Create the pre-release"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
env:
RELEASE_VERSION: ${{ inputs.releaseVersion }}

Expand All @@ -33,24 +33,33 @@ jobs:
with:
version: ${{ env.RELEASE_VERSION }}

- name: "Create a test tag"
id: create_tag
uses: ./.github/actions/create-tag
with:
version: ${{ env.RELEASE_VERSION }}

- name: "Generate the changelog"
id: generate_changelog
uses: ./.github/actions/process-changelog
with:
release-version: ${{ steps.create_tag.outputs.trimmed-version }}
release-version: ${{ steps.create_branch.outputs.trimmed-version }}

- name: "Bump version header"
env:
VERSION: ${{ steps.create_tag.outputs.trimmed-version }}
VERSION: ${{ steps.create_branch.outputs.trimmed-version }}
run: |
sed -i "s/^ \* Version: .*$/ * Version: $VERSION/" woocommerce-payments.php
- name: "Commit and push changes"
env:
BRANCH_NAME: ${{ steps.create_branch.outputs.branch-name }}
RELEASE_VERSION: ${{ steps.create_branch.outputs.trimmed-version }}
uses: ./.github/actions/commit-push-as-bot
with:
release-version: ${{ env.RELEASE_VERSION }}
branch: ${{ env.BRANCH_NAME }}

- name: "Create a test tag"
id: create_tag
uses: ./.github/actions/create-tag
with:
version: ${{ env.RELEASE_VERSION }}

- name: "Build the plugin"
id: build_plugin
uses: ./.github/actions/build
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/e2e-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ env:
WCPAY_USE_BUILD_ARTIFACT: ${{ inputs.wcpay-use-build-artifact }}
WCPAY_ARTIFACT_DIRECTORY: 'zipfile'
NODE_ENV: 'test'
FORCE_E2E_DEPS_SETUP: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
wcpay-e2e-tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

strategy:
fail-fast: false
Expand Down
Loading

0 comments on commit 2fb4c9b

Please sign in to comment.