Skip to content

Commit

Permalink
Enhance use of Makefile (#155)
Browse files Browse the repository at this point in the history
* Enhance use of Makefile

* use Makefile in TravisCI, so that the same scripts are used on the developers machine and during the CI pipeline
* move test scripts to Makefile, so they can be executed in parallel for a faster test-result
* add "clean" target to remove generated files

* Make composer binaries available in PATH and test examples
  • Loading branch information
markuspoerschke authored Apr 22, 2020
1 parent ed1afe1 commit 21ecfaf
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 285 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ indent_style = space
indent_size = 4
charset = utf-8

[makefile]
[Makefile]
indent_style = tab

[*.yml]
Expand Down
68 changes: 0 additions & 68 deletions .github/workflows/ci.yml

This file was deleted.

11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
language: php

php:
- '7.4'

script:
- export PHPUNIT_FLAGS="--coverage-clover=coverage.xml"
- make -j -O test

after_success:
- bash <(curl -s https://codecov.io/bash) || true
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This project uses the [PHP Coding Standards Fixer](http://cs.sensiolabs.org/).
To fix or to check the code stlye download the tool and execute it on your command line:

```
make fix-code-style
make fix
```

## Documentation
Expand Down
75 changes: 75 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
PATH := $(PATH):$(CURDIR)/vendor/bin

.PHONY: test
test: test-validate-composer test-code-style test-psalm test-phpunit test-examples test-composer-normalize

.PHONY: test-code-style
test-code-style: dependencies
php-cs-fixer fix --dry-run --diff

.PHONY: test-psalm
test-psalm: dependencies
psalm -m --no-progress

.PHONY: test-phpunit
test-phpunit: dependencies
phpunit ${PHPUNIT_FLAGS}

.PHONY: test-examples
EXAMPLE_FILES := $(wildcard examples/*.php)
test-examples: $(EXAMPLE_FILES)

examples/example*.php: dependencies
php $@ > /dev/null

.PHONY: test-validate-composer
test-validate-composer:
composer validate

.PHONY: test-composer-normalize
test-composer-normalize: dependencies
test-composer-normalize:
composer normalize --dry-run --diff

.PHONY: dependencies
dependencies:
composer install --no-interaction

.PHONY: fix
fix: fix-code-style fix-composer

.PHONY: fix-code-style
fix-code-style: dependencies
fix-code-style:
php-cs-fixer -- fix

.PHONY: fix-composer
fix-composer: dependencies
fix-composer:
composer normalize --no-update-lock

.PHONY: docs
docs: docs-dependencies docs-frontend-build
php couscous.phar generate

.PHONY: docs-dependencies
docs-dependencies:
if [ ! -f couscous.phar ]; then php -r "copy('https://github.com/CouscousPHP/Couscous/releases/download/1.7.3/couscous.phar', 'couscous.phar');"; fi

.PHONY: docs-preview
docs-preview: docs-dependencies docs-frontend-build
php couscous.phar preview

.PHONY: docs-frontend-dependencies
docs-frontend-dependencies:
cd website && yarn

.PHONY: docs-frontend-build
docs-frontend-build: docs-frontend-dependencies
cd website && yarn build

.PHONY: clean
clean:
rm -rf vendor composer.lock .couscous website/node_modules website/template/static couscous.phar
50 changes: 20 additions & 30 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
{
"name": "eluceo/ical",
"description": "The eluceo/iCal package offers an abstraction layer for creating iCalendars. You can easily create iCal files by using PHP objects instead of typing your *.ics file by hand. The output will follow RFC 5545 as best as possible.",
"license": "MIT",
"keywords": [
"ical",
"php calendar",
"icalendar",
"ics",
"calendar"
],
"homepage": "https://github.com/markuspoerschke/iCal",
"license": "MIT",
"authors": [
{
"name": "Markus Poerschke",
"email": "[email protected]",
"role": "Developer"
}
],
"keywords": [
"ical",
"php calendar",
"icalendar",
"ics",
"calendar"
],
"support": {
"issues": "https://github.com/markuspoerschke/iCal/issues",
"source": "https://github.com/markuspoerschke/iCal"
"require": {
"php": ">=7.4",
"ext-mbstring": "*"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.2",
"friendsofphp/php-cs-fixer": "^2.16",
"phpunit/phpunit": "^8",
"vimeo/psalm": "^3.7"
},
"autoload": {
"psr-4": {
Expand All @@ -31,24 +37,8 @@
"Eluceo\\iCal\\": "tests/"
}
},
"require": {
"php": ">=7.4",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^8",
"vimeo/psalm": "^3.7",
"friendsofphp/php-cs-fixer": "^2.16"
},
"scripts": {
"test": [
"@test:code-style",
"@test:psalm",
"@test:phpunit"
],
"test:code-style": "php-cs-fixer fix --dry-run --diff",
"test:psalm": "psalm",
"test:phpunit": "phpunit",
"fix:code-style": "php-cs-fixer fix"
"support": {
"issues": "https://github.com/markuspoerschke/iCal/issues",
"source": "https://github.com/markuspoerschke/iCal"
}
}
22 changes: 0 additions & 22 deletions makefile

This file was deleted.

14 changes: 9 additions & 5 deletions src/Domain/ValueObject/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ final class Date extends PointInTime
{
public static function fromDateTimeInterface(PhpDateTimeInterface $dateTime): self
{
return new static(
PhpDateTimeImmutable::createFromFormat(
PhpDateTimeInterface::ATOM,
$dateTime->format(PhpDateTimeInterface::ATOM), $dateTime->getTimezone()
)
$dateTime = PhpDateTimeImmutable::createFromFormat(
PhpDateTimeInterface::ATOM,
$dateTime->format(PhpDateTimeInterface::ATOM), $dateTime->getTimezone()
);

if ($dateTime === false) {
throw new \RuntimeException('Unexpected date time value.');
}

return new static($dateTime);
}

public static function fromCurrentDay(): self
Expand Down
14 changes: 9 additions & 5 deletions src/Domain/ValueObject/Timestamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ class Timestamp extends PointInTime
{
public static function fromDateTimeInterface(PhpDateTimeInterface $dateTime): self
{
return new static(
PhpDateTimeImmutable::createFromFormat(
PhpDateTimeInterface::ATOM,
$dateTime->format(PhpDateTimeInterface::ATOM), $dateTime->getTimezone()
)
$dateTime = PhpDateTimeImmutable::createFromFormat(
PhpDateTimeInterface::ATOM,
$dateTime->format(PhpDateTimeInterface::ATOM), $dateTime->getTimezone()
);

if ($dateTime === false) {
throw new \RuntimeException('Unexpected date time value.');
}

return new static($dateTime);
}

public static function fromCurrentTime(): self
Expand Down
6 changes: 5 additions & 1 deletion src/Domain/ValueObject/UniqueIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public static function fromString(string $uid): self

public static function create(): self
{
if (function_exists('uuid_create') && defined('UUID_TYPE_RANDOM')) {
return static::fromString((string) uuid_create(UUID_TYPE_RANDOM));
}

return static::fromString(uniqid());
}

Expand All @@ -33,7 +37,7 @@ private function __construct(string $uid)
$this->uid = $uid;
}

public function __toString()
public function __toString(): string
{
return $this->uid;
}
Expand Down
Loading

0 comments on commit 21ecfaf

Please sign in to comment.