Github actions add

This commit is contained in:
2024-05-22 17:27:20 +09:00
parent d86ad8c051
commit 04aa9fa019
4 changed files with 42 additions and 2 deletions

35
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,35 @@
name: CI
run-name: ${{ github.actor}} runs CI
on: [push]
jobs:
phpstan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: php-actions/composer@v6
env:
COMPOSER_ROOT_VERSION: dev-master
- name: PHPStan Static Analysis
uses: php-actions/phpstan@v3
with:
path: src/
# We need to use phpunit from the self install to get the class paths
- name: PHPunit Tests Prepare
env:
AWS_GIFT_CARD_ENDPOINT: "${{ secrets.AWS_GIFT_CARD_ENDPOINT }}"
AWS_GIFT_CARD_KEY: "${{ secrets.AWS_GIFT_CARD_KEY }}"
AWS_GIFT_CARD_SECRET: "${{ secrets.AWS_GIFT_CARD_SECRET }}"
AWS_GIFT_CARD_PARTNER_ID: "${{ secrets.AWS_GIFT_CARD_PARTNER_ID }}"
AWS_GIFT_CARD_CURRENCY: "${{ secrets.AWS_GIFT_CARD_CURRENCY }}"
run: |
echo "AWS_GIFT_CARD_ENDPOINT=${AWS_GIFT_CARD_ENDPOINT}" > test/.env;
echo "AWS_GIFT_CARD_KEY=${AWS_GIFT_CARD_KEY}" >> test/.env;
echo "AWS_GIFT_CARD_SECRET=${AWS_GIFT_CARD_SECRET}" >> test/.env;
echo "AWS_GIFT_CARD_PARTNER_ID=${AWS_GIFT_CARD_PARTNER_ID}" >> test/.env;
echo "AWS_GIFT_CARD_CURRENCY=${AWS_GIFT_CARD_CURRENCY}" >> test/.env;
echo "AWS_DEBUG=1" >> test/.env;
- name: PHPunit Tests
run: |
vendor/bin/phpunit

View File

@@ -4,7 +4,7 @@ parameters:
tmpDir: /tmp/phpstan-codeblocks-amazon-incentives
level: 8
paths:
- %currentWorkingDirectory%
- %currentWorkingDirectory%/src
excludePaths:
# ignore composer
- vendor

View File

@@ -6,4 +6,9 @@
<extensions>
<extension class="test\phpUnit\Hook\BypassFinalHook" file="test/phpUnit/Hook/BypassFinalHook.php" />
</extensions>
<testsuites>
<testsuite name="unit">
<directory>test/phpUnit/</directory>
</testsuite>
</testsuites>
</phpunit>

View File

@@ -109,7 +109,7 @@ final class AmazonIncentivesTest extends TestCase
try {
// set expected throw error
$result = $client->request($url, [], '');
print "R: " . $result . "\n";
$this->assertTrue(true, 'Successful client request');
} catch (AmazonIncentives\Exceptions\AmazonErrors $e) {
$curl_error = AmazonIncentives\Exceptions\AmazonErrors::decodeExceptionMessage($e->getMessage());
// print "E-B: " . print_r($curl_error, true) . "\n";