Skip to content

Commit 8b9af62

Browse files
committed
Build phar file of Codeception 5.0
1 parent 2c19f8f commit 8b9af62

File tree

2 files changed

+69
-14
lines changed

2 files changed

+69
-14
lines changed

RoboFile.php

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class RoboFile extends \Robo\Tasks
1010
use DocumentationHelpers;
1111

1212
const REPO_BLOB_URL = 'https://github.com/Codeception/Codeception/blob';
13-
const STABLE_BRANCH = '4.1';
13+
const BRANCH_4x = '4.2';
14+
const BRANCH_5x = '5.0';
1415

1516
function post()
1617
{
@@ -180,12 +181,11 @@ public function buildDocsUtils()
180181
$utils = [
181182
'Autoload' => null,
182183
'Fixtures' => null,
183-
'Locator' => null,
184-
'XmlBuilder' => null,
184+
'Locator' => 'lib-web',
185+
'XmlBuilder' => 'lib-xml',
185186
'JsonType' => 'module-rest',
186187
'HttpCode' => 'lib-innerbrowser',
187188
];
188-
//JsonType is in module-rest, HttpCode - in lib-innerbrowser
189189

190190
foreach ($utils as $utilName => $repositoryName) {
191191
$className = '\Codeception\Util\\' . $utilName;
@@ -322,7 +322,7 @@ public function buildDocsExtensions()
322322
->prepend("# Official Extensions\n")
323323
->processClassSignature(function (ReflectionClass $r, $text) {
324324
$name = $r->getShortName();
325-
return "## $name\n\n[See Source](" . self::REPO_BLOB_URL . "/" . self::STABLE_BRANCH . "/ext/$name.php)";
325+
return "## $name\n\n[See Source](" . self::REPO_BLOB_URL . "/" . self::BRANCH_5x . "/ext/$name.php)";
326326
})
327327
->filterMethods(function (ReflectionMethod $r) {
328328
return false;
@@ -336,7 +336,7 @@ public function buildDocsExtensions()
336336
protected function documentApiClass($file, $className, $all = false, $repositoryName = null)
337337
{
338338
if ($repositoryName === null) {
339-
$repositoryUrl = self::REPO_BLOB_URL . "/" . self::STABLE_BRANCH;
339+
$repositoryUrl = self::REPO_BLOB_URL . "/" . self::BRANCH_5x;
340340
} else {
341341
$repositoryUrl = 'https://github.com/Codeception/' . $repositoryName . '/blob/master';
342342
}
@@ -471,9 +471,31 @@ private function postProcessFile($pageName, $documentationFile)
471471
file_put_contents($documentationFile, $contents);
472472
}
473473

474+
public function buildPhar80()
475+
{
476+
$version = self::BRANCH_5x . '.' . date('Ymd');
477+
$releaseDir = "releases/$version";
478+
$this->stopOnFail();
479+
480+
$this->taskFilesystemStack()->mkdir('build/80')->run();
481+
$this->setCodeceptionVersionTo('^5.0');
482+
$this->setPlatformVersionTo('8.0.2');
483+
$buildFile = 'build/80/codecept.phar';
484+
$this->buildPhar($buildFile);
485+
$this->updateVersionFile($buildFile, 'php80/codecept.version');
486+
$versionedFile = "$releaseDir/codecept.phar";
487+
$this->taskFilesystemStack()
488+
->stopOnFail()
489+
->mkdir($releaseDir)
490+
->copy($buildFile, $versionedFile)
491+
->remove('php80/codecept.phar')
492+
->symlink($versionedFile, 'php80/codecept.phar')
493+
->run();
494+
}
495+
474496
public function buildPhar72()
475497
{
476-
$version = self::STABLE_BRANCH . '.' . date('Ymd');
498+
$version = self::BRANCH_4x . '.' . date('Ymd');
477499
$releaseDir = "releases/$version";
478500
$this->stopOnFail();
479501

@@ -494,7 +516,7 @@ public function buildPhar72()
494516

495517
public function buildPhar56()
496518
{
497-
$version = self::STABLE_BRANCH . '.' . date('Ymd');
519+
$version = self::BRANCH_4x . '.' . date('Ymd');
498520
$releaseDir = "releases/$version";
499521
$this->stopOnFail();
500522

@@ -522,7 +544,7 @@ public function findReleases()
522544

523545
public function release()
524546
{
525-
$version = self::STABLE_BRANCH . '.' . date('Ymd');
547+
$version = self::BRANCH_4x . '.' . date('Ymd');
526548
$releaseDir = "releases/$version";
527549
$this->updateBuildsPage();
528550

@@ -538,12 +560,37 @@ public function release()
538560
->run();
539561
}
540562

563+
public function release80()
564+
{
565+
$version = self::BRANCH_5x . '.' . date('Ymd');
566+
$releaseDir = "releases/$version";
567+
$this->updateBuildsPage();
568+
569+
$this->taskGitStack()
570+
->stopOnFail()
571+
->checkout('-- package/composer.json')
572+
->add('builds.markdown')
573+
->add('php80/codecept.phar')
574+
->add('php80/codecept.version')
575+
->add($releaseDir)
576+
->run();
577+
}
578+
541579
private function setPlatformVersionTo($version)
542580
{
543581
$this->taskComposerConfig()->workingDir('package')->set('platform.php', $version)->run();
544582
$this->taskComposerUpdate()->preferDist()->optimizeAutoloader()->workingDir('package')->run();
545583
}
546584

585+
private function setCodeceptionVersionTo($version)
586+
{
587+
$this->taskComposerRequire()
588+
->dependency('codeception/codeception', $version)
589+
->ignorePlatformRequirements()
590+
->workingDir('package')
591+
->run();
592+
}
593+
547594
/**
548595
* @desc creates codecept.phar
549596
* @throws Exception
@@ -701,8 +748,10 @@ public function updateBuildsPage()
701748
$releaseFile->line("*Requires: PHP 5.3 and higher + CURL*\n");
702749
} elseif ($major == 2 && $minor < 4) {
703750
$releaseFile->line("*Requires: PHP 5.4 and higher + CURL*\n");
704-
} else {
751+
} elseif ($major < 5) {
705752
$releaseFile->line("*Requires: PHP 5.6 and higher + CURL*\n");
753+
} else {
754+
$releaseFile->line("*Requires: PHP 8.0 and higher + CURL*\n");
706755
}
707756
$releaseFile->line("* **[Download Latest $branch Release]($downloadUrl)**");
708757
}

package/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ Additional dependency compared with codeception/codecepion:
1717
### Build instructions
1818
1. Install dependencies by running `composer install` in parent directory.
1919
2. Disable phar.readonly in your php.ini file, it must be `phar.readonly = Off`
20-
3. Run `./vendor/bin/robo build:phar72`
21-
4. Run `./vendor/bin/robo build:phar56`
22-
5. Run `./vendor/bin/robo release`
23-
6. Commit added files and push
20+
3. Build Codeception 4 phar file:
21+
1. Run `./vendor/bin/robo build:phar72`
22+
2. Run `./vendor/bin/robo build:phar56`
23+
3. Run `./vendor/bin/robo release`
24+
4. Build Codeception 5 phar file:
25+
1. Run `./vendor/bin/robo build:phar80`
26+
2. Run `./vendor/bin/robo release80`
27+
5. Commit added files and push
28+
29+
Note: it is necessary to delete package/composer.lock and package/vendor between Codeception 4 and 5 builds.

0 commit comments

Comments
 (0)