Skip to content

Commit

Permalink
Merge pull request #26 from owncloud/drone-ci
Browse files Browse the repository at this point in the history
Drone CI
  • Loading branch information
DeepDiver1975 committed Jun 15, 2023
2 parents dfa7c24 + a95c5a0 commit 23452d1
Show file tree
Hide file tree
Showing 11 changed files with 1,064 additions and 131 deletions.
842 changes: 842 additions & 0 deletions .drone.star

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
./idea
/build/
/vendor/
/vendor/
composer.lock
vendor-bin/**/vendor
vendor-bin/**/composer.lock
.php-cs-fixer.cache
.phpunit.result.cache

# drone CI is in .drone.star, do not let someone accidentally commit a local .drone.yml
.drone.yml
13 changes: 13 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

$config = new OC\CodingStandard\Config();

$config
->setUsingCache(true)
->getFinder()
->in(__DIR__)
->exclude('build')
->exclude('vendor-bin')
->exclude('vendor');

return $config;
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

92 changes: 92 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
SHELL := /bin/bash

COMPOSER_BIN := $(shell command -v composer 2> /dev/null)

# bin file definitions
PHPUNIT=php -d zend.enable_gc=0 vendor/bin/phpunit
PHPUNITDBG=phpdbg -qrr -d memory_limit=4096M -d zend.enable_gc=0 vendor/bin/phpunit
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/owncloud-codestyle/vendor/bin/php-cs-fixer
PHAN=php -d zend.enable_gc=0 vendor-bin/phan/vendor/bin/phan
PHPSTAN=php -d zend.enable_gc=0 vendor-bin/phpstan/vendor/bin/phpstan

.PHONY: clean
clean: clean-deps

# Installs and updates the composer dependencies.
.PHONY: composer
composer:
composer install --prefer-dist
composer update --prefer-dist

##------------
## Tests
##------------

.PHONY: test-php-unit
test-php-unit: ## Run php unit tests
test-php-unit: vendor/bin/phpunit
$(PHPUNIT) --configuration ./phpunit.xml --testsuite TarStreamer

.PHONY: test-php-unit-dbg
test-php-unit-dbg: ## Run php unit tests using phpdbg
test-php-unit-dbg: vendor/bin/phpunit
$(PHPUNITDBG) --configuration ./phpunit.xml --testsuite TarStreamer

.PHONY: test-php-style
test-php-style: ## Run php-cs-fixer and check owncloud code-style
test-php-style: vendor-bin/owncloud-codestyle/vendor
$(PHP_CS_FIXER) fix -v --diff --allow-risky yes --dry-run

.PHONY: test-php-style-fix
test-php-style-fix: ## Run php-cs-fixer and fix code style issues
test-php-style-fix: vendor-bin/owncloud-codestyle/vendor
$(PHP_CS_FIXER) fix -v --diff --allow-risky yes

.PHONY: test-php-phan
test-php-phan: ## Run phan
test-php-phan: vendor-bin/phan/vendor
$(PHAN) --config-file .phan/config.php --require-config-exists

.PHONY: test-php-phpstan
test-php-phpstan: ## Run phpstan
test-php-phpstan: vendor-bin/phpstan/vendor
$(PHPSTAN) analyse --memory-limit=4G --configuration=./phpstan.neon --no-progress --level=5 appinfo lib

.PHONY: clean-deps
clean-deps:
rm -rf ./vendor
rm -Rf vendor-bin/**/vendor vendor-bin/**/composer.lock

#
# Dependency management
#--------------------------------------

composer.lock: composer.json
@echo composer.lock is not up to date.

vendor: composer.lock
composer install --no-dev

vendor/bin/phpunit: composer.lock
composer install

vendor/bamarni/composer-bin-plugin: composer.lock
composer install

vendor-bin/owncloud-codestyle/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/owncloud-codestyle/composer.lock
composer bin owncloud-codestyle install --no-progress

vendor-bin/owncloud-codestyle/composer.lock: vendor-bin/owncloud-codestyle/composer.json
@echo owncloud-codestyle composer.lock is not up to date.

vendor-bin/phan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phan/composer.lock
composer bin phan install --no-progress

vendor-bin/phan/composer.lock: vendor-bin/phan/composer.json
@echo phan composer.lock is not up to date.

vendor-bin/phpstan/vendor: vendor/bamarni/composer-bin-plugin vendor-bin/phpstan/composer.lock
composer bin phpstan install --no-progress

vendor-bin/phpstan/composer.lock: vendor-bin/phpstan/composer.json
@echo phpstan composer.lock is not up to date.
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"php": ">=7.1"
},
"config" : {
"platform": {
"php": "7.1"
"allow-plugins": {
"bamarni/composer-bin-plugin": true
}
},
"autoload": {
Expand All @@ -30,8 +30,14 @@
]
},
"require-dev": {
"phpunit/phpunit": "^7.5",
"phpunit/phpunit": "^7.5|^8.5|^9.6",
"pear/pear-core-minimal": "v1.10.10",
"pear/archive_tar": "~1.4"
"pear/archive_tar": "~1.4",
"bamarni/composer-bin-plugin": "^1.5"
},
"extra": {
"bamarni-bin": {
"bin-links": false
}
}
}
4 changes: 2 additions & 2 deletions tests/phpunit.xml → phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php">
<phpunit bootstrap="tests/bootstrap.php">
<testsuite name='TarStreamer'>
<directory suffix='.php'>./</directory>
<directory suffix='.php'>./tests</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
Expand Down
38 changes: 19 additions & 19 deletions src/TarHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,32 +37,32 @@ class TarHeader {

private $reserved = '';

public function setName($name){
public function setName($name) {
$this->name = $name;
return $this;
}

public function setSize($size){
public function setSize($size) {
$this->size = $size;
return $this;
}

public function setMtime($mtime){
public function setMtime($mtime) {
$this->mtime = $mtime;
return $this;
}

public function setTypeflag($typeflag){
public function setTypeflag($typeflag) {
$this->typeflag = $typeflag;
return $this;
}

public function setPrefix($prefix){
public function setPrefix($prefix) {
$this->prefix = $prefix;
return $this;
}

public function getHeader(){
public function getHeader() {
$fields = [
['a100', substr($this->name, 0, 100)],
['a8', str_pad($this->mode, 7, '0', STR_PAD_LEFT)],
Expand All @@ -89,11 +89,11 @@ public function getHeader(){

// Compute header checksum
$checksum = str_pad(decoct($this->computeUnsignedChecksum($header)), 6, "0", STR_PAD_LEFT);
for ($i = 0; $i < 6; $i++){
for ($i = 0; $i < 6; $i++) {
$header[(148 + $i)] = substr($checksum, $i, 1);
}
$header[154] = chr(0);
$header[155] = chr(32);
$header[154] = \chr(0);
$header[155] = \chr(32);

return $header;
}
Expand All @@ -104,11 +104,11 @@ public function getHeader(){
* @param array $fields key being the format string and value being the data to pack
* @return string binary packed data returned from pack()
*/
protected function packFields($fields){
list ($fmt, $args) = ['', []];
protected function packFields($fields) {
list($fmt, $args) = ['', []];

// populate format string and argument list
foreach ($fields as $field){
foreach ($fields as $field) {
$fmt .= $field[0];
$args[] = $field[1];
}
Expand All @@ -117,7 +117,7 @@ protected function packFields($fields){
array_unshift($args, $fmt);

// build output string from header and compressed data
return call_user_func_array('pack', $args);
return \call_user_func_array('pack', $args);
}

/**
Expand All @@ -126,15 +126,15 @@ protected function packFields($fields){
* @param string $header
* @return string unsigned checksum
*/
protected function computeUnsignedChecksum($header){
protected function computeUnsignedChecksum($header) {
$unsignedChecksum = 0;
for ($i = 0; $i < 512; $i++){
$unsignedChecksum += ord($header[$i]);
for ($i = 0; $i < 512; $i++) {
$unsignedChecksum += \ord($header[$i]);
}
for ($i = 0; $i < 8; $i++){
$unsignedChecksum -= ord($header[148 + $i]);
for ($i = 0; $i < 8; $i++) {
$unsignedChecksum -= \ord($header[148 + $i]);
}
$unsignedChecksum += ord(" ") * 8;
$unsignedChecksum += \ord(" ") * 8;

return $unsignedChecksum;
}
Expand Down

0 comments on commit 23452d1

Please sign in to comment.