Skip to content

Commit

Permalink
Update workflows to reusable workflows (#54)
Browse files Browse the repository at this point in the history
* Update workflows to reusable workflows

* Use php 8.2 only test.

* Add php cs config.

* Add php cs config.

* Add token.

* Apply php-cs-fixer changes

* Apply php-cs-fixer changes

* Add token.

* Add token.

* Add token.

---------

Co-authored-by: Herbert Roth <[email protected]>
Co-authored-by: herbertroth <[email protected]>
  • Loading branch information
3 people authored May 8, 2024
1 parent b7720b0 commit 7ee01fa
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 139 deletions.
45 changes: 7 additions & 38 deletions .github/workflows/codeception.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,10 @@ env:

jobs:
codeception-tests:
name: "Codeception tests"
runs-on: "ubuntu-20.04"
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
include:
- { php-version: 8.2, dependencies: lowest, pimcore_version: "", experimental: false }

steps:
- name: "Checkout code"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: xdebug
ini-values: display_errors=On, display_startup_errors=On, error_reporting=32767
php-version: "${{ matrix.php-version }}"

- name: Install SSH Key # this is necessary for Composer to be able to clone source from pimcore/ee-pimcore
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
known_hosts: 'TBD'

- name: "Add authentication for private pimcore packages"
run: |
composer config repositories.private-packagist composer https://repo.pimcore.com/github-actions/
composer config --global --auth http-basic.repo.pimcore.com github-actions ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run Codeception"
run: "vendor/bin/codecept run -c . -vvv --xml --coverage-xml"
uses: pimcore/workflows-collection-public/.github/workflows/reusable-codeception-tests-8-2-only.yaml@main
with:
APP_ENV: test
PIMCORE_TEST: 1
secrets:
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
22 changes: 7 additions & 15 deletions .github/workflows/php-cs-fixer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,10 @@ permissions:
contents: read

jobs:
php-cs-fixer:
permissions:
contents: write # for stefanzweifel/git-auto-commit-action to push code in repo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: PHP-CS-Fixer
uses: docker://oskarstark/php-cs-fixer-ga:latest

- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply php-cs-fixer changes
php-style:
uses: pimcore/workflows-collection-public/.github/workflows/reusable-php-style.yaml@main
secrets:
PHP_CS_FIXER_GITHUB_TOKEN: ${{ secrets.PHP_CS_FIXER_GITHUB_TOKEN }}
with:
head_ref: ${{ github.ref }}
config_file: .php-cs-fixer.dist.php
12 changes: 4 additions & 8 deletions .github/workflows/poeditor-export.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ permissions:
contents: read

jobs:
poeditor:
runs-on: ubuntu-latest
steps:
- name: Trigger workflow in pimcore/poeditor-export-action
env:
GH_TOKEN: ${{ secrets.POEDITOR_ACTION_TRIGGER_TOKEN }}
run: |
gh workflow run -R pimcore/poeditor-export-action poeditor-export.yaml
php-style:
uses: pimcore/workflows-collection-public/.github/workflows/reusable-poeditor.yaml@main
secrets:
POEDITOR_ACTION_TRIGGER_TOKEN: ${{ secrets.POEDITOR_ACTION_TRIGGER_TOKEN }}
64 changes: 5 additions & 59 deletions .github/workflows/static-analysis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,62 +18,8 @@ on:
- "*_actions"

jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-20.04"
strategy:
matrix:
include:
- { php-version: "8.2", dependencies: "highest", experimental: false }
- { php-version: "8.2", dependencies: "highest", pimcore_version: "11.x-dev as 11.99.9", experimental: true }
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"

- name: Install SSH Key # this is necessary for Composer to be able to clone source from pimcore/ee-pimcore
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
known_hosts: 'TBD'

- name: "Add authentication for private pimcore packages"
run: |
composer config repositories.private-packagist composer https://repo.pimcore.com/github-actions/
composer config --global --auth http-basic.repo.pimcore.com github-actions ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
- name: "Setup Pimcore environment"
run: |
.github/ci/scripts/setup-pimcore-environment.sh
- name: "Update Pimcore version"
env:
PIMCORE_VERSION: "${{ matrix.pimcore_version }}"
run: |
if [ ! -z "$PIMCORE_VERSION" ]; then
composer require --no-update pimcore/pimcore:"${PIMCORE_VERSION}"
fi
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v2"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse --memory-limit=-1"

- name: "Generate baseline file"
if: ${{ failure() }}
run: "vendor/bin/phpstan analyse --memory-limit=-1 --generate-baseline"

- name: "Upload baseline file"
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: phpstan-baseline.neon
path: phpstan-baseline.neon
static-analysis:
uses: pimcore/workflows-collection-public/.github/workflows/reusable-static-analysis-8-2-only.yaml@main
secrets:
COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN: ${{ secrets.COMPOSER_PIMCORE_REPO_PACKAGIST_TOKEN }}
SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER: ${{ secrets.SSH_PRIVATE_KEY_PIMCORE_DEPLOYMENTS_USER }}
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/DataObject/ClassNameFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class ClassNameFilter implements FilterInterface
*/
public function apply(CollectionParametersInterface $parameters, QueryInterface $query): QueryInterface
{
if(
if (
!$parameters instanceof DataObjectParametersInterface ||
!$query instanceof DataObjectQuery ||
!$parameters->getClassName()
Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/ExcludeFolderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function apply(CollectionParametersInterface $parameters, QueryInterface
}

$excludeFolders = $parameters->getExcludeFolders();
if(!$excludeFolders) {
if (!$excludeFolders) {
return $query;
}

Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/IdSearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function apply(CollectionParametersInterface $parameters, QueryInterface

$idSearchTerm = $parameters->getIdSearchTerm();

if(!$idSearchTerm) {
if (!$idSearchTerm) {
return $query;
}

Expand Down
2 changes: 1 addition & 1 deletion src/DataIndex/Filter/ParentIdFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function apply(CollectionParametersInterface $parameters, QueryInterface

$parentId = $parameters->getParentId();

if(!$parentId) {
if (!$parentId) {
return $query;
}

Expand Down
20 changes: 10 additions & 10 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,22 @@ private function addAllowedHostsForCorsNode(ArrayNodeDefinition $node): void
->prototype('scalar')->end()
->validate()
->always(
/**
* @throws InvalidHostException
*/ function ($hosts) {
foreach ($hosts as $host) {
if (!filter_var($host)) {
throw new InvalidHostException(
/**
* @throws InvalidHostException
*/ function ($hosts) {
foreach ($hosts as $host) {
if (!filter_var($host)) {
throw new InvalidHostException(
sprintf(
'The host "%s" is not a valid url.',
$host
)
);
}
}
}
}

return $hosts;
})
return $hosts;
})
->end()
->end();
}
Expand Down
4 changes: 2 additions & 2 deletions src/Filter/Service/FilterServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ final class FilterServiceProvider implements FilterServiceProviderInterface

public function __construct(FilterServiceLoaderInterface $taggedIteratorAdapter)
{
foreach($taggedIteratorAdapter->loadFilterServices() as $filterService) {
foreach ($taggedIteratorAdapter->loadFilterServices() as $filterService) {
$this->filterServices[$filterService->getType()] = $filterService;
}
}

public function create(string $type): mixed
{
if(!array_key_exists($type, $this->filterServices)) {
if (!array_key_exists($type, $this->filterServices)) {
throw new InvalidFilterServiceTypeException(400, "Unknown filter type: $type");
}

Expand Down
2 changes: 1 addition & 1 deletion src/Translation/Service/TranslatorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class TranslatorService implements TranslatorServiceInterface
public function __construct(
TranslatorInterface $translator
) {
if(!$translator instanceof TranslatorBagInterface) {
if (!$translator instanceof TranslatorBagInterface) {
throw new InvalidArgumentException('Translator must implement TranslatorBagInterface');
}

Expand Down
4 changes: 2 additions & 2 deletions src/Util/Traits/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ trait RequestTrait
private function getAuthToken(Request $request): string
{
$authToken = $request->headers->get(self::AUTHORIZATION_HEADER);
if($authToken === null) {
if ($authToken === null) {
throw new NotAuthorizedException();
}

Expand All @@ -50,7 +50,7 @@ private function getCurrentRequest(RequestStack $requestStack): Request
{
$request = $requestStack->getCurrentRequest();

if(!$request) {
if (!$request) {
throw new NoRequestException();
}

Expand Down

0 comments on commit 7ee01fa

Please sign in to comment.