From 83cd6fc0c04d5dd175aafca1476b7a38d15433c4 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 6 Feb 2022 14:32:07 -0800 Subject: [PATCH 1/2] introduce github actions --- .github/workflows/psalm.yml | 33 ++++++++++++++++++++++++++++ .github/workflows/run-tests.yml | 38 +++++++++++++++++++++++++++++++++ .gitignore | 2 +- composer.json | 5 +++-- phpunit.xml.dist | 24 +++++++++++++++++++++ psalm.xml => psalm.xml.dist | 0 src/Offers/OffersListDto.php | 4 ++-- 7 files changed, 101 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/psalm.yml create mode 100644 .github/workflows/run-tests.yml create mode 100644 phpunit.xml.dist rename psalm.xml => psalm.xml.dist (100%) diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml new file mode 100644 index 0000000..f40adfc --- /dev/null +++ b/.github/workflows/psalm.yml @@ -0,0 +1,33 @@ +name: Psalm + +on: + push: + paths: + - '**.php' + - 'psalm.xml.dist' + +jobs: + psalm: + name: psalm + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + extensions: json, curl + coverage: none + + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + + - name: Run composer install + run: composer install -n --prefer-dist + + - name: Run psalm + run: ./vendor/bin/psalm --output-format=github diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..c3278d5 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,38 @@ +name: run-tests + +on: + push: + pull_request: + schedule: + - cron: "0 0 * * *" + +jobs: + test: + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + timeout-minutes: 15 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + php: ["7.4", "8.0", "8.1"] + dependency-version: ["prefer-lowest", "prefer-stable"] + os: ["ubuntu-latest", "windows-latest"] + + name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: json + coverage: none + + - name: Install dependencies + run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index d769eb5..dddbc6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ vendor -.phpunit.result.cache +.phpunit.cache composer.lock diff --git a/composer.json b/composer.json index 11b3173..7670e2e 100644 --- a/composer.json +++ b/composer.json @@ -4,11 +4,12 @@ "type": "library", "keywords": [], "require": { - "php": ">=7.4", + "php": "^7.4 || ^8.0", "ext-json": "*", "psr/http-factory": "^1.0", "psr/http-client": "^1.0", - "guzzlehttp/guzzle": "^6.0 || ^7.0" + "guzzlehttp/guzzle": "^6.5.2 || ^7.0", + "guzzlehttp/psr7": "^1.7.0" }, "require-dev": { "http-interop/http-factory-guzzle": "^1.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..8d3e365 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + + tests + + + + + + src + + + diff --git a/psalm.xml b/psalm.xml.dist similarity index 100% rename from psalm.xml rename to psalm.xml.dist diff --git a/src/Offers/OffersListDto.php b/src/Offers/OffersListDto.php index 6271462..0879229 100644 --- a/src/Offers/OffersListDto.php +++ b/src/Offers/OffersListDto.php @@ -36,7 +36,7 @@ class OffersListDto extends BaseOfferDto protected int $noticePercentOvercap; protected float $cr; protected float $epc; - protected ?string $notes; + protected string $notes; protected string $allowedIp; protected string $disallowedIp; protected string $hashPassword; @@ -86,7 +86,7 @@ public function __construct(array $attributes) $this->noticePercentOvercap = $attributes['notice_percent_overcap']; $this->cr = $attributes['cr']; $this->epc = $attributes['epc']; - $this->notes = $attributes['notes']; + $this->notes = $attributes['notes'] ?? ''; $this->allowedIp = $attributes['allowed_ip']; $this->disallowedIp = $attributes['disallowed_ip']; $this->hashPassword = $attributes['hash_password']; From b4d8cb4c6342d7bb52e83e05f3ae6def652ee71e Mon Sep 17 00:00:00 2001 From: Ryan Date: Sun, 6 Feb 2022 15:41:12 -0800 Subject: [PATCH 2/2] WIP --- .github/workflows/psalm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index f40adfc..051dfdc 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -17,7 +17,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: '7.4' - extensions: json, curl + extensions: json coverage: none - name: Cache composer dependencies