Skip to content

Commit

Permalink
Merge branch 'trunk' into 48244-i18n-wplink
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwilsoncc committed Oct 8, 2023
2 parents 0c3c40c + eb0ae56 commit 0017e22
Show file tree
Hide file tree
Showing 2,737 changed files with 255,257 additions and 70,717 deletions.
25 changes: 25 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "WordPress Core Development",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"username": "wordpress"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "16"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/git:1": {}
},
"onCreateCommand": "sudo chmod +x .devcontainer/install-tools.sh && .devcontainer/install-tools.sh",
"postCreateCommand": "sudo chmod +x .devcontainer/setup.sh && .devcontainer/setup.sh",
"forwardPorts": [
8080
],
"remoteUser": "wordpress"
}
29 changes: 29 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3.1'

services:
app:
image: wordpress
restart: always
ports:
- 8080:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- ../..:/workspaces:cached

db:
image: mariadb
restart: unless-stopped
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql

volumes:
db:
15 changes: 15 additions & 0 deletions .devcontainer/install-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

set -eux

echo "Installing wp-cli..."
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
sudo chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

echo "Installing chromium..."
sudo apt-get update
sudo apt-get -y install --no-install-recommends chromium

# Copy the welcome message
sudo cp .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt
18 changes: 18 additions & 0 deletions .devcontainer/setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

set -eux

if [ -z ${CODESPACE_NAME+x} ]; then
SITE_HOST="http://localhost:8080"
else
SITE_HOST="https://${CODESPACE_NAME}-8080.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}"
fi

# Install dependencies
cd /workspaces/wordpress-develop
npm install && npm run build:dev

# Install WordPress and activate the plugin/theme.
cd /var/www/html
echo "Setting up WordPress at $SITE_HOST"
wp core install --url="$SITE_HOST" --title="WordPress Trunk" --admin_user="admin" --admin_email="[email protected]" --admin_password="password" --skip-email
6 changes: 6 additions & 0 deletions .devcontainer/welcome-message.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
👋 Welcome to "WordPress Core Development" in Codespaces!

🛠️ Your environment is fully setup with all the required software.

🚀 To get started, wait for the "postCreateCommand" to finish setting things up, then open the portforwarded URL and append '/wp-admin'.

20 changes: 17 additions & 3 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@ LOCAL_DIR=src
# The PHP version to use. Valid options are 'latest', and '{version}-fpm'.
LOCAL_PHP=latest

# Whether or not to enable XDebug.
# Whether or not to enable Xdebug.
LOCAL_PHP_XDEBUG=false

##
# The Xdebug features to enable.
#
# By default, the following features are enabled in the local environment:
# - Development helpers (`develop`).
# - Step debugging (`debug`).
#
# To generate a code coverage report, `coverage` mode must be active.
#
# For a full list of accepted values, see https://xdebug.org/docs/all_settings#mode.
##
LOCAL_PHP_XDEBUG_MODE=develop,debug

# Whether or not to enable Memcached.
LOCAL_PHP_MEMCACHED=false

Expand All @@ -35,8 +48,8 @@ LOCAL_DB_TYPE=mysql
#
# Defaults to 5.7 with the assumption that LOCAL_DB_TYPE is set to `mysql` above.
#
# When using `mysql`, see https://hub.docker.com/_/mysql/ for valid versions.
# When using `mariadb`, see https://hub.docker.com/_/mariadb for valid versions.
# When using `mysql`, see https://hub.docker.com/r/amd64/mysql for valid versions.
# When using `mariadb`, see https://hub.docker.com/r/amd64/mariadb for valid versions.
##
LOCAL_DB_VERSION=5.7

Expand All @@ -46,6 +59,7 @@ LOCAL_WP_DEBUG_LOG=true
LOCAL_WP_DEBUG_DISPLAY=true
LOCAL_SCRIPT_DEBUG=true
LOCAL_WP_ENVIRONMENT_TYPE=local
LOCAL_WP_DEVELOPMENT_MODE=core

# The URL to use when running e2e tests.
WP_BASE_URL=http://localhost:${LOCAL_PORT}
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ updates:
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
133 changes: 91 additions & 42 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ on:
- '3.[89]'
- '[4-9].[0-9]'
tags:
- '3.[89]*'
- '[4-9].[0-9]*'
- '[0-9]+.[0-9]'
- '[0-9]+.[0-9].[0-9]+'
- '!3.7.[0-9]+'
pull_request:
branches:
- trunk
Expand All @@ -20,7 +21,7 @@ on:
# Any change to a PHP or JavaScript file should run checks.
- '**.js'
- '**.php'
# These files configure NPM. Changes could affect the outcome.
# These files configure npm. Changes could affect the outcome.
- 'package*.json'
# These files configure Composer. Changes could affect the outcome.
- 'composer.*'
Expand All @@ -39,6 +40,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

# Disable permissions for all available scopes by default.
# Any needed permissions should be configured at the job level.
permissions: {}

jobs:
# Runs PHP coding standards checks.
#
Expand All @@ -47,64 +52,74 @@ jobs:
# Performs the following steps:
# - Checks out the repository.
# - Sets up PHP.
# - Logs debug information.
# - Configures caching for PHPCS scans.
# - Installs Composer dependencies (use cache if possible).
# - Installs Composer dependencies.
# - Make Composer packages available globally.
# - Logs PHP_CodeSniffer debug information.
# - Runs PHPCS on the full codebase with warnings suppressed.
# - Generate a report for displaying issues as pull request annotations.
# - Runs PHPCS on the `tests` directory without warnings suppressed.
# - Generate a report for displaying `test` directory issues as pull request annotations.
# - Ensures version-controlled files are not modified or deleted.
phpcs:
name: PHP coding standards
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}

steps:
- name: Checkout repository
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Set up PHP
uses: shivammathur/setup-php@d37cc3048580de06099c81ded417530716a0d7ab # v2.18.0
uses: shivammathur/setup-php@4bd44f22a98a19e0950cbad5f31095157cc9621b # v2.25.4
with:
php-version: '7.4'
php-version: 'latest'
coverage: none
tools: composer, cs2pr

- name: Log debug information
run: |
php --version
composer --version
tools: cs2pr

# This date is used to ensure that the PHPCS cache is cleared at least once every week.
# http://man7.org/linux/man-pages/man1/date.1.html
- name: "Get last Monday's date"
id: get-date
run: echo "::set-output name=date::$(/bin/date -u --date='last Mon' "+%F")"
run: echo "date=$(/bin/date -u --date='last Mon' "+%F")" >> $GITHUB_OUTPUT

- name: Cache PHPCS scan cache
uses: actions/cache@136d96b4aee02b1f0de3ba493b1d47135042d9c0 # v3.0.1
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3.3.1
with:
path: .cache/phpcs.json
path: |
.cache/phpcs-src.json
.cache/phpcs-tests.json
key: ${{ runner.os }}-date-${{ steps.get-date.outputs.date }}-phpcs-cache-${{ hashFiles('**/composer.json', 'phpcs.xml.dist') }}

# Since Composer dependencies are installed using `composer update` and no lock file is in version control,
# passing a custom cache suffix ensures that the cache is flushed at least once per week.
- name: Install Composer dependencies
uses: ramsey/composer-install@f680dac46551dffb2234a240d65ae806c2999dd6 # v2.1.0
uses: ramsey/composer-install@83af392bf5f031813d25e6fe4cd626cdba9a2df6 # v2.2.0
with:
composer-options: "--no-progress --no-ansi --no-interaction"
custom-cache-suffix: ${{ steps.get-date.outputs.date }}

- name: Make Composer packages available globally
run: echo "${PWD}/vendor/bin" >> $GITHUB_PATH

- name: Log PHPCS debug information
run: phpcs -i

- name: Run PHPCS on all Core files
run: phpcs -q -n --report=checkstyle | cs2pr
id: phpcs-core
run: phpcs -n --report-full --cache=./.cache/phpcs-src.json --report-checkstyle=./.cache/phpcs-report.xml

- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs-core.outcome == 'failure' }}
run: cs2pr ./.cache/phpcs-report.xml

- name: Check test suite files for warnings
run: phpcs tests -q --report=checkstyle | cs2pr
id: phpcs-tests
run: phpcs tests --report-full --cache=./.cache/phpcs-tests.json --report-checkstyle=./.cache/phpcs-tests-report.xml

- name: Show test suite scan results in PR
if: ${{ always() && steps.phpcs-tests.outcome == 'failure' }}
run: cs2pr ./.cache/phpcs-tests-report.xml

- name: Ensure version-controlled files are not modified during the tests
run: git diff --exit-code
Expand All @@ -115,33 +130,29 @@ jobs:
#
# Performs the following steps:
# - Checks out the repository.
# - Logs debug information about the runner container.
# - Installs NodeJS 14.
# - Logs updated debug information.
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Sets up Node.js.
# - Logs debug information about the GitHub Action runner.
# - Installs npm dependencies.
# - Run the WordPress JSHint checks.
# - Ensures version-controlled files are not modified or deleted.
jshint:
name: JavaScript coding standards
runs-on: ubuntu-latest
permissions:
contents: read
timeout-minutes: 20
if: ${{ github.repository == 'WordPress/wordpress-develop' || github.event_name == 'pull_request' }}
env:
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
PUPPETEER_SKIP_DOWNLOAD: ${{ true }}

steps:
- name: Checkout repository
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0

- name: Log debug information
run: |
npm --version
node --version
git --version
svn --version
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
with:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}

- name: Install NodeJS
uses: actions/setup-node@5b52f097d36d4b0b2f94ed6de710023fbb8b2236 # v3.1.0
- name: Set up Node.js
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1
with:
node-version-file: '.nvmrc'
cache: npm
Expand All @@ -150,8 +161,10 @@ jobs:
run: |
npm --version
node --version
git --version
svn --version
- name: Install Dependencies
- name: Install npm Dependencies
run: npm ci

- name: Run JSHint
Expand All @@ -163,12 +176,48 @@ jobs:
slack-notifications:
name: Slack Notifications
uses: WordPress/wordpress-develop/.github/workflows/slack-notifications.yml@trunk
permissions:
actions: read
contents: read
needs: [ phpcs, jshint ]
if: ${{ github.repository == 'WordPress/wordpress-develop' && github.event_name != 'pull_request' && always() }}
with:
calling_status: ${{ needs.phpcs.result == 'success' && needs.jshint.result == 'success' && 'success' || ( needs.phpcs.result == 'cancelled' || needs.jshint.result == 'cancelled' ) && 'cancelled' || 'failure' }}
calling_status: ${{ contains( needs.*.result, 'cancelled' ) && 'cancelled' || contains( needs.*.result, 'failure' ) && 'failure' || 'success' }}
secrets:
SLACK_GHA_SUCCESS_WEBHOOK: ${{ secrets.SLACK_GHA_SUCCESS_WEBHOOK }}
SLACK_GHA_CANCELLED_WEBHOOK: ${{ secrets.SLACK_GHA_CANCELLED_WEBHOOK }}
SLACK_GHA_FIXED_WEBHOOK: ${{ secrets.SLACK_GHA_FIXED_WEBHOOK }}
SLACK_GHA_FAILURE_WEBHOOK: ${{ secrets.SLACK_GHA_FAILURE_WEBHOOK }}

failed-workflow:
name: Failed workflow tasks
runs-on: ubuntu-latest
permissions:
actions: write
needs: [ phpcs, jshint, slack-notifications ]
if: |
always() &&
github.repository == 'WordPress/wordpress-develop' &&
github.event_name != 'pull_request' &&
github.run_attempt < 2 &&
(
contains( needs.*.result, 'cancelled' ) ||
contains( needs.*.result, 'failure' )
)
steps:
- name: Dispatch workflow run
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.1
with:
retries: 2
retry-exempt-status-codes: 418
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'failed-workflow.yml',
ref: 'trunk',
inputs: {
run_id: '${{ github.run_id }}'
}
});
Loading

0 comments on commit 0017e22

Please sign in to comment.