From 3ef31930adfeded89609557570a1af764a8f71ae Mon Sep 17 00:00:00 2001 From: dante di domenico Date: Wed, 7 Sep 2022 12:04:49 +0200 Subject: [PATCH 1/3] refactor: php workflow --- .github/workflows/{test.yml => php.yml} | 85 ++++--------------------- 1 file changed, 13 insertions(+), 72 deletions(-) rename .github/workflows/{test.yml => php.yml} (58%) diff --git a/.github/workflows/test.yml b/.github/workflows/php.yml similarity index 58% rename from .github/workflows/test.yml rename to .github/workflows/php.yml index e4d3f7c..9309e3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/php.yml @@ -1,91 +1,32 @@ -name: 'Run tests' +name: 'php' on: pull_request: paths: - '**/*.php' - - '.github/workflows/*' + - '.github/workflows/php.yml' + - 'composer.json' push: paths: - '**/*.php' - - '.github/workflows/*' + - '.github/workflows/php.yml' + - 'composer.json' jobs: cs: - name: 'Check coding style' - runs-on: 'ubuntu-20.04' - - steps: - - name: 'Checkout current revision' - uses: 'actions/checkout@v2' - - - name: 'Setup PHP' - uses: 'shivammathur/setup-php@v2' - with: - php-version: '8.1' - tools: 'composer' - extensions: 'mbstring, intl' - coverage: 'none' - - - name: 'Discover Composer cache directory' - id: 'cachedir' - run: 'echo "::set-output name=path::$(composer global config cache-dir)"' - - - name: 'Share Composer cache across runs' - uses: 'actions/cache@v2' - with: - path: '${{ steps.cachedir.outputs.path }}' - key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}" - restore-keys: | - composer-${{ github.job }}- - composer- - - - name: 'Install dependencies with Composer' - run: 'composer install --prefer-dist --no-interaction' - - - name: 'Run PHP CodeSniffer' - run: 'vendor/bin/phpcs -n' + uses: bedita/github-workflows/.github/workflows/php-cs.yml@v1 + with: + php_versions: '["8.1"]' stan: - name: 'Static code analyzer' - runs-on: 'ubuntu-20.04' - continue-on-error: true - - steps: - - name: 'Checkout current revision' - uses: 'actions/checkout@v2' - - - name: 'Setup PHP' - uses: 'shivammathur/setup-php@v2' - with: - php-version: '8.1' - tools: 'composer' - extensions: 'mbstring, intl' - coverage: 'none' - - - name: 'Discover Composer cache directory' - id: 'cachedir' - run: 'echo "::set-output name=path::$(composer global config cache-dir)"' - - - name: 'Share Composer cache across runs' - uses: 'actions/cache@v2' - with: - path: '${{ steps.cachedir.outputs.path }}' - key: "composer-${{ github.job }}-${{ hashFiles('**/composer.json') }}" - restore-keys: | - composer-${{ github.job }}- - composer- - - - name: 'Install dependencies with Composer' - run: 'composer install --prefer-dist --no-interaction' - - - name: 'Run PHP STAN' - run: 'vendor/bin/phpstan analyse --no-progress --error-format=github' + uses: bedita/github-workflows/.github/workflows/php-stan.yml@v1 + with: + php_versions: '["8.1"]' unit: name: 'Run unit tests' if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" - runs-on: 'ubuntu-20.04' + runs-on: 'ubuntu-latest' strategy: fail-fast: false @@ -147,7 +88,7 @@ jobs: unit-lowest: name: 'Run unit tests with lowest-matching dependencies versions' if: "!contains(github.event.commits[0].message, '[skip ci]') && !contains(github.event.commits[0].message, '[ci skip]')" - runs-on: 'ubuntu-20.04' + runs-on: 'ubuntu-latest' steps: - name: 'Checkout current revision' From 0518e5c653b1e5c64bb846b15f93041a6880bcb0 Mon Sep 17 00:00:00 2001 From: dante di domenico Date: Wed, 7 Sep 2022 12:14:06 +0200 Subject: [PATCH 2/3] fix: phpcs --- src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php | 10 ++++++++-- .../Authenticator/AlbAuthenticatorTest.php | 14 ++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php b/src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php index 6c5fe68..6d7a5d6 100644 --- a/src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php +++ b/src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php @@ -58,8 +58,14 @@ class AwsS3CloudFrontAdapter extends AwsS3V3Adapter * @param bool $streamReads Whether reads should be streamed. * @param \Aws\CloudFront\CloudFrontClient|null $cloudfrontClient CloudFront client instance, or `null`. */ - public function __construct(S3ClientInterface $client, string $bucket, string $prefix = '', array $options = [], $streamReads = true, ?CloudFrontClient $cloudfrontClient = null) - { + public function __construct( + S3ClientInterface $client, + string $bucket, + string $prefix = '', + array $options = [], + $streamReads = true, + ?CloudFrontClient $cloudfrontClient = null + ) { parent::__construct($client, $bucket, $prefix, null, null, $options, $streamReads); if (!empty($options['distributionId']) && $cloudfrontClient === null) { diff --git a/tests/TestCase/Authenticator/AlbAuthenticatorTest.php b/tests/TestCase/Authenticator/AlbAuthenticatorTest.php index 63eef4f..f1d925a 100644 --- a/tests/TestCase/Authenticator/AlbAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/AlbAuthenticatorTest.php @@ -93,9 +93,10 @@ protected function setUp(): void openssl_pkey_export($key, $privateKey); $keyInfo = openssl_pkey_get_details($key); assert($keyInfo !== false); - if (is_resource($key)) { - openssl_free_key($key); - } + // openssl_free_key is deprecated, no effect on php 8 @see https://www.php.net/manual/en/function.openssl-free-key.php + // if (is_resource($key)) { + // openssl_free_key($key); + // } $this->keyId = Text::uuid(); $this->privateKey = InMemory::plainText($privateKey); @@ -367,9 +368,10 @@ public function testAuthenticateInvalidSignature(): void ]); assert($key !== false); openssl_pkey_export($key, $privateKey); - if (is_resource($key)) { - openssl_free_key($key); - } + // openssl_free_key is deprecated, no effect on php 8 @see https://www.php.net/manual/en/function.openssl-free-key.php + // if (is_resource($key)) { + // openssl_free_key($key); + // } $privateKey = InMemory::plainText($privateKey); $token = (new Builder(new JoseEncoder(), ChainedFormatter::default())) From 52fb1d60ecf818dd61f4802a5b8ed5bc352bdcfd Mon Sep 17 00:00:00 2001 From: dante di domenico Date: Wed, 7 Sep 2022 12:31:57 +0200 Subject: [PATCH 3/3] Revert "fix: phpcs" This reverts commit 0518e5c653b1e5c64bb846b15f93041a6880bcb0. --- src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php | 10 ++-------- .../Authenticator/AlbAuthenticatorTest.php | 14 ++++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php b/src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php index 6d7a5d6..6c5fe68 100644 --- a/src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php +++ b/src/Filesystem/Adapter/AwsS3CloudFrontAdapter.php @@ -58,14 +58,8 @@ class AwsS3CloudFrontAdapter extends AwsS3V3Adapter * @param bool $streamReads Whether reads should be streamed. * @param \Aws\CloudFront\CloudFrontClient|null $cloudfrontClient CloudFront client instance, or `null`. */ - public function __construct( - S3ClientInterface $client, - string $bucket, - string $prefix = '', - array $options = [], - $streamReads = true, - ?CloudFrontClient $cloudfrontClient = null - ) { + public function __construct(S3ClientInterface $client, string $bucket, string $prefix = '', array $options = [], $streamReads = true, ?CloudFrontClient $cloudfrontClient = null) + { parent::__construct($client, $bucket, $prefix, null, null, $options, $streamReads); if (!empty($options['distributionId']) && $cloudfrontClient === null) { diff --git a/tests/TestCase/Authenticator/AlbAuthenticatorTest.php b/tests/TestCase/Authenticator/AlbAuthenticatorTest.php index f1d925a..63eef4f 100644 --- a/tests/TestCase/Authenticator/AlbAuthenticatorTest.php +++ b/tests/TestCase/Authenticator/AlbAuthenticatorTest.php @@ -93,10 +93,9 @@ protected function setUp(): void openssl_pkey_export($key, $privateKey); $keyInfo = openssl_pkey_get_details($key); assert($keyInfo !== false); - // openssl_free_key is deprecated, no effect on php 8 @see https://www.php.net/manual/en/function.openssl-free-key.php - // if (is_resource($key)) { - // openssl_free_key($key); - // } + if (is_resource($key)) { + openssl_free_key($key); + } $this->keyId = Text::uuid(); $this->privateKey = InMemory::plainText($privateKey); @@ -368,10 +367,9 @@ public function testAuthenticateInvalidSignature(): void ]); assert($key !== false); openssl_pkey_export($key, $privateKey); - // openssl_free_key is deprecated, no effect on php 8 @see https://www.php.net/manual/en/function.openssl-free-key.php - // if (is_resource($key)) { - // openssl_free_key($key); - // } + if (is_resource($key)) { + openssl_free_key($key); + } $privateKey = InMemory::plainText($privateKey); $token = (new Builder(new JoseEncoder(), ChainedFormatter::default()))