This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4798be
commit 2747fd6
Showing
11 changed files
with
124 additions
and
56 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -39,14 +39,18 @@ jobs: | |
- | ||
name: Run ecs.phar | ||
run: | | ||
cd packages/EasyCodingStandard/compiler | ||
../tmp/ecs.phar | ||
# remove local vendor, to prevent duplicated content | ||
rm -rf packages/EasyCodingStandard/vendor | ||
cd packages/EasyCodingStandard | ||
tmp/ecs.phar | ||
- | ||
name: Run ecs.phar with PSR-12 set | ||
run: | | ||
cd packages/EasyCodingStandard/compiler | ||
../tmp/ecs.phar check ../src --set psr12 --dry-run --debug | ||
cd packages/EasyCodingStandard | ||
# create dummy file | ||
echo "<?php echo 'hi';" >> someFile.php | ||
tmp/ecs.phar check someFile.php --set dead-code | ||
# Deploy PHAR to https://github.com/Symplify/EasyCodingStandardPrefixed | ||
- | ||
|
@@ -57,19 +61,23 @@ jobs: | |
# reuse tmp/ecs.phar from previous job | ||
git clone https://${ACCESS_TOKEN}@github.com/Symplify/EasyCodingStandardPrefixed.git > /dev/null 2>&1 | ||
# copy phar files inside cloned repository | ||
cp tmp/ecs.phar EasyCodingStandardPrefixed/ecs.phar | ||
cp tmp/ecs.phar EasyCodingStandardPrefixed/ecs | ||
cd EasyCodingStandardPrefixed | ||
# go to clone repository | ||
cd EasyCodingStandardPrefixed | ||
git config user.email "[email protected]" | ||
git config user.name "Github Actions" | ||
git add ecs ecs.phar | ||
# commit with new tag, if this commit is tagged, or with normal commit | ||
if [ "${TRAVIS_TAG}" != "" ]; then COMMIT_MSG="ECS ${TRAVIS_TAG}"; else COMMIT_MSG="Updated ECS to commit ${TRAVIS_COMMIT}"; fi | ||
git commit -m "${COMMIT_MSG}" | ||
git push --quiet origin master | ||
# push tag, if this commit is tagged, or with normal push | ||
if [ "${TRAVIS_TAG}" != "" ]; then git tag "${TRAVIS_TAG}" && git push --quiet origin ${TRAVIS_TAG}; fi | ||
env: | ||
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
This file contains 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 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 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
52 changes: 52 additions & 0 deletions
52
packages/EasyCodingStandard/compiler/src/Packagist/SymplifyStableVersionProvider.php
This file contains 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,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symplify\EasyCodingStandard\Compiler\Packagist; | ||
|
||
use Nette\Utils\Json; | ||
use PharIo\Version\Version; | ||
use Symplify\EasyCodingStandard\Compiler\Exception\ShouldNotHappenException; | ||
|
||
final class SymplifyStableVersionProvider | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
private $symplifyVersionToRequire; | ||
|
||
public function provide(): string | ||
{ | ||
if ($this->symplifyVersionToRequire !== null) { | ||
return $this->symplifyVersionToRequire; | ||
} | ||
|
||
$symplifyPackageContent = file_get_contents('https://repo.packagist.org/p/symplify/symplify.json'); | ||
if ($symplifyPackageContent === null) { | ||
throw new ShouldNotHappenException(); | ||
} | ||
|
||
$symplifyPackageJson = $this->loadContentJsonStringToArray($symplifyPackageContent); | ||
$symplifyPackageVersions = $symplifyPackageJson['packages']['symplify/symplify']; | ||
|
||
$lastStableVersion = $this->getLastKey($symplifyPackageVersions); | ||
|
||
$lastStableVersion = new Version($lastStableVersion); | ||
|
||
$this->symplifyVersionToRequire = '^' . $lastStableVersion->getMajor()->getValue() . '.' . $lastStableVersion->getMinor()->getValue(); | ||
|
||
return $this->symplifyVersionToRequire; | ||
} | ||
|
||
private function loadContentJsonStringToArray(string $jsonContent): array | ||
{ | ||
return Json::decode($jsonContent, Json::FORCE_ARRAY); | ||
} | ||
|
||
private function getLastKey(array $items): string | ||
{ | ||
end($items); | ||
|
||
return key($items); | ||
} | ||
} |
This file contains 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
2 changes: 1 addition & 1 deletion
2
packages/EasyCodingStandard/config/set/php_cs_fixer/php-cs-fixer-psr2.yaml
This file contains 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 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 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 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 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