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 25276e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
The format of this change log follows the advice given at [Keep a CHANGELOG](http://keepachangelog.com).

## [Unreleased]

### Changed
- 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.
* ACTION SUGGESTED: In order to avoid the node 16 deprecation warnings, update your workflows to use `actions/checkout@v4`.
- ACTION SUGGESTED: In order to avoid the node 16 deprecation warnings, update your workflows to use `actions/checkout@v4`.

### Deprecated
- 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.
- 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).
- 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.
- 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.

## [4.3.2] - 2024-01-26
### Changed
Expand Down
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
11 changes: 11 additions & 0 deletions src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ 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).
// @codeCoverageIgnoreStart
if (getenv('GITHUB_ACTIONS')) { // Only show annotations in GitHub Actions.
if ($branch === 'master') { // And only if the branch being used is 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;
}
}
// @codeCoverageIgnoreEnd

// 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 25276e2

Please sign in to comment.