From 5caba2039e1f38e82ba4ea00a2705c5ce693b0df Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 21 May 2025 15:47:12 -0700 Subject: [PATCH 01/10] Rename old GH action deprecated --- config/skeletons.yml | 4 ++-- language/en/common.php | 6 +++--- skeleton/.github/workflows/tests.yml.twig | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/skeletons.yml b/config/skeletons.yml index 50ae61e..70bab04 100644 --- a/config/skeletons.yml +++ b/config/skeletons.yml @@ -171,10 +171,10 @@ services: tags: - { name: phpbb.skeleton.ext.skeleton } - phpbb.skeleton.ext.skeleton.githubactions_custom: + phpbb.skeleton.ext.skeleton.githubactions_deprecated: class: phpbb\skeleton\skeleton arguments: - - 'githubactions_custom' + - 'githubactions_deprecated' - false - [] - ['.github/workflows/tests.yml'] diff --git a/language/en/common.php b/language/en/common.php index e38a03c..a9096c3 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -123,10 +123,10 @@ 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 'Create a GitHub Actions workflow to run tests in your repository?', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_UI' => 'GitHub Actions Workflow (Reusable – Recommended)', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_EXPLAIN' => 'Creates a GitHub Actions workflow that uses a reusable, phpBB-maintained framework to run PHPUnit tests on your repository. The workflow file is saved in .github/workflows and runs automatically on each commit and pull request.', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM' => 'Create a fully customisable GitHub Actions workflow? (Select this if you plan to modify jobs or steps.)', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM_UI' => 'GitHub Actions Workflow (Standalone – Deprecated)', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM_EXPLAIN' => 'Deprecated: Creates a fully standalone workflow to run PHPUnit tests without using the shared phpBB framework. This overrides the reusable workflow and is no longer recommended. The file is saved in .github/workflows and runs on each commit and pull request.', 'SKELETON_QUESTION_COMPONENT_BUILD' => 'Create a sample build script for phing?', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED' => 'Create a standalone GitHub Actions workflow [Deprecated: not recommended unless you plan to modify jobs or steps]', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED_UI' => 'GitHub Actions Workflow (Standalone – Deprecated)', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED_EXPLAIN' => 'Deprecated: Creates a fully standalone workflow to run PHPUnit tests without using the shared phpBB framework. This overrides the reusable workflow and is no longer recommended. The file is saved in .github/workflows and runs on each commit and pull request.', 'SKELETON_QUESTION_COMPONENT_BUILD_UI' => 'Build script (phing)', 'SKELETON_QUESTION_COMPONENT_BUILD_EXPLAIN' => 'A phing build script is generated for your extension which can be used to generate build packages to help simplify the release or deployment processes.', diff --git a/skeleton/.github/workflows/tests.yml.twig b/skeleton/.github/workflows/tests.yml.twig index e984322..2ff5433 100644 --- a/skeleton/.github/workflows/tests.yml.twig +++ b/skeleton/.github/workflows/tests.yml.twig @@ -1,6 +1,6 @@ name: Tests -{% if COMPONENT.githubactions_custom %} +{% if COMPONENT.githubactions_deprecated %} env: EXTNAME: {{ EXTENSION.vendor_name }}/{{ EXTENSION.extension_name }} # Your extension vendor/package name SNIFF: 1 # Run code sniffer on your code? 1 or 0 From 9c172543d8ab6db47eb33133732993abb9ef27eb Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 21 May 2025 15:47:56 -0700 Subject: [PATCH 02/10] Clean up lang file --- language/en/common.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/language/en/common.php b/language/en/common.php index a9096c3..6073f82 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -78,55 +78,55 @@ 'SKELETON_QUESTION_PHPBB_VERSION_MAX_UI' => 'Maximum phpBB requirement of the extension', 'SKELETON_QUESTION_PHPBB_VERSION_MAX_EXPLAIN' => 'default: <' . \phpbb\skeleton\ext::DEFAULT_PHPBB_MAX, - 'SKELETON_QUESTION_COMPONENT_PHPLISTENER' => 'Create sample PHP event listeners?', + 'SKELETON_QUESTION_COMPONENT_PHPLISTENER' => 'Create sample PHP event listeners', 'SKELETON_QUESTION_COMPONENT_PHPLISTENER_UI' => 'PHP event listeners', 'SKELETON_QUESTION_COMPONENT_PHPLISTENER_EXPLAIN' => 'PHP event listeners work with core events to inject code into phpBB.', - 'SKELETON_QUESTION_COMPONENT_HTMLLISTENER' => 'Create sample styles listeners?', + 'SKELETON_QUESTION_COMPONENT_HTMLLISTENER' => 'Create sample styles listeners', 'SKELETON_QUESTION_COMPONENT_HTMLLISTENER_UI' => 'Style listeners', 'SKELETON_QUESTION_COMPONENT_HTMLLISTENER_EXPLAIN' => 'Style listeners use template events to inject HTML, JS and CSS into phpBB’s style files.', - 'SKELETON_QUESTION_COMPONENT_ACP' => 'Create a sample ACP administration module?', + 'SKELETON_QUESTION_COMPONENT_ACP' => 'Create a sample ACP administration module', 'SKELETON_QUESTION_COMPONENT_ACP_UI' => 'Administration control panel (ACP)', 'SKELETON_QUESTION_COMPONENT_ACP_EXPLAIN' => 'Add a functional ACP module for an extension to the ACP’s Extensions tab.', - 'SKELETON_QUESTION_COMPONENT_MCP' => 'Create a sample MCP moderation module?', + 'SKELETON_QUESTION_COMPONENT_MCP' => 'Create a sample MCP moderation module', 'SKELETON_QUESTION_COMPONENT_MCP_UI' => 'Moderator control panel (MCP)', 'SKELETON_QUESTION_COMPONENT_MCP_EXPLAIN' => 'Add a functional MCP module tab for an extension to the MCP.', - 'SKELETON_QUESTION_COMPONENT_UCP' => 'Create a sample UCP user module?', + 'SKELETON_QUESTION_COMPONENT_UCP' => 'Create a sample UCP user module', 'SKELETON_QUESTION_COMPONENT_UCP_UI' => 'User control panel (UCP)', 'SKELETON_QUESTION_COMPONENT_UCP_EXPLAIN' => 'Add a functional UCP module tab for an extension to the UCP.', - 'SKELETON_QUESTION_COMPONENT_MIGRATION' => 'Create sample database migrations?', + 'SKELETON_QUESTION_COMPONENT_MIGRATION' => 'Create sample database migrations', 'SKELETON_QUESTION_COMPONENT_MIGRATION_UI' => 'Database migration', 'SKELETON_QUESTION_COMPONENT_MIGRATION_EXPLAIN' => 'Migration files are used to make database changes.', - 'SKELETON_QUESTION_COMPONENT_SERVICE' => 'Create a sample service?', + 'SKELETON_QUESTION_COMPONENT_SERVICE' => 'Create a sample service', 'SKELETON_QUESTION_COMPONENT_SERVICE_UI' => 'Service', 'SKELETON_QUESTION_COMPONENT_SERVICE_EXPLAIN' => 'This is a PHP class that does something behind the scenes. It is a class that can be accessed by controllers, event listeners, or control panel modules.', - 'SKELETON_QUESTION_COMPONENT_CONTROLLER' => 'Create a sample controller?', + 'SKELETON_QUESTION_COMPONENT_CONTROLLER' => 'Create a sample controller', 'SKELETON_QUESTION_COMPONENT_CONTROLLER_UI' => 'Controller (front page)', 'SKELETON_QUESTION_COMPONENT_CONTROLLER_EXPLAIN'=> 'Controllers are typically used for the front-facing files/classes. They run the code that produces the page the user views.', - 'SKELETON_QUESTION_COMPONENT_EXT' => 'Create a sample ext.php?', + 'SKELETON_QUESTION_COMPONENT_EXT' => 'Create a sample ext.php', 'SKELETON_QUESTION_COMPONENT_EXT_UI' => 'Extension base (ext.php)', 'SKELETON_QUESTION_COMPONENT_EXT_EXPLAIN' => 'Create the optional ext.php file which can be used to run code before or during extension installation and removal.', - 'SKELETON_QUESTION_COMPONENT_CONSOLE' => 'Create a sample console command?', + 'SKELETON_QUESTION_COMPONENT_CONSOLE' => 'Create a sample console command', 'SKELETON_QUESTION_COMPONENT_CONSOLE_UI' => 'Console command', 'SKELETON_QUESTION_COMPONENT_CONSOLE_EXPLAIN' => 'A functional CLI interface to perform console/terminal commands.', - 'SKELETON_QUESTION_COMPONENT_CRON' => 'Create a sample cron task?', + 'SKELETON_QUESTION_COMPONENT_CRON' => 'Create a sample cron task', 'SKELETON_QUESTION_COMPONENT_CRON_UI' => 'Cron task', 'SKELETON_QUESTION_COMPONENT_CRON_EXPLAIN' => 'Add a cron task to be able to schedule and run cron-based actions from an extension.', - 'SKELETON_QUESTION_COMPONENT_NOTIFICATION' => 'Create a sample notification?', + 'SKELETON_QUESTION_COMPONENT_NOTIFICATION' => 'Create a sample notification', 'SKELETON_QUESTION_COMPONENT_NOTIFICATION_UI' => 'Notifications', 'SKELETON_QUESTION_COMPONENT_NOTIFICATION_EXPLAIN' => 'Notifications allow an extension to notify users of specific activities. When choosing notifications, do not use phpBB 3.1 as the minimum requirement. Notifications changed in phpBB 3.2.0 and are not backwards compatible with 3.1.x.', - 'SKELETON_QUESTION_COMPONENT_PERMISSIONS' => 'Create sample permissions?', + 'SKELETON_QUESTION_COMPONENT_PERMISSIONS' => 'Create sample permissions', 'SKELETON_QUESTION_COMPONENT_PERMISSIONS_UI' => 'Permissions', 'SKELETON_QUESTION_COMPONENT_PERMISSIONS_EXPLAIN' => 'Permissions can be used to grant users, groups and roles access to specific extension features.', - 'SKELETON_QUESTION_COMPONENT_TESTS' => 'Create sample PHPUnit tests?', + 'SKELETON_QUESTION_COMPONENT_TESTS' => 'Create sample PHPUnit tests', 'SKELETON_QUESTION_COMPONENT_TESTS_UI' => 'Tests (PHPUnit)', 'SKELETON_QUESTION_COMPONENT_TESTS_EXPLAIN' => 'Unit tests can test an extension to verify that specific portions of its source code work properly. This helps ensure basic code integrity and prevents regressions as an extension is being developed and debugged.', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 'Create a GitHub Actions workflow to run tests in your repository?', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 'Create a GitHub Actions workflow to run tests in your repository', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_UI' => 'GitHub Actions Workflow (Reusable – Recommended)', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_EXPLAIN' => 'Creates a GitHub Actions workflow that uses a reusable, phpBB-maintained framework to run PHPUnit tests on your repository. The workflow file is saved in .github/workflows and runs automatically on each commit and pull request.', - 'SKELETON_QUESTION_COMPONENT_BUILD' => 'Create a sample build script for phing?', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED' => 'Create a standalone GitHub Actions workflow [Deprecated: not recommended unless you plan to modify jobs or steps]', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED_UI' => 'GitHub Actions Workflow (Standalone – Deprecated)', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED_EXPLAIN' => 'Deprecated: Creates a fully standalone workflow to run PHPUnit tests without using the shared phpBB framework. This overrides the reusable workflow and is no longer recommended. The file is saved in .github/workflows and runs on each commit and pull request.', + 'SKELETON_QUESTION_COMPONENT_BUILD' => 'Create a sample build script for phing', 'SKELETON_QUESTION_COMPONENT_BUILD_UI' => 'Build script (phing)', 'SKELETON_QUESTION_COMPONENT_BUILD_EXPLAIN' => 'A phing build script is generated for your extension which can be used to generate build packages to help simplify the release or deployment processes.', From 921c68cebd3cd8ca1dfd5dfbbb9e574840eb7f3d Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 21 May 2025 15:48:25 -0700 Subject: [PATCH 03/10] Re-do CLI logic for github actions as multiple choices --- console/create.php | 38 ++++++++++++++++++++++++++++++++++++++ language/en/common.php | 3 +++ 2 files changed, 41 insertions(+) diff --git a/console/create.php b/console/create.php index 2e89568..48191bc 100644 --- a/console/create.php +++ b/console/create.php @@ -22,6 +22,7 @@ use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\ChoiceQuestion; use Symfony\Component\Console\Question\ConfirmationQuestion; use Symfony\Component\Console\Question\Question; @@ -167,6 +168,43 @@ protected function get_component_data() } } + // Special logic for GitHub Actions options + if ($component === 'githubactions') + { + $question = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON'); + $choices = [ + $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_0'), + $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_1'), + $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_2'), + ]; + + $question = new ChoiceQuestion($question, $choices, 0); + + $choice = $this->helper->ask($this->input, $this->output, $question); + $index = array_search($choice, $choices, true); + + $this->data['components']['githubactions'] = false; + $this->data['components']['githubactions_deprecated'] = false; + + if ($index === 1) + { + $this->data['components']['githubactions'] = true; + } + else if ($index === 2) + { + $this->data['components']['githubactions_deprecated'] = true; + } + + continue; + } + + if ($component === 'githubactions_deprecated') + { + // Already handled via githubactions logic + continue; + } + + // Default logic for all other components $this->data['components'][$component] = $this->get_user_input('component_' . $component, $details['default']); } } diff --git a/language/en/common.php b/language/en/common.php index 6073f82..a443e01 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -121,6 +121,9 @@ 'SKELETON_QUESTION_COMPONENT_TESTS_UI' => 'Tests (PHPUnit)', 'SKELETON_QUESTION_COMPONENT_TESTS_EXPLAIN' => 'Unit tests can test an extension to verify that specific portions of its source code work properly. This helps ensure basic code integrity and prevents regressions as an extension is being developed and debugged.', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 'Create a GitHub Actions workflow to run tests in your repository', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_0' => 'No (Default)', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_1' => 'Reusable (Recommended – uses phpBB’s maintained workflow)', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_2' => 'Standalone (Deprecated – overrides reusable workflow)', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_UI' => 'GitHub Actions Workflow (Reusable – Recommended)', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_EXPLAIN' => 'Creates a GitHub Actions workflow that uses a reusable, phpBB-maintained framework to run PHPUnit tests on your repository. The workflow file is saved in .github/workflows and runs automatically on each commit and pull request.', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED' => 'Create a standalone GitHub Actions workflow [Deprecated: not recommended unless you plan to modify jobs or steps]', From 7c49815871c682871d97a4cd05825fc73ab7c363 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 21 May 2025 16:03:43 -0700 Subject: [PATCH 04/10] Refactor handling of github actions in CLI --- console/create.php | 105 ++++++++++++++++++++++------------ language/en/common.php | 10 ++-- tests/console/create_test.php | 2 +- 3 files changed, 77 insertions(+), 40 deletions(-) diff --git a/console/create.php b/console/create.php index 48191bc..56c51ef 100644 --- a/console/create.php +++ b/console/create.php @@ -159,53 +159,31 @@ protected function get_component_data() $components = $this->packager->get_component_dialog_values(); foreach ($components as $component => $details) { - foreach ($details['dependencies'] as $depends) + // Skip early as it's handled elsewhere + if ($component === 'githubactions_deprecated') { - if (empty($this->data['components'][$depends])) - { - $this->data['components'][$component] = false; - continue 2; - } + continue; } - // Special logic for GitHub Actions options - if ($component === 'githubactions') + // Check dependencies + if (!$this->check_dependencies($details['dependencies'])) { - $question = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON'); - $choices = [ - $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_0'), - $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_1'), - $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_2'), - ]; - - $question = new ChoiceQuestion($question, $choices, 0); - - $choice = $this->helper->ask($this->input, $this->output, $question); - $index = array_search($choice, $choices, true); - - $this->data['components']['githubactions'] = false; - $this->data['components']['githubactions_deprecated'] = false; - - if ($index === 1) - { - $this->data['components']['githubactions'] = true; - } - else if ($index === 2) - { - $this->data['components']['githubactions_deprecated'] = true; - } - + $this->data['components'][$component] = false; continue; } - if ($component === 'githubactions_deprecated') + // Handle GitHub Actions + if ($component === 'githubactions') { - // Already handled via githubactions logic + $this->handle_github_actions(); continue; } // Default logic for all other components - $this->data['components'][$component] = $this->get_user_input('component_' . $component, $details['default']); + $this->data['components'][$component] = $this->get_user_input( + 'component_' . $component, + $details['default'] + ); } } @@ -239,4 +217,61 @@ protected function get_user_input($value, $default) return $return_value; } + + /** + * Check if all dependencies are satisfied + * + * @param array $dependencies List of dependencies to check + * @return bool + */ + private function check_dependencies(array $dependencies): bool + { + foreach ($dependencies as $depends) + { + if (empty($this->data['components'][$depends])) + { + return false; + } + } + return true; + } + + /** + * Handle GitHub Actions specific logic + */ + private function handle_github_actions(): void + { + $question = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON'); + $choices = [ + $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', 0), + $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', 1), + $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', 2), + ]; + + $question = new ChoiceQuestion($question, $choices, 0); + + $choice = $this->helper->ask($this->input, $this->output, $question); + $index = array_search($choice, $choices, true); + + $this->data['components']['githubactions'] = false; + $this->data['components']['githubactions_deprecated'] = false; + + // Initialize both flags to false + $this->data['components'] = array_merge( + $this->data['components'], + [ + 'githubactions' => false, + 'githubactions_deprecated' => false + ] + ); + + if ($index === 1) + { + $this->data['components']['githubactions'] = true; + } + else if ($index === 2) + { + $this->data['components']['githubactions_deprecated'] = true; + } + } } diff --git a/language/en/common.php b/language/en/common.php index a443e01..8536193 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -120,10 +120,12 @@ 'SKELETON_QUESTION_COMPONENT_TESTS' => 'Create sample PHPUnit tests', 'SKELETON_QUESTION_COMPONENT_TESTS_UI' => 'Tests (PHPUnit)', 'SKELETON_QUESTION_COMPONENT_TESTS_EXPLAIN' => 'Unit tests can test an extension to verify that specific portions of its source code work properly. This helps ensure basic code integrity and prevents regressions as an extension is being developed and debugged.', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 'Create a GitHub Actions workflow to run tests in your repository', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_0' => 'No (Default)', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_1' => 'Reusable (Recommended – uses phpBB’s maintained workflow)', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_2' => 'Standalone (Deprecated – overrides reusable workflow)', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 'Create a GitHub Actions workflow', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI' => [ + 0 => 'No (Default)', + 1 => 'Reusable (Recommended – uses phpBB’s maintained workflow)', + 2 => 'Standalone (Deprecated - customise and maintain your own workflow)', + ], 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_UI' => 'GitHub Actions Workflow (Reusable – Recommended)', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_EXPLAIN' => 'Creates a GitHub Actions workflow that uses a reusable, phpBB-maintained framework to run PHPUnit tests on your repository. The workflow file is saved in .github/workflows and runs automatically on each commit and pull request.', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED' => 'Create a standalone GitHub Actions workflow [Deprecated: not recommended unless you plan to modify jobs or steps]', diff --git a/tests/console/create_test.php b/tests/console/create_test.php index 637fd50..807ee15 100644 --- a/tests/console/create_test.php +++ b/tests/console/create_test.php @@ -184,7 +184,7 @@ public function get_questions() // 'SKELETON_QUESTION_COMPONENT_NOTIFICATION' => 'y', // 'SKELETON_QUESTION_COMPONENT_PERMISSIONS' => 'y', 'SKELETON_QUESTION_COMPONENT_TESTS' => 'y', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 'y', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 2, // 'SKELETON_QUESTION_COMPONENT_BUILD' => 'y', ]; } From 39360f925d5d3502337d18d5ffb0c49df3bc3da4 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 21 May 2025 16:31:34 -0700 Subject: [PATCH 05/10] Revert naming to old ga as deprecated --- config/skeletons.yml | 4 ++-- console/create.php | 8 ++++---- language/en/common.php | 6 +++--- skeleton/.github/workflows/tests.yml.twig | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config/skeletons.yml b/config/skeletons.yml index 70bab04..50ae61e 100644 --- a/config/skeletons.yml +++ b/config/skeletons.yml @@ -171,10 +171,10 @@ services: tags: - { name: phpbb.skeleton.ext.skeleton } - phpbb.skeleton.ext.skeleton.githubactions_deprecated: + phpbb.skeleton.ext.skeleton.githubactions_custom: class: phpbb\skeleton\skeleton arguments: - - 'githubactions_deprecated' + - 'githubactions_custom' - false - [] - ['.github/workflows/tests.yml'] diff --git a/console/create.php b/console/create.php index 56c51ef..d3b2b8a 100644 --- a/console/create.php +++ b/console/create.php @@ -160,7 +160,7 @@ protected function get_component_data() foreach ($components as $component => $details) { // Skip early as it's handled elsewhere - if ($component === 'githubactions_deprecated') + if ($component === 'githubactions_custom') { continue; } @@ -254,14 +254,14 @@ private function handle_github_actions(): void $index = array_search($choice, $choices, true); $this->data['components']['githubactions'] = false; - $this->data['components']['githubactions_deprecated'] = false; + $this->data['components']['githubactions_custom'] = false; // Initialize both flags to false $this->data['components'] = array_merge( $this->data['components'], [ 'githubactions' => false, - 'githubactions_deprecated' => false + 'githubactions_custom' => false ] ); @@ -271,7 +271,7 @@ private function handle_github_actions(): void } else if ($index === 2) { - $this->data['components']['githubactions_deprecated'] = true; + $this->data['components']['githubactions_custom'] = true; } } } diff --git a/language/en/common.php b/language/en/common.php index 8536193..ac3e2c4 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -128,9 +128,9 @@ ], 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_UI' => 'GitHub Actions Workflow (Reusable – Recommended)', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_EXPLAIN' => 'Creates a GitHub Actions workflow that uses a reusable, phpBB-maintained framework to run PHPUnit tests on your repository. The workflow file is saved in .github/workflows and runs automatically on each commit and pull request.', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED' => 'Create a standalone GitHub Actions workflow [Deprecated: not recommended unless you plan to modify jobs or steps]', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED_UI' => 'GitHub Actions Workflow (Standalone – Deprecated)', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_DEPRECATED_EXPLAIN' => 'Deprecated: Creates a fully standalone workflow to run PHPUnit tests without using the shared phpBB framework. This overrides the reusable workflow and is no longer recommended. The file is saved in .github/workflows and runs on each commit and pull request.', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM' => 'Create a standalone GitHub Actions workflow [Deprecated: not recommended unless you plan to modify jobs or steps]', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM_UI' => 'GitHub Actions Workflow (Standalone – Deprecated)', + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM_EXPLAIN' => 'Deprecated: Creates a fully standalone workflow to run PHPUnit tests without using the shared phpBB framework. This overrides the reusable workflow and is no longer recommended. The file is saved in .github/workflows and runs on each commit and pull request.', 'SKELETON_QUESTION_COMPONENT_BUILD' => 'Create a sample build script for phing', 'SKELETON_QUESTION_COMPONENT_BUILD_UI' => 'Build script (phing)', 'SKELETON_QUESTION_COMPONENT_BUILD_EXPLAIN' => 'A phing build script is generated for your extension which can be used to generate build packages to help simplify the release or deployment processes.', diff --git a/skeleton/.github/workflows/tests.yml.twig b/skeleton/.github/workflows/tests.yml.twig index 2ff5433..e984322 100644 --- a/skeleton/.github/workflows/tests.yml.twig +++ b/skeleton/.github/workflows/tests.yml.twig @@ -1,6 +1,6 @@ name: Tests -{% if COMPONENT.githubactions_deprecated %} +{% if COMPONENT.githubactions_custom %} env: EXTNAME: {{ EXTENSION.vendor_name }}/{{ EXTENSION.extension_name }} # Your extension vendor/package name SNIFF: 1 # Run code sniffer on your code? 1 or 0 From ec5a11b9e17b51f18803bfc0720371bd4b14ab0c Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 21 May 2025 16:51:46 -0700 Subject: [PATCH 06/10] Fixes --- console/create.php | 9 --------- tests/console/create_test.php | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/console/create.php b/console/create.php index d3b2b8a..06626f1 100644 --- a/console/create.php +++ b/console/create.php @@ -256,15 +256,6 @@ private function handle_github_actions(): void $this->data['components']['githubactions'] = false; $this->data['components']['githubactions_custom'] = false; - // Initialize both flags to false - $this->data['components'] = array_merge( - $this->data['components'], - [ - 'githubactions' => false, - 'githubactions_custom' => false - ] - ); - if ($index === 1) { $this->data['components']['githubactions'] = true; diff --git a/tests/console/create_test.php b/tests/console/create_test.php index 807ee15..513f068 100644 --- a/tests/console/create_test.php +++ b/tests/console/create_test.php @@ -93,7 +93,7 @@ public function setUp(): void ], 'githubactions' => [ 'default' => false, - 'dependencies' => ['tests'], + 'dependencies' => [], 'files' => ['.github/workflows/tests.yml'], 'group' => 'TEST_DEPLOY', ], @@ -184,7 +184,7 @@ public function get_questions() // 'SKELETON_QUESTION_COMPONENT_NOTIFICATION' => 'y', // 'SKELETON_QUESTION_COMPONENT_PERMISSIONS' => 'y', 'SKELETON_QUESTION_COMPONENT_TESTS' => 'y', - 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 2, + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 0, // 'SKELETON_QUESTION_COMPONENT_BUILD' => 'y', ]; } From 5ffb405487a67f561a930d0fcff3dbfb92287655 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Wed, 21 May 2025 21:33:45 -0700 Subject: [PATCH 07/10] Refactor new function --- console/create.php | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/console/create.php b/console/create.php index 06626f1..e906d80 100644 --- a/console/create.php +++ b/console/create.php @@ -236,33 +236,32 @@ private function check_dependencies(array $dependencies): bool return true; } + private const GITHUB_ACTIONS_TYPES = [ + 0 => ['githubactions' => false, 'githubactions_custom' => false], // No + 1 => ['githubactions' => true, 'githubactions_custom' => false], // Reusable + 2 => ['githubactions' => false, 'githubactions_custom' => true], // Standalone + ]; + /** * Handle GitHub Actions specific logic */ private function handle_github_actions(): void { - $question = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON'); - $choices = [ - $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', 0), - $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', 1), - $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', 2), - ]; - - $question = new ChoiceQuestion($question, $choices, 0); + $questionText = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON'); + $choices = []; + foreach (array_keys(self::GITHUB_ACTIONS_TYPES) as $i) + { + $choices[] = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', $i); + } + $question = new ChoiceQuestion($questionText, $choices, 0); $choice = $this->helper->ask($this->input, $this->output, $question); $index = array_search($choice, $choices, true); - $this->data['components']['githubactions'] = false; - $this->data['components']['githubactions_custom'] = false; - - if ($index === 1) - { - $this->data['components']['githubactions'] = true; - } - else if ($index === 2) - { - $this->data['components']['githubactions_custom'] = true; - } + $componentSettings = self::GITHUB_ACTIONS_TYPES[$index] ?? self::GITHUB_ACTIONS_TYPES[0]; + $this->data['components'] = array_merge( + $this->data['components'] ?? [], + $componentSettings + ); } } From 1c02ca2d27ed4e32186c047f47713d9a8b920e42 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 22 May 2025 06:36:12 -0700 Subject: [PATCH 08/10] A little more refactoring and cleanup --- console/create.php | 23 ++++++++++++----------- tests/console/create_test.php | 7 +++++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/console/create.php b/console/create.php index e906d80..4581951 100644 --- a/console/create.php +++ b/console/create.php @@ -236,32 +236,33 @@ private function check_dependencies(array $dependencies): bool return true; } - private const GITHUB_ACTIONS_TYPES = [ - 0 => ['githubactions' => false, 'githubactions_custom' => false], // No - 1 => ['githubactions' => true, 'githubactions_custom' => false], // Reusable - 2 => ['githubactions' => false, 'githubactions_custom' => true], // Standalone - ]; - /** * Handle GitHub Actions specific logic */ private function handle_github_actions(): void { - $questionText = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON'); + // Lookup table of GitHub Action component settings + $github_actions_types = [ + 0 => ['githubactions' => false, 'githubactions_custom' => false], // No (default) + 1 => ['githubactions' => true, 'githubactions_custom' => false], // Reusable + 2 => ['githubactions' => false, 'githubactions_custom' => true], // Standalone + ]; + + $question_text = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS') . $this->language->lang('COLON'); $choices = []; - foreach (array_keys(self::GITHUB_ACTIONS_TYPES) as $i) + foreach (array_keys($github_actions_types) as $i) { $choices[] = $this->language->lang('SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI', $i); } - $question = new ChoiceQuestion($questionText, $choices, 0); + $question = new ChoiceQuestion($question_text, $choices, 0); $choice = $this->helper->ask($this->input, $this->output, $question); $index = array_search($choice, $choices, true); - $componentSettings = self::GITHUB_ACTIONS_TYPES[$index] ?? self::GITHUB_ACTIONS_TYPES[0]; + $component_settings = $github_actions_types[$index] ?? $github_actions_types[0]; $this->data['components'] = array_merge( $this->data['components'] ?? [], - $componentSettings + $component_settings ); } } diff --git a/tests/console/create_test.php b/tests/console/create_test.php index 513f068..37bed9f 100644 --- a/tests/console/create_test.php +++ b/tests/console/create_test.php @@ -92,6 +92,12 @@ public function setUp(): void 'group' => 'TEST_DEPLOY', ], 'githubactions' => [ + 'default' => false, + 'dependencies' => ['tests'], + 'files' => ['.github/workflows/tests.yml'], + 'group' => 'TEST_DEPLOY', + ], + 'githubactions_custom' => [ 'default' => false, 'dependencies' => [], 'files' => ['.github/workflows/tests.yml'], @@ -185,6 +191,7 @@ public function get_questions() // 'SKELETON_QUESTION_COMPONENT_PERMISSIONS' => 'y', 'SKELETON_QUESTION_COMPONENT_TESTS' => 'y', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 0, + 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM' => null, // 'SKELETON_QUESTION_COMPONENT_BUILD' => 'y', ]; } From 2ad4b07c19c3da0e10232891d11689e54d710c82 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 22 May 2025 07:41:29 -0700 Subject: [PATCH 09/10] Remove UTF8 chars from console --- language/en/common.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/language/en/common.php b/language/en/common.php index ac3e2c4..5d914a3 100644 --- a/language/en/common.php +++ b/language/en/common.php @@ -123,7 +123,7 @@ 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS' => 'Create a GitHub Actions workflow', 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CLI' => [ 0 => 'No (Default)', - 1 => 'Reusable (Recommended – uses phpBB’s maintained workflow)', + 1 => 'Reusable (Recommended - uses phpBB\'s maintained workflow)', 2 => 'Standalone (Deprecated - customise and maintain your own workflow)', ], 'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_UI' => 'GitHub Actions Workflow (Reusable – Recommended)', From 3024ae05a52e90aed93a11603bf9c2c89be925e7 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Thu, 22 May 2025 09:21:12 -0700 Subject: [PATCH 10/10] Fix ignoring nested github folder --- .gitattributes | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitattributes b/.gitattributes index 5392ca4..d3365db 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,7 @@ -/tests/ export-ignore -.github/ export-ignore -.gitignore export-ignore -.gitattributes export-ignore -phpunit.xml.dist export-ignore -composer.lock export-ignore -build.xml export-ignore +/tests export-ignore +/.github export-ignore +.gitignore export-ignore +.gitattributes export-ignore +phpunit.xml.dist export-ignore +composer.lock export-ignore +build.xml export-ignore