Skip to content

Commit

Permalink
github ci
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed Mar 2, 2021
1 parent 58f6df3 commit e4b0bcd
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 3 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
on: [push, pull_request]

name: CI

jobs:
php-cs-fixer:
name: PHP-CS-Fixer
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: apcu
- name: PHP-CS-Fixer
uses: OskarStark/[email protected]
with:
args: --diff --dry-run --allow-risky yes --stop-on-violation --using-cache=no --path-mode=intersection

phpstan:
name: PHPStan Static Analysis
runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: apcu, smbclient
- name: Composer
run: composer install
- env:
BACKEND: smbclient
run: php ./vendor/bin/phpstan analyse --level 1 src

phpunit:
runs-on: ubuntu-20.04
name: Unit tests

services:
samba:
image: dperson/samba
env:
USER: "test;test"
SHARE: "test;/tmp;yes;no;yes;all;none"
ports:
- 139:139
- 445:445

steps:
- name: Install packages
run: |
sudo apt-get install smbclient
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
extensions: apcu, smbclient
- name: Composer
run: composer install
- name: Config
run: |
cat tests/config.json
echo '{"host": "localhost","user": "test","password": "test","share": "test","root": ""}' > tests/config.json
cat tests/config.json
- name: PHPUnit Tests
env:
BACKEND: smbclient
run: php ./vendor/bin/phpunit tests
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
},
"require-dev": {
"phpunit/phpunit": "^9.3.8",
"friendsofphp/php-cs-fixer": "^2.16"
"friendsofphp/php-cs-fixer": "^2.16",
"phpstan/phpstan": "^0.12.57"
},
"autoload" : {
"psr-4": {
Expand Down
50 changes: 50 additions & 0 deletions src/ProtocolLevel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Robin Appelman <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace Icewind\SMB;


class ProtocolLevel {
/** @var string */
private $level;

private function __construct(string $level) {
$this->level = $level;
}

public function getLevel(): string {
return $this->level;
}

public static function NT1(): self {
return new ProtocolLevel("NT1");
}

public static function SMB2(): self {
return new ProtocolLevel("SMB2");
}

public static function SMB3(): self {
return new ProtocolLevel("SMB3");
}
}
2 changes: 1 addition & 1 deletion src/Wrapped/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function read(callable $callback = null) {
break;
}
} else {
$output[] .= $line;
$output[] = $line;
}
$line = $this->readLine();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Wrapped/Share.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ public function write($target) {

// use a close callback to ensure the upload is finished before continuing
// this also serves as a way to keep the connection in scope
return CallbackWrapper::wrap($fh, null, null, function () use ($connection, $target) {
return CallbackWrapper::wrap($fh, null, null, function () use ($connection) {
$connection->close(false); // dont terminate, give the upload some time
});
}
Expand Down

0 comments on commit e4b0bcd

Please sign in to comment.