Skip to content

Commit

Permalink
Merge pull request #191 from mpdude/fix-build
Browse files Browse the repository at this point in the history
Fix the build pipeline in GitHub Actions
  • Loading branch information
Yozhef authored Nov 26, 2022
2 parents 572c34e + bdefae6 commit 3645bd6
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 28 deletions.
89 changes: 75 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ on:
jobs:
test:
name: PHP ${{ matrix.php-version }} + Symfony ${{ matrix.symfony-version }}
runs-on: ubuntu-20.04
continue-on-error: false
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
Expand All @@ -24,37 +23,99 @@ jobs:
- '8.1'
symfony-version:
- '4.4.*'
- '5.3.*'
- '5.4.*'
- '6.0.*'
exclude:
- php-version: '7.4'
symfony-version: '6.0.*'
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
ini-values: "memory_limit=-1"
ini-values: "memory_limit=-1, zend.assertions=1"
php-version: ${{ matrix.php-version }}
tools: composer:v2, flex

# This works around SYMFONY_REQUIRE currently not working (https://github.com/symfony/flex/issues/946):
- name: Lock Symfony version
run: VERSION=${{ matrix.symfony-version }} .github/workflows/lock-symfony-version.sh

- name: Install dependencies
run: |
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer install --prefer-dist --no-progress --no-plugins
#env:
# SYMFONY_REQUIRE: "${{ matrix.symfony-version }}"

- name: Run tests
run: composer test

psalm:
name: Run Psalm
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
ini-values: "memory_limit=-1, zend.assertions=1"
php-version: 7.4
tools: composer:v2, flex

- name: Install dependencies
run: |
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer install --prefer-dist --no-progress --no-plugins
- name: Run Psalm
run: vendor/bin/psalm src --no-progress

validate-composer:
name: Validate composer.json
runs-on: ubuntu-22.04
continue-on-error: false
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
ini-values: "memory_limit=-1, zend.assertions=1"
php-version: 8.1
tools: composer:v2, flex

- name: Validate composer.json
run: composer validate --strict

coding-standards:
name: Validate Coding Standards
runs-on: ubuntu-22.04
continue-on-error: false
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
coverage: none
ini-values: "memory_limit=-1, zend.assertions=1"
php-version: 8.1
tools: composer:v2, flex

- name: Install dependencies
run: composer install --prefer-dist --no-progress
env:
SYMFONY_REQUIRE: "${{ matrix.symfony-version }}"
run: |
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
composer install --prefer-dist --no-progress
- name: Run coding standard
run: vendor/bin/ecs check --ansi --no-progress-bar src tests

- name: Run Psalm
run: vendor/bin/psalm src --no-progress --php-version="${{ matrix.php-version }}"

- name: Run tests
run: composer test
4 changes: 4 additions & 0 deletions .github/workflows/lock-symfony-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

cat <<< $(jq --indent 4 --arg version $VERSION '.require |= with_entries(if (.key|test("^symfony/")) then .value=$version else . end)' < composer.json) > composer.json
cat <<< $(jq --indent 4 --arg version $VERSION '."require-dev" |= with_entries(if (.key|test("^symfony/")) then .value=$version else . end)' < composer.json) > composer.json
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"friends-of-behat/mink-extension": "^2.5",
"friends-of-behat/page-object-extension": "^0.3.2",
"friends-of-behat/service-container-extension": "^1.1",
"sylius-labs/coding-standard": "^4.1.1",
"sylius-labs/coding-standard": ">=4.1.1, <=4.2.1",
"symfony/browser-kit": "^4.4 || ^5.3 || ^6.0",
"symfony/framework-bundle": "^4.4 || ^5.3 || ^6.0",
"symfony/process": "^4.4 || ^5.3 || ^6.0",
Expand Down
10 changes: 9 additions & 1 deletion features/dependency_injection/autowiring_contexts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Feature: Autowiring contexts
App\Tests\SomeContext:
public: true
# https://github.com/symfony/symfony/pull/35879/
Psr\Container\ContainerInterface:
alias: service_container
"""
When I run Behat
Then it should pass
Expand Down Expand Up @@ -128,6 +132,10 @@ Feature: Autowiring contexts
App\Tests\:
resource: '../tests/*'
# https://github.com/symfony/symfony/pull/35879/
Psr\Container\ContainerInterface:
alias: service_container
"""
When I run Behat
Then it should pass
Expand Down Expand Up @@ -177,4 +185,4 @@ Feature: Autowiring contexts
resource: '../tests/*'
"""
When I run Behat
Then it should pass
Then it should pass
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private function getSuiteContextsServices(Suite $suite): array
throw new SuiteConfigurationException(sprintf(
'"contexts" setting of the "%s" suite is expected to be an array, %s given.',
$suite->getName(),
gettype($contexts)
gettype($contexts),
), $suite->getName());
}

Expand All @@ -147,7 +147,7 @@ private function cloneSuiteWithoutContexts(Suite $suite, array $contextsToRemove
throw new SuiteConfigurationException(sprintf(
'"contexts" setting of the "%s" suite is expected to be an array, %s given.',
$suite->getName(),
gettype($contexts)
gettype($contexts),
), $suite->getName());
}

Expand Down Expand Up @@ -182,7 +182,7 @@ private function assertEnvironmentCanBeIsolated(Environment $uninitializedEnviro
throw new EnvironmentIsolationException(sprintf(
'"%s" does not support isolation of "%s" environment.',
static::class,
get_class($uninitializedEnvironment)
get_class($uninitializedEnvironment),
), $uninitializedEnvironment);
}
}
Expand All @@ -197,7 +197,7 @@ private function getContainer(): ContainerInterface
get_class($this->symfonyKernel),
$this->symfonyKernel->getEnvironment(),
$this->symfonyKernel->isDebug() ? 'enabled' : 'disabled',
FriendsOfBehatSymfonyExtensionBundle::class
FriendsOfBehatSymfonyExtensionBundle::class,
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getContext(string $class): Context
if (!isset($this->contexts[$class])) {
throw new ContextNotFoundException(sprintf(
'`%s` context is not found in the suite environment. Have you registered it?',
$class
$class,
), $class);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Driver/SymfonyDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(KernelInterface $kernel, ?string $baseUrl)
'Please make sure the kernel is using "test" environment or have "framework.test" configuration option enabled.',
get_class($kernel),
$kernel->getEnvironment(),
$kernel->isDebug() ? 'enabled' : 'disabled'
$kernel->isDebug() ? 'enabled' : 'disabled',
));
}

Expand All @@ -31,7 +31,7 @@ public function __construct(KernelInterface $kernel, ?string $baseUrl)
'Service "test.client" should be an instance of "%s" or "%s", "%s" given.',
Client::class,
AbstractBrowser::class,
get_class($testClient)
get_class($testClient),
));
}

Expand Down
4 changes: 2 additions & 2 deletions src/ServiceContainer/SymfonyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private function autodiscoverKernelConfiguration(array $config): array
if ($autodiscovered !== 1) {
throw new \RuntimeException(
'Could not autodiscover the application kernel. ' .
'Please define it manually with "FriendsOfBehat\SymfonyExtension.kernel" configuration option.'
'Please define it manually with "FriendsOfBehat\SymfonyExtension.kernel" configuration option.',
);
}

Expand Down Expand Up @@ -260,7 +260,7 @@ private function autodiscoverBootstrap($bootstrap): ?string
throw new \RuntimeException(
'Could not autodiscover the bootstrap file. ' .
'Please define it manually with "FriendsOfBehat\SymfonyExtension.bootstrap" configuration option. ' .
'Setting that option to "false" disables autodiscovering.'
'Setting that option to "false" disables autodiscovering.',
);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Behat/Context/TestContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public function itShouldPass(): void
}

throw new \DomainException(
'Behat was expecting to pass, but failed with the following output:' . \PHP_EOL . \PHP_EOL . $this->getProcessOutput()
'Behat was expecting to pass, but failed with the following output:' . \PHP_EOL . \PHP_EOL . $this->getProcessOutput(),
);
}

Expand All @@ -333,7 +333,7 @@ public function itShouldFail(): void
}

throw new \DomainException(
'Behat was expecting to fail, but passed with the following output:' . \PHP_EOL . \PHP_EOL . $this->getProcessOutput()
'Behat was expecting to fail, but passed with the following output:' . \PHP_EOL . \PHP_EOL . $this->getProcessOutput(),
);
}

Expand Down Expand Up @@ -371,7 +371,7 @@ private function assertOutputMatches($expectedOutput): void
throw new \DomainException(sprintf(
'Pattern "%s" does not match the following output:' . \PHP_EOL . \PHP_EOL . '%s',
$pattern,
$output
$output,
));
}
}
Expand Down

0 comments on commit 3645bd6

Please sign in to comment.