Skip to content

Commit

Permalink
Show a warning annotation when "master" branch usage is detected
Browse files Browse the repository at this point in the history
That way, both the web UI and the email from GitHub will show
the recommendation about to move to the new "main" branch.

Also, unrelated, exclude some unreachable code from code coverage
analysis.
  • Loading branch information
stronk7 committed Feb 7, 2024
1 parent 8124fe7 commit 1a23fb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Command/CopyPasteDetectorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
// @codeCoverageIgnoreStart
if (!defined('PHPUNIT_TEST')) { // Only show deprecation warnings in non-test environments.
trigger_deprecation(
'moodle-plugin-ci',
Expand All @@ -51,6 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'is deprecated and will be removed in 5.0.0. No replacement is planned.' . PHP_EOL;
}
}
// @codeCoverageIgnoreEnd

$timer = new Timer();
$timer->start();
Expand Down
7 changes: 7 additions & 0 deletions src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ protected function configure(): void
$extra = getenv('EXTRA_PLUGINS_DIR') !== false ? getenv('EXTRA_PLUGINS_DIR') : null;
$node = getenv('NODE_VERSION') !== false ? getenv('NODE_VERSION') : null;

// Emit a warning/annotation under GHA if the branch is master (recommending to move to main).
if (getenv('GITHUB_ACTIONS') && $branch === 'master') {
echo '::warning title=`master` branch use detected::The `master` branch of Moodle has been ' .
'moved to `main` and will stop working soon. Please consider moving to `main` in your ' .
'workflows. Ref.: MDLSITE-7418' . PHP_EOL;
}

// As there is not only Travis CI, it can also be passed a generic environment variable.
if (null === $plugin) {
$plugin = getenv('CI_BUILD_DIR') !== false ? getenv('CI_BUILD_DIR') : null;
Expand Down

0 comments on commit 1a23fb1

Please sign in to comment.