Skip to content

Commit

Permalink
Merge pull request #37 from Schmidt-DevOps/develop
Browse files Browse the repository at this point in the history
Fixed misc stuff
  • Loading branch information
rene-s authored Jul 31, 2023
2 parents 7236eff + 688f37b commit 60b3f25
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 89 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Unit tests
on: push
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['8.2']

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo # Add your extensions here.
coverage: xdebug

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

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Prepare tests
run: composer run-script tests_prepare

# - name: Run tests
# run: composer run-script tests_run
14 changes: 9 additions & 5 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@ variables:

before_script:
- apt-get update -yqq
- apt-get install git -yqq
- apt-get install git iputils-ping wget -yqq
- ping -c 1 1.1.1.1 || true
- ping -c 1 example.com || true
- ping -c 1 github.com || true
- ping -c 1 dl-cdn.alpinelinux.org || true
- curl -sS https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- curl --location --output /usr/local/bin/phpunit https://phar.phpunit.de/phpunit.phar
- chmod +x /usr/local/bin/phpunit /usr/local/bin/composer
- mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
- echo "memory_limit = -1" > /usr/local/etc/php/conf.d/test.ini

test:php-7.3:
test:php-8.0:
stage: test
image: php:7.3
image: php:8.0
script:
- bash ./bin/prepare_tests.sh && bash ./bin/run_tests.sh
tags:
- sdo-docker-runner

test:php-7.4:
test:php-8.1:
stage: test
image: php:7.4
image: php:8.1
script:
- bash ./bin/prepare_tests.sh && bash ./bin/run_tests.sh
tags:
Expand Down
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.0]
### [3.0.0] - 2021-MM-DD

- Supports PHP ~v8.0 only.

## [2.0.1] - 2020-10-06

This version will not be backwards compatible with Version 1.x.

Expand Down
41 changes: 22 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ This is a PHP package for accessing [Seafile Web API](https://www.seafile.com/).

No marketing skills whatsoever, but low rates, 20+ years of experience, and "german work attitude" -- whatever you associate with that.

Get in touch now: https://sdo.sh/DevOps/#contact
Get in touch now: https://sdo.sh/#contact

[![Build Status](https://travis-ci.org/Schmidt-DevOps/Seafile-PHP-SDK.svg?branch=develop)](https://travis-ci.org/Schmidt-DevOps/Seafile-PHP-SDK)
[![Test Coverage](https://codeclimate.com/github/rene-s/Seafile-PHP-SDK/badges/coverage.svg)](https://codeclimate.com/github/rene-s/Seafile-PHP-SDK/coverage)
[![Unit tests](https://github.com/Schmidt-DevOps/Seafile-PHP-SDK/actions/workflows/tests.yml/badge.svg)](https://github.com/Schmidt-DevOps/Seafile-PHP-SDK/actions/workflows/tests.yml)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## What is Seafile?
Expand Down Expand Up @@ -344,24 +343,24 @@ $client = new Client(
## Dependencies
- PHP >=7.3 64 bits
- Guzzle 6
- PHP >=8.0 64 bits
- Guzzle 7.2
## Seafile Web API Support Matrix
| Resource | Web API Version | Support grade |
| ---------------------- | --------------- | ------------- |
| Account | v2 | ★★★☆ |
| Avatar | v2.1 | ★★★★ |
| Resource | Web API Version | Support grade |
|------------------------|-----------------|-------------------------------------------------------|
| Account | v2 | ★★★☆ |
| Avatar | v2.1 | ★★★★ |
| Events | v2 | Yet to be done, [contact me](mailto:rene+_gth@sdo.sh) |
| File Share Link | v2.1 | ★★★☆ |
| Group | v2 | ★☆☆☆ |
| Library/Directory | v2 | ★★☆☆ |
| Library/File | v2 | ★★☆☆ |
| Library/Library | v2 | ★★☆☆ |
| Library/Multiple Files | v2 | ★★★★ |
| File Share Link | v2.1 | ★★★☆ |
| Group | v2 | ★☆☆☆ |
| Library/Directory | v2 | ★★☆☆ |
| Library/File | v2 | ★★☆☆ |
| Library/Library | v2 | ★★☆☆ |
| Library/Multiple Files | v2 | ★★★★ |
| Organization | v2 | Yet to be done, [contact me](mailto:rene+_gth@sdo.sh) |
| Starred Files | v2 | ★★★★ |
| Starred Files | v2 | ★★★★ |
## Seafile server compatibility
Expand All @@ -371,7 +370,11 @@ Tested with:
- ~~Seafile Server 5.1.3 for generic Linux/Debian Wheezy~~
- ~~Seafile Server 5.1.4 for generic Linux/Ubuntu Xenial~~
- ~~Seafile Server 6.0.3 for generic Linux/Ubuntu Xenial~~
- Seafile Server 7.1.4 for Ubuntu 20.04 LTS
- Seafile Server 7.x+ for Ubuntu 20.04 LTS
## Support
I'd be happy to implement new features for you at a competitive hourly rate. Get in touch now: https://sdo.sh/#contact

## Contributing

Expand All @@ -388,7 +391,7 @@ Please note that this package still is in its infancy. Only a part of the API ha
There are two types of tests:

1. Unit tests that test a code unit without external dependencies and no data manipulation. Please always provide at least unit tests when contributing.
1. Functional tests that run against a live server instance (=may have external dependencies) and also alter data. Disabled and thus skipped by default. Please refer to `/phpunit/php` in `phpunit.xml.dist` for information on how to enable functional tests.
2. Functional tests that run against a live server instance (=may have external dependencies) and also alter data. Disabled and thus skipped by default. Please refer to `/phpunit/php` in `phpunit.xml.dist` for information on how to enable functional tests.

## Links

Expand All @@ -400,4 +403,4 @@ There are two types of tests:

## License

[MIT](https://raw.githubusercontent.com/rene-s/seafile-php-sdk/master/LICENSE) © 2015-2020 Rene Schmidt DevOps UG (haftungsbeschränkt) & Co. KG
[MIT](https://raw.githubusercontent.com/rene-s/seafile-php-sdk/master/LICENSE) © 2015-2023 Rene Schmidt DevOps UG (haftungsbeschränkt) & Co. KG
1 change: 0 additions & 1 deletion bin/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ size=`stat --printf="%s" $file 2>/dev/null`

if [ ! -f $file ] || [ $size -eq 0 ]; then
wget $url -O $file

fi

if [ -f $file ]; then
Expand Down
25 changes: 14 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@
"encrypted"
],
"require": {
"php": ">=7.3",
"guzzlehttp/guzzle": "~6.0|~7.0",
"nabil1337/case-helper": "~0.1",
"php": ">=8.2",
"guzzlehttp/guzzle": "~7.7",
"marcusball/case-helper": "~0.2",
"ext-json": "*",
"sdo/bitmask": "^1.0"
"sdo/bitmask": "~1.0"
},
"require-dev": {
"monolog/monolog": "~1.17",
"phpunit/phpunit": "~8.0",
"phpunit/php-token-stream": "~3.0",
"sebastian/phpcpd": "~4.0",
"squizlabs/php_codesniffer": "~3.2",
"phpunit/php-timer": "~2.0",
"fzaninotto/faker": "^1.9"
"monolog/monolog": " ~2.9",
"phpunit/phpunit": "~9.6",
"sebastian/phpcpd": "~6.0",
"squizlabs/php_codesniffer": "~3.7",
"phpunit/php-timer": "~5.0",
"fzaninotto/faker": "~1.5"
},
"type": "library",
"autoload": {
Expand All @@ -47,5 +46,9 @@
"Seafile\\Client\\Tests\\Functional\\": "test/functional",
"Seafile\\Client\\Tests\\Unit\\": "test/unit"
}
},
"scripts": {
"tests_prepare": "./bin/prepare_tests.sh",
"tests_run": "./bin/run_tests.sh"
}
}
10 changes: 7 additions & 3 deletions src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Seafile\Client\Http;

use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\UriInterface;

Expand Down Expand Up @@ -42,8 +43,9 @@ public function __construct(array $config = [])

/**
* @param string|UriInterface $uri URI for request
* @param array $args Request args
* @param array $options
* @return ResponseInterface
* @throws GuzzleException
*/
public function get($uri, array $options = []): ResponseInterface
{
Expand All @@ -52,8 +54,9 @@ public function get($uri, array $options = []): ResponseInterface

/**
* @param string|UriInterface $uri URI for request
* @param array $args Request args
* @param array $options
* @return ResponseInterface
* @throws GuzzleException
*/
public function put($uri, array $options = []): ResponseInterface
{
Expand All @@ -62,8 +65,9 @@ public function put($uri, array $options = []): ResponseInterface

/**
* @param string|UriInterface $uri URI for request
* @param array $args Request args
* @param array $options
* @return ResponseInterface
* @throws GuzzleException
*/
public function delete($uri, array $options = []): ResponseInterface
{
Expand Down
40 changes: 20 additions & 20 deletions src/Resource/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ protected function urlEncodePath(string $path)
* @throws GuzzleException
*/
public function downloadFromDir(
LibraryType $library,
LibraryType $library,
DirectoryItem $item,
string $localFilePath,
string $dir,
int $reuse = 1
string $localFilePath,
string $dir,
int $reuse = 1
): ResponseInterface
{
if (is_readable($localFilePath)) {
Expand Down Expand Up @@ -184,8 +184,8 @@ public function getUploadUrl(LibraryType $library, bool $newFile = true, string
public function getMultiPartParams(
string $localFilePath,
string $dir,
bool $newFile = true,
$newFilename = false
bool $newFile = true,
$newFilename = false
): array
{
if ($newFilename === false) {
Expand Down Expand Up @@ -240,10 +240,10 @@ public function getMultiPartParams(
*/
public function upload(
LibraryType $library,
string $localFilePath,
string $dir = '/',
$newFilename = false,
bool $newFile = true
string $localFilePath,
string $dir = '/',
$newFilename = false,
bool $newFile = true
): ResponseInterface
{
if (!is_readable($localFilePath)) {
Expand Down Expand Up @@ -389,10 +389,10 @@ public function rename(LibraryType $library, DirectoryItem $dirItem, string $new
*/
public function copy(
LibraryType $srcLibrary,
string $srcFilePath,
string $srcFilePath,
LibraryType $dstLibrary,
string $dstDirectoryPath,
int $operation = self::OPERATION_COPY
string $dstDirectoryPath,
int $operation = self::OPERATION_COPY
): bool
{
// do not allow empty paths
Expand Down Expand Up @@ -453,9 +453,9 @@ public function copy(
*/
public function move(
LibraryType $srcLibrary,
string $srcFilePath,
string $srcFilePath,
LibraryType $dstLibrary,
string $dstDirectoryPath
string $dstDirectoryPath
): bool
{
return $this->copy($srcLibrary, $srcFilePath, $dstLibrary, $dstDirectoryPath, self::OPERATION_MOVE);
Expand All @@ -472,8 +472,8 @@ public function move(
* @throws GuzzleException
*/
public function getFileRevisionDownloadUrl(
LibraryType $library,
DirectoryItem $dirItem,
LibraryType $library,
DirectoryItem $dirItem,
FileHistoryItem $fileHistoryItem
)
{
Expand Down Expand Up @@ -501,10 +501,10 @@ public function getFileRevisionDownloadUrl(
* @throws GuzzleException
*/
public function downloadRevision(
LibraryType $library,
DirectoryItem $dirItem,
LibraryType $library,
DirectoryItem $dirItem,
FileHistoryItem $fileHistoryItem,
string $localFilePath
string $localFilePath
): ResponseInterface
{
$downloadUrl = $this->getFileRevisionDownloadUrl($library, $dirItem, $fileHistoryItem);
Expand Down
10 changes: 5 additions & 5 deletions src/Resource/Multi.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class Multi extends Resource
*/
public function move(
LibraryType $srcLibrary,
array $srcPaths,
array $srcPaths,
LibraryType $dstLibrary,
string $dstDirectoryPath
string $dstDirectoryPath
): bool
{
return $this->copy($srcLibrary, $srcPaths, $dstLibrary, $dstDirectoryPath, self::OPERATION_MOVE);
Expand All @@ -63,10 +63,10 @@ public function move(
*/
public function copy(
LibraryType $srcLibrary,
array $srcPaths,
array $srcPaths,
LibraryType $dstLibrary,
string $dstDirectoryPath,
int $operation = self::OPERATION_COPY
string $dstDirectoryPath,
int $operation = self::OPERATION_COPY
): bool
{
// do not allow empty paths
Expand Down
Loading

0 comments on commit 60b3f25

Please sign in to comment.