Skip to content

Commit dc0e179

Browse files
authored
Merge pull request #588 from Codeception/codeception5-phar-build
Build phar file of Codeception 5.0
2 parents 488f620 + 5a181cb commit dc0e179

File tree

7 files changed

+90
-22
lines changed

7 files changed

+90
-22
lines changed

RoboFile.php

Lines changed: 71 additions & 16 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.2';
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,14 +471,38 @@ 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

480502
$this->taskFilesystemStack()->mkdir('build/72')->run();
503+
$this->setCodeceptionVersionTo('^4.1');
481504
$this->setPlatformVersionTo('7.2.0');
505+
$this->requireHoaConsole();
482506
$buildFile = 'build/72/codecept.phar';
483507
$this->buildPhar($buildFile);
484508
$this->updateVersionFile($buildFile, 'codecept.version');
@@ -494,12 +518,14 @@ public function buildPhar72()
494518

495519
public function buildPhar56()
496520
{
497-
$version = self::STABLE_BRANCH . '.' . date('Ymd');
521+
$version = self::BRANCH_4x . '.' . date('Ymd');
498522
$releaseDir = "releases/$version";
499523
$this->stopOnFail();
500524

501525
$this->taskFilesystemStack()->mkdir('build/56')->run();
526+
$this->setCodeceptionVersionTo('^4.1');
502527
$this->setPlatformVersionTo('5.6.4');
528+
$this->requireHoaConsole();
503529
//filenames must be different, because Phar refuses to build second file with the same name
504530
$buildFile = 'build/56/codecept.phar';
505531
$this->buildPhar($buildFile);
@@ -512,17 +538,19 @@ public function buildPhar56()
512538
->remove('php56/codecept.phar')
513539
->symlink("../$versionedFile", 'php56/codecept.phar')
514540
->run();
515-
516541
}
517542

518-
public function findReleases()
543+
private function requireHoaConsole(): void
519544
{
520-
545+
$this->taskComposerRequire()
546+
->dependency('hoa/console')
547+
->workingDir('package')
548+
->run();
521549
}
522550

523551
public function release()
524552
{
525-
$version = self::STABLE_BRANCH . '.' . date('Ymd');
553+
$version = self::BRANCH_4x . '.' . date('Ymd');
526554
$releaseDir = "releases/$version";
527555
$this->updateBuildsPage();
528556

@@ -538,12 +566,37 @@ public function release()
538566
->run();
539567
}
540568

569+
public function release80()
570+
{
571+
$version = self::BRANCH_5x . '.' . date('Ymd');
572+
$releaseDir = "releases/$version";
573+
$this->updateBuildsPage();
574+
575+
$this->taskGitStack()
576+
->stopOnFail()
577+
->checkout('-- package/composer.json')
578+
->add('builds.markdown')
579+
->add('php80/codecept.phar')
580+
->add('php80/codecept.version')
581+
->add($releaseDir)
582+
->run();
583+
}
584+
541585
private function setPlatformVersionTo($version)
542586
{
543587
$this->taskComposerConfig()->workingDir('package')->set('platform.php', $version)->run();
544588
$this->taskComposerUpdate()->preferDist()->optimizeAutoloader()->workingDir('package')->run();
545589
}
546590

591+
private function setCodeceptionVersionTo($version)
592+
{
593+
$this->taskComposerRequire()
594+
->dependency('codeception/codeception', $version)
595+
->ignorePlatformRequirements()
596+
->workingDir('package')
597+
->run();
598+
}
599+
547600
/**
548601
* @desc creates codecept.phar
549602
* @throws Exception
@@ -691,7 +744,7 @@ public function updateBuildsPage()
691744

692745
foreach ($releases as $release) {
693746
$releaseName = $release->getBasename();
694-
$downloadUrl = "http://codeception.com/releases/$releaseName/codecept.phar";
747+
$downloadUrl = "https://codeception.com/releases/$releaseName/codecept.phar";
695748

696749
list($major, $minor) = explode('.', $releaseName);
697750
if ("$major.$minor" != $branch) {
@@ -701,14 +754,16 @@ public function updateBuildsPage()
701754
$releaseFile->line("*Requires: PHP 5.3 and higher + CURL*\n");
702755
} elseif ($major == 2 && $minor < 4) {
703756
$releaseFile->line("*Requires: PHP 5.4 and higher + CURL*\n");
704-
} else {
757+
} elseif ($major < 5) {
705758
$releaseFile->line("*Requires: PHP 5.6 and higher + CURL*\n");
759+
} else {
760+
$releaseFile->line("*Requires: PHP 8.0 and higher + CURL*\n");
706761
}
707762
$releaseFile->line("* **[Download Latest $branch Release]($downloadUrl)**");
708763
}
709764

710765
if (file_exists("releases/$releaseName/php54/codecept.phar")) {
711-
$downloadUrl2 = "http://codeception.com/releases/$releaseName/php54/codecept.phar";
766+
$downloadUrl2 = "https://codeception.com/releases/$releaseName/php54/codecept.phar";
712767
if (version_compare($releaseName, '2.4.0', '>=')) {
713768
$versionLine = "* [$releaseName for PHP 7]($downloadUrl)";
714769
$versionLine .= ", [for PHP 5.6]($downloadUrl2)";
@@ -721,7 +776,7 @@ public function updateBuildsPage()
721776
}
722777
} elseif (file_exists("releases/$releaseName/php56/codecept.phar")) {
723778
$versionLine = "* [$releaseName for PHP 7.2+]($downloadUrl)";
724-
$downloadUrl2 = "http://codeception.com/releases/$releaseName/php56/codecept.phar";
779+
$downloadUrl2 = "https://codeception.com/releases/$releaseName/php56/codecept.phar";
725780
$versionLine .= ", [for PHP 5.6 - 7.1]($downloadUrl2)";
726781
} else {
727782
$versionLine = "* [$releaseName]($downloadUrl)";

builds.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ title: Codeception Builds
44
---
55

66

7+
## 5.0
8+
*Requires: PHP 8.0 and higher + CURL*
9+
10+
* **[Download Latest 5.0 Release](https://codeception.com/releases/5.0.20220728/codecept.phar)**
11+
* [5.0.20220728](https://codeception.com/releases/5.0.20220728/codecept.phar)
12+
713
## 4.2
814
*Requires: PHP 5.6 and higher + CURL*
915

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.

package/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"codeception/module-sequence": "*",
2323
"codeception/module-soap": "*",
2424
"codeception/module-webdriver": "*",
25-
"hoa/console": "*",
26-
"padraic/phar-updater": "^1.0"
25+
"laravel-zero/phar-updater": "^1.0"
2726
}
2827
}

php80/codecept.phar

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
releases/5.0.20220728/codecept.phar

php80/codecept.version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
be3b88554c95dccaab26b679dc99c9b334333520
8.25 MB
Binary file not shown.

0 commit comments

Comments
 (0)