Skip to content

Commit 28605ed

Browse files
committed
Show a warning annotation when "master" branch usage is detected
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.
1 parent 8124fe7 commit 28605ed

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

docs/CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
99
The format of this change log follows the advice given at [Keep a CHANGELOG](http://keepachangelog.com).
1010

1111
## [Unreleased]
12-
1312
### Changed
1413
- Updated all uses of `actions/checkout` from `v3` (using node 16) to `v4` (using node 20), because [actions using node 16 are deprecated](https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/) and will stop working in the future.
15-
* ACTION SUGGESTED: In order to avoid the node 16 deprecation warnings, update your workflows to use `actions/checkout@v4`.
14+
- ACTION SUGGESTED: In order to avoid the node 16 deprecation warnings, update your workflows to use `actions/checkout@v4`.
1615

1716
### Deprecated
1817
- The `phpcpd` command (that uses the [PHP Copy/Paste Detector](https://github.com/sebastianbergmann/phpcpd), now abandoned) has been deprecated in this `moodle-plugin-ci` release (4.4.0) and will be removed in 5.0.0. No replacement is planned.
1918
- ACTION SUGGESTED: In order to avoid deprecation warnings or annotations, proceed to remove this command from your workflows. Note that any use will throw an error in the next major release (5.0.0).
19+
- The `master` branch of Moodle upstream repositories has been moved to `main` and will stop working soon (see [MDLSITE-7418](https://tracker.moodle.org/browse/MDLSITE-7418) for details). GitHub workflows will start emitting warnings/annotations when uses of the `master` branch are detected.
20+
- ACTION SUGGESTED: In order to avoid deprecation warnings or annotations, proceed to replace `master` by `main` in your workflows. Note that any use of the former (to be removed) will throw an error in the future.
2021

2122
## [4.3.2] - 2024-01-26
2223
### Changed

src/Command/CopyPasteDetectorCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ protected function configure(): void
3838

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

5557
$timer = new Timer();
5658
$timer->start();

src/Command/InstallCommand.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,17 @@ protected function configure(): void
6262
$extra = getenv('EXTRA_PLUGINS_DIR') !== false ? getenv('EXTRA_PLUGINS_DIR') : null;
6363
$node = getenv('NODE_VERSION') !== false ? getenv('NODE_VERSION') : null;
6464

65+
// Emit a warning/annotation under GHA if the branch is master (recommending to move to main).
66+
// @codeCoverageIgnoreStart
67+
if (getenv('GITHUB_ACTIONS')) { // Only show annotations in GitHub Actions.
68+
if ($branch === 'master') { // And only if the branch being used is master.
69+
echo '::warning title=`master` branch use detected::The `master` branch of Moodle has been ' .
70+
'moved to `main` and will stop working soon. Please consider moving to `main` in your ' .
71+
'workflows. Ref.: MDLSITE-7418' . PHP_EOL;
72+
}
73+
}
74+
// @codeCoverageIgnoreEnd
75+
6576
// As there is not only Travis CI, it can also be passed a generic environment variable.
6677
if (null === $plugin) {
6778
$plugin = getenv('CI_BUILD_DIR') !== false ? getenv('CI_BUILD_DIR') : null;

0 commit comments

Comments
 (0)