Skip to content

Commit

Permalink
GitHub pipeline, PHP 8.4 support (#25)
Browse files Browse the repository at this point in the history
* #17 - fix getting rates for day before if there are gaps in table

* #24 - updates preparing for 7.x support drop

* #24 - ci updates; remove circleci

* #24 - update test pipeline

* #24 - update ref commit to run

* #24 - added coverage

* #24 - moved validation of composer.json before adjustments

* #24 - removed validation of composer.json

* #24 - workflow split based on php versions

* #24 - moved caching before update

* #24 - testing php version on pipeline

* #24 - testing php version on pipeline

* #24 - testing php version on pipeline

* #24 - new adjust system for older php versions; coverage retrieval script

* #24 - remove php 8.1 from GH workflow

* #24 - test pipeline status send

* #24 - test pipeline status send

* #24 - test pipeline status send

* #24 - test pipeline status send

* #24 - test pipeline status send

* #24 - split test and coverage workflows

* #24 - split test and coverage workflows

* #24 - updated php-version variable

* #24 - updated php-version variable

* #24 - moved the php-version variable to env

* #24 - added delta coverage from main branch

* #24 - downgrade PHP version to run coverage

* #24 - ignore test result on main branch for coverage purposes

* #24 - preserve get-coverage.php scripts

* #24 - applied cs-fixer fixes

* #24 - added cs-fixer workflow

* #24 - added cs-fixer workflow

* #24 - added PHPStan workflow

* #24 - added Deptrac workflow

* #24 - added cs-fix composer script

* #24 - added deptrac, updated some array type annotations

* #24 - fix after rebasing master

* #24 - revert the change `new` to `create` as it would cause too much BC
  • Loading branch information
maciej-sz authored Feb 2, 2025
1 parent a23a467 commit e23c6fe
Show file tree
Hide file tree
Showing 72 changed files with 3,481 additions and 2,792 deletions.
56 changes: 0 additions & 56 deletions .circleci/config.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PHP CS Fixer

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "**" ]

env:
PHP_VERSION: '8.3'

jobs:
cs-fixer:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mbstring, xml, json
tools: composer:v2

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-8.3-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.PHP_VERSION }}-
- name: Run PHP CS Fixer
run: |
vendor/bin/php-cs-fixer check --config=./.php-cs-fixer.dist.php --diff --allow-risky=yes
40 changes: 40 additions & 0 deletions .github/workflows/deptrac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Deptrac

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "**" ]

env:
PHP_VERSION: '8.3'

jobs:
deptrac:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mbstring, xml, json
tools: composer:v2

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-8.3-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.PHP_VERSION }}-
- name: Run Deptrac
run: |
vendor/bin/deptrac
44 changes: 44 additions & 0 deletions .github/workflows/php-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PHP Tests

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "**" ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4']

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, xml, json, xdebug, curl
coverage: pcov
tools: composer:v2

- name: Adjust composer dependencies for older PHP versions
run: php scripts/adjust-deps-for-older-php-versions.php

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Run all test suites
run: composer run-script test-all
40 changes: 40 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: PHPStan

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "**" ]

env:
PHP_VERSION: '8.3'

jobs:
phpstan:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mbstring, xml, json
tools: composer:v2

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-8.3-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.PHP_VERSION }}-
- name: Run PHPStan
run: |
vendor/bin/phpstan
98 changes: 98 additions & 0 deletions .github/workflows/pr-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: PR Test Coverage

on:
pull_request:
branches: [ "**" ]

env:
PHP_VERSION: '8.3'

jobs:
check-coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Indicate pending code coverage check
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
-d '{
"state": "pending",
"context": "Test Coverage",
"description": "Coverage: ?%",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}
extensions: mbstring, xml, json, xdebug, curl
coverage: pcov
tools: composer:v2

- name: Cache Composer packages
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ env.PHP_VERSION }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ env.PHP_VERSION }}-
- name: Run test suites with coverage on PR branch
run: |
cp scripts/get-coverage.php var/coverage/
php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-text --coverage-clover=var/coverage/clover-pr.xml
- name: Checkout main branch
if: success()
run: |
git fetch origin master
git checkout master
- name: Run test suites with coverage on main branch. Ignore test result for the coverage purpose.
if: success()
run: php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-text --coverage-clover=var/coverage/clover-main.xml || true

- name: Extract coverage
if: success()
run: |
COVERAGE_PR=$(php var/coverage/get-coverage.php var/coverage/clover-pr.xml)
COVERAGE_MAIN=$(php var/coverage/get-coverage.php var/coverage/clover-main.xml)
DIFF=$(echo "$COVERAGE_PR - $COVERAGE_MAIN" | bc)
DIFF_DISPLAY=$DIFF
if [ $(echo "$DIFF > 0" | bc) -eq 1 ]; then
DIFF_DISPLAY="+$DIFF"
fi
if [ $(echo "$DIFF >= 0" | bc) -eq 1 ]; then
STATE="success"
EMOJI="✅"
else
STATE="failure"
EMOJI="❌"
fi
DESCRIPTION="Coverage: $COVERAGE_PR%. Change from main branch: $DIFF_DISPLAY% $EMOJI"
echo "COVERAGE_DESCRIPTION=${DESCRIPTION}" >> $GITHUB_ENV
echo "COVERAGE_STATE=${STATE}" >> $GITHUB_ENV
- name: Update GitHub status with code coverage
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
-d '{
"state": "${{ env.COVERAGE_STATE }}",
"context": "Test Coverage",
"description": "${{ env.COVERAGE_DESCRIPTION }}",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vendor/
var/
!var/coverage/.gitkeep
.idea
tests/php-unit/reports/
.phpunit.result.cache
Expand Down
24 changes: 13 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,35 @@
}
},
"require": {
"php": ">=7.2||>=8.0",
"php": ">=8.1",
"ext-json": "*"
},
"require-dev": {
"guzzlehttp/guzzle": "^6.3",
"guzzlehttp/guzzle": "^7.9",
"phpunit/phpunit": "^9.6",
"qossmic/deptrac-shim": "^1.0",
"qossmic/deptrac": "^2.0",
"friendsofphp/php-cs-fixer": "^3.16",
"phpstan/phpstan": "^1.10",
"symfony/http-client": "^6.2",
"donatj/mock-webserver": "^2.6",
"symfony/cache": "^6.2",
"cache/integration-tests": "dev-master"
"symfony/http-client": "^7.2",
"symfony/cache": "^7.2"
},
"suggest": {
"psr/cache": "Allows local cache",
"symfony/http-foundation": "Symfony HTTP Transport layer"
"symfony/http-client": "Symfony HTTP Transport layer"
},
"scripts": {
"test": "vendor/bin/phpunit -vv --testsuite unit,functional,integration",
"test-all": "vendor/bin/phpunit -vv --testsuite unit,functional,integration,e2e",
"test-coverage": "php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-html var/coverage/html-report -vv --testsuite unit,functional,integration",
"cs-check": "vendor/bin/php-cs-fixer --config=./.php-cs-fixer.dist.php fix --dry-run --diff --allow-risky=yes",
"phpstan-analyse": "vendor/bin/phpstan",
"test-coverage": "php -d xdebug.mode=coverage vendor/bin/phpunit --coverage-html var/coverage/html-report -vv --testsuite unit,functional,integration,e2e",
"cs-check": "vendor/bin/php-cs-fixer check --config=./.php-cs-fixer.dist.php --diff --allow-risky=yes",
"cs-fix": "vendor/bin/php-cs-fixer fix --config=./.php-cs-fixer.dist.php --diff --allow-risky=yes",
"phpstan": "vendor/bin/phpstan",
"deptrac": "vendor/bin/deptrac",
"analyse": [
"@cs-check",
"@phpstan-analyse"
"@phpstan",
"@deptrac"
],
"pre-commit-checks": [
"@analyse",
Expand Down
Loading

0 comments on commit e23c6fe

Please sign in to comment.