-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
3,595 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
use SebastianBergmann\CodeCoverage\CodeCoverage; | ||
use SebastianBergmann\CodeCoverage\Driver\Selector; | ||
use SebastianBergmann\CodeCoverage\Filter; | ||
use SebastianBergmann\CodeCoverage\Report\PHP; | ||
|
||
// phpcs:disable WordPress.PHP.DevelopmentFunctions.error_log_error_log | ||
|
||
$base_dir = __DIR__ . '/../plugins/two-factor-provider-webauthn'; | ||
if ( getenv( 'COLLECT_COVERAGE' ) === '1' && PHP_SAPI !== 'cli' && is_dir( $base_dir ) && is_dir( $base_dir . '/coverage-report' ) ) { | ||
/** @psalm-suppress UnresolvableInclude */ | ||
require_once $base_dir . '/vendor/autoload.php'; | ||
|
||
$filter = new Filter(); | ||
$filter->includeDirectory( $base_dir ); | ||
$filter->excludeDirectory( $base_dir . '/node_modules' ); | ||
$filter->excludeDirectory( $base_dir . '/stubs' ); | ||
$filter->excludeDirectory( $base_dir . '/vendor' ); | ||
|
||
$selector = new Selector(); | ||
$dt = new DateTime(); | ||
try { | ||
$coverage = new CodeCoverage( $selector->forLineCoverage( $filter ), $filter ); | ||
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized | ||
$coverage->start( sprintf( '%s %s - %s', ( $_SERVER['REQUEST_METHOD'] ?? '-' ), ( $_SERVER['REQUEST_URI'] ?? '-' ), $dt->format( 'YmdHisu' ) ) ); | ||
|
||
register_shutdown_function( function () use ( $coverage, $base_dir ) { | ||
$coverage->stop(); | ||
try { | ||
$php = new PHP(); | ||
$dt = new DateTime(); | ||
$php->process( $coverage, sprintf( '%s/coverage-report/%s.cov', $base_dir, $dt->format( 'YmdHisu' ) ) ); | ||
} catch ( Throwable $e ) { | ||
error_log( (string) $e ); | ||
} | ||
} ); | ||
} catch ( Throwable $e ) { | ||
error_log( (string) $e ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace WildWolf\WordPress\E2EHelper; | ||
|
||
use WP_Error; | ||
|
||
/** | ||
* @param mixed $preempt | ||
* @param array $_args | ||
* @param string $url | ||
* @return mixed | ||
*/ | ||
function pre_http_request( $preempt, array $_args, string $url ) /* NOSONAR */ { | ||
if ( false !== strpos( $url, '://api.wordpress.org/' ) ) { | ||
$preempt = new WP_Error( 'Forbidden' ); | ||
} else { | ||
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log | ||
error_log( $url ); | ||
} | ||
|
||
return $preempt; | ||
} | ||
|
||
if ( defined( '\\ABSPATH' ) ) { | ||
add_filter( 'pre_http_request', __NAMESPACE__ . '\\pre_http_request', 1, 3 ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": [ "plugin:@wordpress/eslint-plugin/recommended" ] | ||
"extends": [ | ||
"plugin:@wordpress/eslint-plugin/recommended", | ||
"plugin:playwright/playwright-test" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ name: Build and Test | |
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: E2E Testing | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
cancel-in-progress: true | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
e2e: | ||
name: Run E2E tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@v2.4.0 | ||
|
||
- name: Set up Node.js environment | ||
uses: actions/setup-node@v2.5.1 | ||
with: | ||
node-version: lts/* | ||
cache: npm | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@2.16.0 | ||
|
||
- name: Install Composer Dependencies | ||
uses: ramsey/composer-install@2.1.0 | ||
|
||
- name: Install Playwright | ||
run: npx playwright install chromium | ||
|
||
- name: Run PlaywrightE2E tests | ||
run: npm run test:e2e | ||
|
||
- name: Upload test results | ||
uses: actions/upload-artifact@v2 | ||
if: failure() | ||
with: | ||
name: playwright-test-results | ||
path: test-results/ | ||
retention-days: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ name: Code Standards Compliance Checks | |
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ name: Static Code Analysis | |
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/node_modules | ||
/vendor | ||
/test-results/ | ||
/playwright-report/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.