Ticket #8421: 8421-2.patch
File 8421-2.patch, 9.2 KB (added by , 3 years ago) |
---|
-
new file .github/workflows/coding-standards.yml
diff --git .github/workflows/coding-standards.yml .github/workflows/coding-standards.yml new file mode 100644 index 000000000..ba8e1f042
- + 1 name: Coding Standards 2 3 on: 4 push: 5 branches: [ master ] 6 7 jobs: 8 phpcs: 9 name: PHPCS 10 runs-on: ubuntu-latest 11 strategy: 12 fail-fast: true 13 matrix: 14 php: ['7.4'] 15 16 steps: 17 - name: Cancel previous runs of this workflow 18 uses: styfle/cancel-workflow-action@0.5.0 19 with: 20 access_token: ${{ github.token }} 21 22 - name: Checkout code 23 uses: actions/checkout@v2 24 25 - name: Setup PHP 26 uses: shivammathur/setup-php@v2 27 with: 28 php-version: ${{ matrix.php }} 29 tools: composer:v2 30 coverage: none 31 32 - name: Log information 33 run: | 34 echo "$GITHUB_REF" 35 echo "$GITHUB_EVENT_NAME" 36 git --version 37 php --version 38 composer --version 39 40 - name: Validate Composer 41 run: composer validate --strict 42 43 - name: Install dependencies 44 uses: ramsey/composer-install@v1 45 with: 46 composer-options: "--ignore-platform-reqs" 47 48 - name: Run PHPCS 49 run: composer phpcs -
new file .github/workflows/unit-tests.yml
diff --git .github/workflows/unit-tests.yml .github/workflows/unit-tests.yml new file mode 100644 index 000000000..213eb2b8f
- + 1 name: Unit Tests 2 3 on: 4 push: 5 branches: [ master ] 6 7 jobs: 8 tests: 9 name: "WP: ${{ matrix.wp_version }} - PHP: ${{ matrix.php }}" 10 runs-on: ubuntu-latest 11 strategy: 12 fail-fast: false 13 matrix: 14 php: ['7.4', '8.0'] 15 wp_version: ['master'] 16 include: 17 - php: '8.0' 18 wp_version: '5.7' 19 - php: '7.4' 20 wp_version: '5.7' 21 env: 22 WP_ENV_PHP_VERSION: ${{ matrix.php }} 23 WP_VERSION: ${{ matrix.wp_version }} 24 25 steps: 26 - name: Cancel previous runs of this workflow 27 uses: styfle/cancel-workflow-action@0.5.0 28 with: 29 access_token: ${{ github.token }} 30 31 - name: Checkout repository 32 uses: actions/checkout@v2 33 34 - name: Setup PHP 35 uses: shivammathur/setup-php@v2 36 with: 37 php-version: ${{ matrix.php }} 38 tools: composer:v2 39 coverage: none 40 41 - name: Log information 42 run: | 43 echo "$GITHUB_REF" 44 echo "$GITHUB_EVENT_NAME" 45 npm --version 46 node --version 47 git --version 48 php --version 49 composer --version 50 51 - name: Validate Composer 52 run: composer validate --strict 53 54 - name: Install Composer dependencies 55 uses: ramsey/composer-install@v1 56 with: 57 composer-options: "--ignore-platform-reqs" 58 59 - name: Cache node modules 60 uses: actions/cache@v2 61 env: 62 cache-name: cache-node-modules 63 with: 64 # npm cache files are stored in `~/.npm` on Linux/macOS 65 path: ~/.npm 66 key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} 67 restore-keys: | 68 ${{ runner.os }}-build-${{ env.cache-name }}- 69 ${{ runner.os }}-build- 70 ${{ runner.os }}- 71 72 - name: Validate node modules 73 run: if [[ -f package.json ]]; then npm audit --audit-level=high --production --cache ~/.npm; fi 74 75 - name: Install node modules 76 run: npm ci --cache ~/.npm 77 78 - name: Setup WordPress 79 run: echo "{\"core\":\"WordPress/WordPress#${WP_VERSION}\"}" >> .wp-env.override.json 80 81 - name: Install WordPress 82 run: | 83 chmod -R 767 ./ 84 npm run wp-env start -- --update 85 86 - name: Running single site unit tests 87 run: npm run test-php 88 if: ${{ success() || failure() }} 89 90 - name: Running multi site unit tests 91 run: npm run test-php-multisite 92 if: ${{ success() || failure() }} 93 94 - name: Stop Docker environment 95 run: npm run wp-env stop 96 if: ${{ success() || failure() }} -
.gitignore
diff --git .gitignore .gitignore index cc3f92c79..a08f6858b 100644
build 26 26 27 27 # The custom Docker config file. 28 28 .wp-env.override.json 29 30 # Cache files 31 .phpcs/*.json -
new file .phpcs/.gitkeep
diff --git .phpcs/.gitkeep .phpcs/.gitkeep new file mode 100644 index 000000000..38955e325
- + 1 # This directory can't be empty. -
composer.json
diff --git composer.json composer.json index 3bf5b45c3..d936760ee 100644
33 33 "require-dev": { 34 34 "phpcompatibility/phpcompatibility-wp": "^2.1.0", 35 35 "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", 36 "squizlabs/php_codesniffer" : "^3.5.4", 37 "wp-coding-standards/wpcs": "*", 36 38 "wp-phpunit/wp-phpunit": "^5.6", 37 39 "phpunit/phpunit": "^7.5" 40 }, 41 "scripts": { 42 "phpcs" : "phpcs . --basepath=." 38 43 } 39 44 } -
package.json
diff --git package.json package.json index 13a9f6cc5..74ffdb363 100644
5 5 }, 6 6 "description": "BuddyPress adds community features to WordPress. Member Profiles, Activity Streams, Direct Messaging, Notifications, and more!", 7 7 "devDependencies": { 8 "@babel/core": " ^7.11.6",9 "@wordpress/babel-preset-default": " ^5.0.1",8 "@babel/core": "~7.13.14", 9 "@wordpress/babel-preset-default": "~5.1.0", 10 10 "@wordpress/browserslist-config": "~3.0.1", 11 "@wordpress/env": "^ 3.0.2",11 "@wordpress/env": "^4.0.0", 12 12 "autoprefixer": "~8.5.2", 13 13 "grunt": "~1.3.0", 14 14 "grunt-check-dependencies": "~1.0.0", … … 18 18 "grunt-contrib-cssmin": "^3.0.0", 19 19 "grunt-contrib-imagemin": "~4.0.0", 20 20 "grunt-contrib-jshint": "^2.1.0", 21 "grunt-contrib-uglify": " ^5.0.0",21 "grunt-contrib-uglify": "~5.0.1", 22 22 "grunt-contrib-watch": "~1.1.0", 23 23 "grunt-exec": "^3.0.0", 24 24 "grunt-jsvalidate": "~0.2.2", 25 25 "grunt-legacy-util": "^2.0.0", 26 "grunt-patch-wordpress": "~3.0. 0",26 "grunt-patch-wordpress": "~3.0.1", 27 27 "grunt-postcss": "~0.9.0", 28 "grunt-rtlcss": "~2.0. 1",28 "grunt-rtlcss": "~2.0.2", 29 29 "grunt-sass": "~2.0.0", 30 30 "grunt-stylelint": "~0.15.0", 31 31 "matchdep": "~2.0.0", 32 "parcel-bundler": "~1.12. 4",33 "phplint": " ^2.0.1",32 "parcel-bundler": "~1.12.5", 33 "phplint": "~2.0.5", 34 34 "postcss-scss": "~2.0.0", 35 35 "stylelint": "~13.6.1", 36 36 "stylelint-config-wordpress": "~17.0.0" … … 74 74 "extends @wordpress/browserslist-config" 75 75 ], 76 76 "dependencies": { 77 "postcss": "~7.0.3 2"77 "postcss": "~7.0.35" 78 78 } 79 79 } -
new file phpcs.xml.dist
diff --git phpcs.xml.dist phpcs.xml.dist new file mode 100644 index 000000000..b206b6501
- + 1 <?xml version="1.0"?> 2 <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="BuddyPress" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> 3 <description>PHP_CodeSniffer standard for the BuddyPress plugin.</description> 4 5 <!-- Load WordPress standards --> 6 <rule ref="WordPress"/> 7 8 <!-- Load PHPCompatibilityWP standards --> 9 <rule ref="PHPCompatibilityWP" /> 10 11 <!-- Configure the PHP version --> 12 <config name="testVersion" value="5.6-"/> 13 14 <!-- Check against minimum WP version. --> 15 <config name="minimum_supported_wp_version" value="4.9"/> 16 17 <!-- Don't fail CI build on warnings. --> 18 <config name="ignore_warnings_on_exit" value="1"/> 19 20 <!-- 21 Pass some flags to PHPCS: 22 p flag: Show progress of the run. 23 s flag: Show sniff codes in all reports. 24 --> 25 <arg value="ps" /> 26 27 <!-- Enable colors in report --> 28 <arg name="colors"/> 29 30 <!-- Cache the scan results and re-use those for unchanged files on the next scan. --> 31 <arg name="cache" value=".phpcs/cache.json" /> 32 33 <!-- Check 20 files in parallel. --> 34 <arg name="parallel" value="20"/> 35 36 <!-- Set severity to 1 to see everything that isn't effectively turned off. --> 37 <arg name="severity" value="6" /> 38 39 <!-- PHP files only, for now. --> 40 <arg name="extensions" value="php" /> 41 42 <!-- What to exclude --> 43 <exclude-pattern>*/**/tests/</exclude-pattern> 44 <exclude-pattern>*/node_modules/*</exclude-pattern> 45 <exclude-pattern>*/vendor/*</exclude-pattern> 46 47 <!-- What to exclude from the plugin --> 48 <exclude-pattern>*/**/**/deprecated/*</exclude-pattern> 49 50 <rule ref="WordPress.WP.I18n"> 51 <properties> 52 <property name="text_domain" type="array"> 53 <element value="buddypress" /> 54 </property> 55 </properties> 56 </rule> 57 58 <!-- Allow array disalignment --> 59 <rule ref="WordPress"> 60 <exclude name="WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned"/> 61 </rule> 62 </ruleset> -
tests/phpunit/assets/phpunit-wp-config.php
diff --git tests/phpunit/assets/phpunit-wp-config.php tests/phpunit/assets/phpunit-wp-config.php index 5113dd55b..25f0abd81 100644
define( 'DB_NAME', 'tests-wordpress'); 26 26 define( 'DB_USER', 'root'); 27 27 28 28 /** MySQL database password */ 29 define( 'DB_PASSWORD', ' ');29 define( 'DB_PASSWORD', 'password'); 30 30 31 31 /** MySQL hostname */ 32 define( 'DB_HOST', ' mysql');32 define( 'DB_HOST', 'tests-mysql'); 33 33 34 34 /** Database Charset to use in creating database tables. */ 35 35 define( 'DB_CHARSET', 'utf8');