-
Notifications
You must be signed in to change notification settings - Fork 2k
refactor: implement development versions for CodeIgniter::CI_VERSION
#9951
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
Merged
paulbalandan
merged 5 commits into
codeigniter4:develop
from
paulbalandan:dev-ci-version
Feb 17, 2026
+199
−42
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ab6469e
Refactor for better variable names
paulbalandan 0cccba0
Replace `CodeIgniter::CI_VERSION` with dev version
paulbalandan e8c31c9
Add auto review test
paulbalandan d572b96
Change CI_VERSION
paulbalandan 1b6ca6d
Fetch tags manually
paulbalandan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * This file is part of CodeIgniter 4 framework. | ||
| * | ||
| * (c) CodeIgniter Foundation <admin@codeigniter.com> | ||
| * | ||
| * For the full copyright and license information, please view | ||
| * the LICENSE file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace CodeIgniter\AutoReview; | ||
|
|
||
| use PHPUnit\Framework\Attributes\CoversNothing; | ||
| use PHPUnit\Framework\Attributes\DataProvider; | ||
| use PHPUnit\Framework\Attributes\Group; | ||
| use PHPUnit\Framework\TestCase; | ||
|
|
||
| /** | ||
| * @internal | ||
| */ | ||
| #[CoversNothing] | ||
| #[Group('AutoReview')] | ||
| final class CreateNewChangelogTest extends TestCase | ||
| { | ||
| private string $currentVersion; | ||
|
|
||
| public static function setUpBeforeClass(): void | ||
| { | ||
| parent::setUpBeforeClass(); | ||
|
|
||
| if (getenv('GITHUB_ACTIONS') !== false) { | ||
| exec('git fetch --unshallow 2>&1', $output, $exitCode); | ||
| exec('git fetch --tags 2>&1', $output, $exitCode); | ||
|
|
||
| if ($exitCode !== 0) { | ||
| self::fail(sprintf( | ||
| "Failed to fetch git history and tags.\nOutput: %s", | ||
| implode("\n", $output), | ||
| )); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| protected function setUp(): void | ||
| { | ||
| parent::setUp(); | ||
|
|
||
| exec('git describe --tags --abbrev=0 2>&1', $output, $exitCode); | ||
|
|
||
| if ($exitCode !== 0) { | ||
| $this->markTestSkipped(sprintf( | ||
| "Unable to get the latest git tag.\nOutput: %s", | ||
| implode("\n", $output), | ||
| )); | ||
| } | ||
|
|
||
| // Current tag should already have the next patch docs done, so for testing purposes, | ||
| // we will treat the next patch version as the current version. | ||
| $this->currentVersion = $this->incrementVersion(trim($output[0], 'v')); | ||
| } | ||
|
|
||
| #[DataProvider('provideCreateNewChangelog')] | ||
| public function testCreateNewChangelog(string $mode): void | ||
| { | ||
| $currentVersion = $this->currentVersion; | ||
| $newVersion = $this->incrementVersion($currentVersion, $mode); | ||
|
|
||
| exec( | ||
| sprintf('php ./admin/create-new-changelog.php %s %s --dry-run', $currentVersion, $newVersion), | ||
| $output, | ||
| $exitCode, | ||
| ); | ||
|
|
||
| $this->assertSame(0, $exitCode, "Script exited with code {$exitCode}. Output: " . implode("\n", $output)); | ||
|
|
||
| $this->assertStringContainsString( | ||
| "public const CI_VERSION = '{$newVersion}-dev';", | ||
| $this->getContents('./system/CodeIgniter.php'), | ||
| ); | ||
|
|
||
| $this->assertFileExists("./user_guide_src/source/changelogs/v{$newVersion}.rst"); | ||
| $this->assertStringContainsString( | ||
| "Version {$newVersion}", | ||
| $this->getContents("./user_guide_src/source/changelogs/v{$newVersion}.rst"), | ||
| ); | ||
| $this->assertStringContainsString( | ||
| "**{$newVersion} release of CodeIgniter4**", | ||
| $this->getContents("./user_guide_src/source/changelogs/v{$newVersion}.rst"), | ||
| ); | ||
| $this->assertStringContainsString( | ||
| $newVersion, | ||
| $this->getContents('./user_guide_src/source/changelogs/index.rst'), | ||
| ); | ||
|
|
||
| $versionWithoutDots = str_replace('.', '', $newVersion); | ||
| $this->assertFileExists("./user_guide_src/source/installation/upgrade_{$versionWithoutDots}.rst"); | ||
| $this->assertStringContainsString( | ||
| "Upgrading from {$currentVersion} to {$newVersion}", | ||
| $this->getContents("./user_guide_src/source/installation/upgrade_{$versionWithoutDots}.rst"), | ||
| ); | ||
| $this->assertStringContainsString( | ||
| "upgrade_{$versionWithoutDots}", | ||
| $this->getContents('./user_guide_src/source/installation/upgrading.rst'), | ||
| ); | ||
|
|
||
| // cleanup added and modified files | ||
| exec('git restore .'); | ||
| exec('git clean -fd'); | ||
| } | ||
|
|
||
| /** | ||
| * @return iterable<string, array{0: string}> | ||
| */ | ||
| public static function provideCreateNewChangelog(): iterable | ||
| { | ||
| yield 'patch update' => ['patch']; | ||
|
|
||
| yield 'minor update' => ['minor']; | ||
|
|
||
| yield 'major update' => ['major']; | ||
| } | ||
|
|
||
| private function incrementVersion(string $version, string $mode = 'patch'): string | ||
| { | ||
| $parts = explode('.', $version); | ||
|
|
||
| return match ($mode) { | ||
| 'major' => sprintf('%d.0.0', ++$parts[0]), | ||
| 'minor' => sprintf('%d.%d.0', $parts[0], ++$parts[1]), | ||
| 'patch' => sprintf('%d.%d.%d', $parts[0], $parts[1], ++$parts[2]), | ||
| default => $this->fail('Invalid version increment mode. Use "major", "minor", or "patch".'), | ||
| }; | ||
| } | ||
|
|
||
| private function getContents(string $path): string | ||
| { | ||
| $contents = @file_get_contents($path); | ||
|
|
||
| if ($contents === false) { | ||
| $this->fail("Failed to read file contents from {$path}."); | ||
| } | ||
|
|
||
| return $contents; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
@paulbalandan You forgot about the developers.
The command deletes uncommited changes in the local environment. I cleared 10 files after the test 😢
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.
Sorry about this. I was also stuck at why my files gets deleted when running auto review tests.
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.
I won't be able to come to my laptop until Friday. Will you be able to effect the changes? Sorry again.
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.
I do not know how to change this. What if I edited the changelog and the test got lost? Cancellation is not possible.
I restored the files via the IDE timeline.
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.
Do I need to issue a note about uncommitted changes or create a temporary commit and return after the test?
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.
@paulbalandan see #10020