Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - support latest version, add typehint, add static checks, and add tests #53

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.php]
indent_size = 4
14 changes: 14 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
* text=auto eol=lf

*.md diff=markdown
*.php diff=php

/.github export-ignore
/tests export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
pint.json export-ignore
testbench.yaml export-ignore
100 changes: 100 additions & 0 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Testing

on:
push:
schedule:
- cron: '0 0 * * 1' # run tests on every week Monday

jobs:
static_analyze:
name: Static Analyze

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: xdebug

- name: Get composer cache directory
run: echo "COMPOSER_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_DIR }}
key: ${{ runner.os }}-composer-static-analyze-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-static-analyze-

- name: Install dependencies
run: composer update --no-progress --no-interaction

- name: Check runtime dependencies
run: composer check-platform-reqs

- name: Run composer validate
run: composer validate --strict

- name: Run composer normalize
run: composer normalize --dry-run

- name: Run static analysis
run: vendor/bin/phpstan --memory-limit=-1 --verbose

- name: Run coding style checker
run: vendor/bin/pint -v --test

- name: Run type coverage check
run: vendor/bin/pest --memory-limit=-1 --type-coverage --min=95

testing:
name: PHP ${{ matrix.php }}

runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
php: [ '8.3', '8.2' ]

services:
typesense:
image: typesense/typesense:0.25.2
ports:
- 8108:8108/tcp
volumes:
- typesense_data:/data
env:
TYPESENSE_DATA_DIR: /data
TYPESENSE_API_KEY: testing
TYPESENSE_ENABLE_CORS: true

steps:
- uses: actions/checkout@v4

- name: Setup PHP with PECL extension
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug

- name: Get composer cache directory
run: echo "COMPOSER_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ env.COMPOSER_DIR }}
key: ${{ runner.os }}-composer-php-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-php-${{ matrix.php }}-

- name: Install dependencies
run: composer update --no-progress --no-interaction

- name: Run tests
run: vendor/bin/pest --coverage --min=95
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
.idea
.tmp
/composer.lock
vendor
/.fleet
/.idea
/.vscode
/coverage
/vendor
.DS_Store
.phpunit.result.cache
clover.xml
composer.phar
composer.lock
Thumbs.db
66 changes: 39 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "typesense/typesense-php",
"description": "PHP client for Typesense Search Server: https://github.com/typesense/typesense",
"type": "library",
"homepage": "https://github.com/typesense/typesense-php",
"license": "Apache-2.0",
"type": "library",
"authors": [
{
"name": "Typesense",
Expand All @@ -16,48 +15,61 @@
"email": "[email protected]",
"homepage": "https://www.devloops.net",
"role": "Developer"
},
{
"name": "bepsvpt",
"email": "[email protected]"
}
],
"homepage": "https://github.com/typesense/typesense-php",
"support": {
"docs": "https://typesense.org/api",
"issues": "https://github.com/typesense/typesense-php/issues",
"source": "https://github.com/typesense/typesense-php",
"issues": "https://github.com/typesense/typesense-php/issues"
"docs": "https://typesense.org/docs/api"
},
"require": {
"php": "^8.2",
"php-http/discovery": "^1.19",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "^1.0",
"psr/http-factory": "^1.0",
"psr/http-factory-implementation": "^1.0"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
"guzzlehttp/guzzle": "^7.8",
"laravel/pint": "^1.14",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-faker": "^2.0",
"pestphp/pest-plugin-type-coverage": "^2.8",
"phpstan/phpstan": "^1.10",
"symfony/http-client": "^7.0"
},
"minimum-stability": "stable",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Typesense\\": "src/"
}
},
"require": {
"php": ">=7.4",
"ext-json": "*",
"monolog/monolog": "^2.1 || ^3.0 || ^3.3",
"nyholm/psr7": "^1.3",
"php-http/client-common": "^1.0 || ^2.3",
"php-http/discovery": "^1.0",
"php-http/httplug": "^1.0 || ^2.2",
"psr/http-client-implementation": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"psr/http-factory": "^1.0"
},
"require-dev": {
"squizlabs/php_codesniffer": "3.*",
"symfony/http-client": "^5.2"
"autoload-dev": {
"psr-4": {
"Typesense\\Tests\\": "tests/"
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
"allow-plugins": {
"ergebnis/composer-normalize": true,
"pestphp/pest-plugin": true,
"php-http/discovery": false
},
"optimize-autoloader": true,
"sort-packages": true
},
"scripts": {
"typesenseServer": [
"typesense-server": [
"Composer\\Config::disableProcessTimeout",
"docker-compose up"
],
"lint": "phpcs -v",
"lint:fix": "phpcbf"
"docker-compose pull && docker-compose up"
]
}
}
25 changes: 14 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
version: '3.5'
version: "3"

services:
typesense:
image: typesense/typesense:0.21.0.rc20
environment:
TYPESENSE_DATA_DIR: /data
TYPESENSE_API_KEY: xyz
volumes:
- /tmp/typesense-server-data:/data
ports:
- 8108:8108
restart: "no"
typesense:
image: typesense/typesense:0.25.2
container_name: typesense-testing
restart: "on-failure"
ports:
- "8108:8108/tcp"
environment:
TYPESENSE_DATA_DIR: "/var/tmp"
TYPESENSE_API_KEY: "testing"
TYPESENSE_ENABLE_CORS: "true"
TYPESENSE_PEERING_ADDRESS: "127.0.0.1"
TYPESENSE_PEERING_PORT: "12345"
TYPESENSE_PEERING_SUBNET: "127.0.0.1/24"
14 changes: 0 additions & 14 deletions examples/README.md

This file was deleted.

Loading