-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#50 PHP-Scoper がテスト可能に #51
Changes from 4 commits
04ae20f
f6f4291
34f8e37
6b2758c
87e8427
3cd35dc
a6e9ee5
ac3cafa
c7357f1
cf05a2a
fa6c5ca
7f8c8c3
0df79ca
e9e8959
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,28 @@ | ||||||||||||||||||||||||||||||||
name: Setup PHP Scoper | ||||||||||||||||||||||||||||||||
description: Setup PHP Scoper | ||||||||||||||||||||||||||||||||
inputs: | ||||||||||||||||||||||||||||||||
scoper: | ||||||||||||||||||||||||||||||||
description: Whether to do PHP Scoper | ||||||||||||||||||||||||||||||||
required: true | ||||||||||||||||||||||||||||||||
Comment on lines
+1
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The required: true
default: 'no' And changing lines 12 and 21 to: if: ${{ inputs.scoper == 'yes' }} This ensures that the condition matches the input value and avoids any ambiguity. |
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
Comment on lines
+1
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The 3: inputs:
4: scoper:
5: description: Whether to enable PHP Scoper
6: required: false
7: default: false |
||||||||||||||||||||||||||||||||
runs: | ||||||||||||||||||||||||||||||||
using: "composite" | ||||||||||||||||||||||||||||||||
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The
Comment on lines
+1
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The new hunk introduces a GitHub Actions workflow file for setting up PHP Scoper. It includes inputs for the |
||||||||||||||||||||||||||||||||
steps: | ||||||||||||||||||||||||||||||||
- name: Add Prefix | ||||||||||||||||||||||||||||||||
if: inputs.scoper | ||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||
composer global require humbug/php-scoper | ||||||||||||||||||||||||||||||||
~/.composer/vendor/bin/php-scoper add-prefix --output-dir=vendor-prefixed --force | ||||||||||||||||||||||||||||||||
composer dump-autoload --working-dir vendor-prefixed --classmap-authoritative | ||||||||||||||||||||||||||||||||
composer scoper-patch | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The current implementation assumes that the
Suggested change
|
||||||||||||||||||||||||||||||||
- name: Cleanup Vendor | ||||||||||||||||||||||||||||||||
if: inputs.scoper | ||||||||||||||||||||||||||||||||
run: rm -rf vendor | ||||||||||||||||||||||||||||||||
shell: bash | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The cleanup of the
Suggested change
|
||||||||||||||||||||||||||||||||
- name: Skip PHP Scoper | ||||||||||||||||||||||||||||||||
if: ! inputs.scoper | ||||||||||||||||||||||||||||||||
run: echo "Skipping Scoper" | ||||||||||||||||||||||||||||||||
shell: bash |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,7 +19,7 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||
php: [ '7.2', '7.4', '8.0' ] # PHP versions to check. | ||||||||||||||||||||||||||||||||||||||||||||||
wp: [ 'latest', '5.9' ] # WordPress version to check. | ||||||||||||||||||||||||||||||||||||||||||||||
tools: [ composer ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
scoper: [ true, false ] | ||||||||||||||||||||||||||||||||||||||||||||||
services: | ||||||||||||||||||||||||||||||||||||||||||||||
mysql: | ||||||||||||||||||||||||||||||||||||||||||||||
image: mysql:8.0 | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The |
||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -47,12 +47,20 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||
- name: Install dependencies | ||||||||||||||||||||||||||||||||||||||||||||||
run: composer install --prefer-dist --no-progress --no-suggest | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
46
to
47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI Add the --no-dev flag to exclude development dependencies if they are not required for testing purposes. 50: 53: 57: |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
47
to
48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The step installs dependencies using Composer. No issues found. |
||||||||||||||||||||||||||||||||||||||||||||||
- uses: ./.github/actions/php-scoper/action.yml | ||||||||||||||||||||||||||||||||||||||||||||||
name: Do PHP Scoper if possible | ||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||
scoper: ${{ matrix.scoper }} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI A new step named "Do PHP Scoper if possible" has been added. It uses the action defined in |
||||||||||||||||||||||||||||||||||||||||||||||
- name: Make Binaries Executionable | ||||||||||||||||||||||||||||||||||||||||||||||
if: matrix.scoper | ||||||||||||||||||||||||||||||||||||||||||||||
run: chmod +x vendor-prefixed/vendor/bin/* | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI A new step named "Make Binaries Executionable" has been added. It runs the command |
||||||||||||||||||||||||||||||||||||||||||||||
- name: Start MySQL | ||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||
sudo systemctl start mysql | ||||||||||||||||||||||||||||||||||||||||||||||
mysql -h 127.0.0.1 --port 3306 -u root --password=root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
59
to
61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI A step is added to start MySQL and alter the root user's password. No issues found.
Comment on lines
60
to
61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI Ensure that the workflow environment has the necessary permissions to execute the sudo systemctl start mysql and mysql commands. 65: 115: 118: 120: 123:
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
- name: Install WordPress | ||||||||||||||||||||||||||||||||||||||||||||||
run: bash bin/install-wp-tests.sh wordpress root root 127.0.0.1:3306 ${{ matrix.wp }} | ||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
63
to
64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI A step is added to install WordPress for testing purposes. No issues found. |
||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI Several steps have been added to the workflow file. Here are the specific line ranges and their corresponding issues:
Comment on lines
58
to
65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI Steps related to starting MySQL, installing WordPress, and running tests have been modified. There are no issues with these changes. |
||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -103,15 +111,13 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||
env: | ||||||||||||||||||||||||||||||||||||||||||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
135
to
137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI A new step is added to build the package. No issues found. |
||||||||||||||||||||||||||||||||||||||||||||||
- name: Build Package. | ||||||||||||||||||||||||||||||||||||||||||||||
- name: Build Package | ||||||||||||||||||||||||||||||||||||||||||||||
run: bash bin/build.sh | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
- name: Do PHP scoper | ||||||||||||||||||||||||||||||||||||||||||||||
run: | | ||||||||||||||||||||||||||||||||||||||||||||||
composer global require humbug/php-scoper | ||||||||||||||||||||||||||||||||||||||||||||||
~/.composer/vendor/bin/php-scoper add-prefix --output-dir=vendor-prefixed --force | ||||||||||||||||||||||||||||||||||||||||||||||
composer dump-autoload --working-dir vendor-prefixed --classmap-authoritative | ||||||||||||||||||||||||||||||||||||||||||||||
composer help-scoper | ||||||||||||||||||||||||||||||||||||||||||||||
- uses: ./.github/actions/php-scoper/action.yml | ||||||||||||||||||||||||||||||||||||||||||||||
name: Do PHP Scoper | ||||||||||||||||||||||||||||||||||||||||||||||
with: | ||||||||||||||||||||||||||||||||||||||||||||||
scoper: true | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
- name: Clean Unwanted files | ||||||||||||||||||||||||||||||||||||||||||||||
run: bash bin/clean.sh | ||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI More steps have been added to the workflow. Here are the specific issues:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,14 +60,25 @@ static function ( string $filePath, string $prefix, string $contents ): string { | |
|
||
// For more information see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#excluded-symbols | ||
'exclude-namespaces' => [ | ||
'/^cli/', | ||
'/^Composer/', | ||
'/^DeepCopy/', | ||
'/^Doctrine/', | ||
'/^Kunoichi/', | ||
'/^PharIo/', | ||
'/^PHP_CodeSniffer/', | ||
'/^PHPCompatibility/', | ||
'/^PHPCSStandards/', | ||
'/^PHPUnit/', | ||
'/^Yoast/', | ||
'/^SebastianBergmann/', | ||
'/^TheSeer/', | ||
'/^WP_/', | ||
'/^Composer/', | ||
'/^cli/' | ||
], | ||
Comment on lines
52
to
69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The |
||
'exclude-classes' => [ | ||
'/^WP_/', | ||
'/^Composer/' | ||
'/^Composer/', | ||
'/^PHPUnit/', | ||
], | ||
Comment on lines
70
to
74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The |
||
'exclude-functions' => [ | ||
// 'mb_str_split', | ||
Comment on lines
52
to
76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The new hunk updates the excluded namespaces, classes, and functions in the PHP-Scoper configuration file. It appears that the changes are intended to exclude additional namespaces, classes, and functions from being scoped. Without the complete context, it's difficult to determine if there are any issues with this change. |
||
|
@@ -80,7 +91,7 @@ static function ( string $filePath, string $prefix, string $contents ): string { | |
// | ||
// For more information see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#exposed-symbols | ||
'expose-global-constants' => true, | ||
'expose-global-classes' => true, | ||
'expose-global-classes' => false, | ||
'expose-global-functions' => false, | ||
'expose-namespaces' => [ | ||
], | ||
Comment on lines
83
to
89
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The new hunk modifies the values of 'expose-global-classes' and 'expose-global-functions' in the PHP-Scoper configuration file. The value of 'expose-global-classes' has been changed to false, and 'expose-global-functions' remains false. Without the complete context, it's difficult to determine if there are any issues with this change. |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,13 @@ | |
// Give access to tests_add_filter() function. | ||
require_once $_tests_dir . '/includes/functions.php'; | ||
|
||
Comment on lines
19
to
21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The comment on line 19 is unnecessary and can be removed. |
||
require_once dirname( __DIR__ ) . '/vendor/autoload.php'; | ||
/** | ||
* Manually load the plugin being tested. | ||
*/ | ||
function _manually_load_plugin() { | ||
require dirname( dirname( __FILE__ ) ) . '/ga-communicator.php'; | ||
} | ||
Comment on lines
+25
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 OpenAI The function /**
* Manually load the plugin being tested.
*/
function _manually_load_plugin() {
require dirname(dirname(__FILE__)) . '/ga-communicator.php';
} 28: // Load the plugin before running the tests.
tests_add_filter('muplugins_loaded', '_manually_load_plugin'); Please ensure that the code snippets provided above are placed in the correct location within the file. |
||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); | ||
|
||
// Start up the WP testing environment. | ||
require $_tests_dir . '/includes/bootstrap.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 OpenAI
The
name
anddescription
fields in the GitHub Actions workflow file should be more descriptive. Consider updating them to provide clearer information about the purpose of the workflow.