Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
_site/
/.idea
.jekyll-metadata
/build
/composer.lock
Gemfile.lock
/docs/modules/AbstractAsserts.md
/docs/modules/Phalcon.md
/docs/modules/Phalcon4.md
/package/composer.lock
/package/vendor
/vendor
.jekyll-cache
149 changes: 9 additions & 140 deletions RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ class RoboFile extends \Robo\Tasks
use DocumentationHelpers;

const REPO_BLOB_URL = 'https://github.com/Codeception/Codeception/blob';
const BRANCH_5x = '5.3';
const BRANCH_MAIN = 'main';
const RELEASES_URL = 'https://github.com/Codeception/Codeception/releases';
const PHAR_LATEST_URL = self::RELEASES_URL . '/latest/download/codecept.phar';

function post()
{
Expand Down Expand Up @@ -412,129 +413,6 @@ private function postProcessFile($pageName, $documentationFile)
file_put_contents($documentationFile, $contents);
}

public function buildPhar82()
{
$ignoredPlatformReqs = array(
'ext-apcu',
'ext-mongodb',
'ext-phalcon',
);

$version = self::BRANCH_5x . '.' . date('Ymd');
$releaseDir = "releases/$version";
$this->stopOnFail();
$this->taskFilesystemStack()->mkdir('build/82')->run();
$this->setCodeceptionVersionTo('^' . self::BRANCH_5x, $ignoredPlatformReqs);
$this->setPlatformVersionTo('8.2.0', $ignoredPlatformReqs);
$buildFile = 'build/82/codecept.phar';
$this->buildPhar($buildFile);
$this->updateVersionFile($buildFile, 'php82/codecept.version');
$versionedFile = "$releaseDir/codecept.phar";
$this->taskFilesystemStack()
->stopOnFail()
->mkdir($releaseDir)
->copy($buildFile, $versionedFile)
->remove('php82/codecept.phar')
->symlink("../$versionedFile", 'php82/codecept.phar')
->run();
}

public function release82()
{
$version = self::BRANCH_5x . '.' . date('Ymd');
$releaseDir = "releases/$version";
$this->updateBuildsPage();

$this->taskGitStack()
->stopOnFail()
->checkout('-- package/composer.json')
->add('builds.markdown')
->add('php82/codecept.phar')
->add('php82/codecept.version')
->add($releaseDir)
->run();
}

private function setPlatformVersionTo($version, $ignoredPlatformReqs = array())
{
$this->taskComposerConfig()->workingDir('package')->set('platform.php', $version)->run();
$composerUpdate = $this->taskComposerUpdate();
foreach ($ignoredPlatformReqs as $ignoredPlatformReq) {
$composerUpdate->option('--ignore-platform-req', $ignoredPlatformReq);
}
$composerUpdate->preferDist()->optimizeAutoloader()->workingDir('package')->run();
}

private function setCodeceptionVersionTo($version, $ignoredPlatformReqs = array())
{
$composerRequire = $this->taskComposerRequire()
->dependency('codeception/codeception', $version);
foreach ($ignoredPlatformReqs as $ignoredPlatformReq) {
$composerRequire->option('--ignore-platform-req', $ignoredPlatformReq);
}
$composerRequire->workingDir('package')
->run();
}

/**
* @desc creates codecept.phar
* @throws Exception
*/
public function buildPhar($targetFile)
{
$this->packPhar($targetFile);
$dir = dirname($targetFile);
//the file must be named codecept.phar to be executable
$this->taskFilesystemStack()->copy($targetFile, $dir . '/codecept.phar')->run();
$code = $this->taskExec('php codecept.phar')->dir($dir)->run()->getExitCode();
if ($code !== 0) {
throw new Exception("There was problem compiling phar");
}
}

private function packPhar($pharFileName)
{
$pharTask = $this->taskPackPhar($pharFileName)
->compress()
->stub('package/stub.php');

$finder = Finder::create()->files()
->ignoreVCS(true)
->name('*.php')
->name('*.php8')
->name('*.css')
->name('*.png')
->name('*.js')
->name('*.css')
->name('*.eot')
->name('*.svg')
->name('*.ttf')
->name('*.wof')
->name('*.woff')
->name('*.woff2')
->name('*.png')
->name('*.tpl')
->name('*.tpl.dist')
->name('*.html.dist')
->exclude('Tests')
->exclude('tests')
->exclude('benchmark')
->exclude('demo')
->in('package/vendor');

foreach ($finder as $file) {
$relativePathname = $file->getRelativePathname();
if (strpos($relativePathname, 'codeception/') === 0) {
//don't remove whitespace from Codeception files
$pharTask->addFile('vendor/' . $relativePathname, $file->getRealPath());
} else {
$pharTask->addStripped('vendor/' . $relativePathname, $file->getRealPath());
}
}

$pharTask->run();
}

public function processChangelog()
{
$client = new \Github\Client();
Expand Down Expand Up @@ -618,7 +496,13 @@ public function updateBuildsPage()
->line('layout: page')
->line('title: Codeception Builds')
->line('---')
->line('');
->line('')
->line("\n## 5.3 and newer")
->line("*Requires: PHP 8.2 and higher + CURL*\n")
->line('Starting with Codeception 5.3, the phar is built automatically and attached to every GitHub release.')
->line('')
->line('* **[Download Latest Release](' . self::PHAR_LATEST_URL . ')**')
->line('* [All Releases](' . self::RELEASES_URL . ')');

foreach ($releases as $release) {
$releaseName = $release->getBasename();
Expand Down Expand Up @@ -666,19 +550,4 @@ public function updateBuildsPage()
}
$releaseFile->run();
}

/**
* @param $pharFile
* @param $versionFile
*/
private function updateVersionFile($pharFile, $versionFile)
{
$hash = sha1_file($pharFile);
if ($hash === false) {
throw new Exception('Failed to write hash to file: ' . $versionFile);
}
$this->taskWriteToFile($versionFile)->text($hash)->run();
}


}
39 changes: 35 additions & 4 deletions _includes/phar.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
<div class="panel-group panel-group--phar" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseLatest"
aria-expanded="true" aria-controls="collapseLatest">
Download Codeception v5.3+ Phar Executable for PHP 8.2+
</a>
</h4>
</div>
<div id="collapseLatest" class="panel-collapse collapse in" role="tabpanel" tabindex="-1" aria-labelledby="collapseLatest">
<div class="panel-collapse-body">
<div class="row">
<div class="col-lg-3">
<a href="/thanks_php82" class="btn btn-success btn-expand">Download</a>
</div>
<div class="col-lg-9">
<div class="highlight">
<pre>wget https://github.com/Codeception/Codeception/releases/latest/download/codecept.phar<a href="/thanks_php82" class="phar-download"
target="_blank">download <span
class="glyphicon glyphicon-download"></span></a></pre>
</div>
</div>
</div>
<p>
Execute it as
<code>php codecept.phar</code></p>
<p>
Older releases are available on <a href="https://github.com/Codeception/Codeception/releases">GitHub</a>.</p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne"
aria-expanded="true" aria-controls="collapseOne">
Download Codeception v5 Phar Executable for PHP 8.0+
Download Codeception v5.0 - v5.1 Phar for PHP 8.0+
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" tabindex="-1" aria-labelledby="headingOne"
<div id="collapseOne" class="panel-collapse collapse" role="tabpanel" tabindex="-1" aria-labelledby="headingOne"
href="#collapseOne">
<div class="panel-collapse-body">
<div class="row">
Expand Down Expand Up @@ -91,14 +122,14 @@ <h4 class="panel-title">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" tabindex="-1" href="#collapseFour"
aria-expanded="true" aria-controls="collapseFour">
Install Phar Globally
Install Phar Globally (PHP 8.2+)
</a>
</h4>
</div>
<div id="collapseFour" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingFour">
<div class="panel-collapse-body">
<div class="highlight">
<pre>sudo curl -LsS https://codeception.com/php80/codecept.phar -o /usr/local/bin/codecept</pre>
<pre>sudo curl -LsS https://github.com/Codeception/Codeception/releases/latest/download/codecept.phar -o /usr/local/bin/codecept</pre>
<pre>sudo chmod a+x /usr/local/bin/codecept</pre>
</div>
<p>
Expand Down
2 changes: 1 addition & 1 deletion _layouts/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{% endif %}
<div class="links">
<p>
<a href="https://codeception.com/thanks.html">
<a href="https://codeception.com/thanks_php82.html">
<img src="https://poser.pugx.org/Codeception/Codeception/version.png" alt="Latest stable version">
</a>
<img
Expand Down
8 changes: 8 additions & 0 deletions builds.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ title: Codeception Builds
---


## 5.3 and newer
*Requires: PHP 8.2 and higher + CURL*

Starting with Codeception 5.3, the phar is built automatically and attached to every GitHub release.

* **[Download Latest Release](https://github.com/Codeception/Codeception/releases/latest/download/codecept.phar)**
* [All Releases](https://github.com/Codeception/Codeception/releases)

## 5.1
*Requires: PHP 8.0 and higher + CURL*

Expand Down
23 changes: 0 additions & 23 deletions package/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions package/composer.json

This file was deleted.

7 changes: 0 additions & 7 deletions package/stub.php

This file was deleted.

21 changes: 21 additions & 0 deletions thanks_php82.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
layout: bootstrap
title: Thanks for choosing Codeception!
meta:
<meta http-equiv="REFRESH" content="3;url=https://github.com/Codeception/Codeception/releases/latest/download/codecept.phar">
---
<div class="container">
<div class="row">
<div class="col-xs-12 fill-thanks">
<h2>Installation - Codeception v5.3+ Phar for PHP 8.2+</h2>
<p><strong>1.</strong> Save this file into the root of desired PHP project</p>
<p><strong>2.</strong> Initialize test classes inside the root of your project</p>
<p><code>php codecept.phar bootstrap</code></p>
<p><strong>3.</strong> Write your tests!</p>
<p>Follow <a href="https://codeception.com/docs/GettingStarted"> Getting Started Guide</a> to perform
configuration and write the first test.</p>
<p class="small">Your download is on the way. <a href="https://github.com/Codeception/Codeception/releases/latest/download/codecept.phar"> Click
here</a> if you don't want to wait any longer</p>
</div>
</div>
</div>