Skip to content

Commit

Permalink
Replace Travis with GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Apr 15, 2022
1 parent c257c0b commit 86d40d9
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 99 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
@@ -1,7 +1,6 @@
.coveralls.yml export-ignore
.github
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
Makefile export-ignore
phpunit.xml.dist export-ignore
tests/ export-ignore
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,48 @@
name: test

on:
- push
- pull_request

jobs:
phpunit:
name: phpunit
runs-on: ubuntu-18.04
strategy:
matrix:
php-version:
- "5.6"
- "7.0"
- "7.4"
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
coverage: xdebug
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1
tools: composer:v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: |
~/.composer/cache
vendor
key: "php-${{ matrix.php-version }}"
restore-keys: "php-${{ matrix.php-version }}"

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

- name: Run PHPUnit
run: make test-coveralls

- name: Upload code coverage
if: ${{ matrix.php-version == '5.6' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions LICENSE
@@ -1,7 +1,7 @@
The ICanBoogie/DateTime package is free software.
It is released under the terms of the following BSD License.

Copyright (c) 2013-2019 by Olivier Laviale
Copyright (c) 2013-2022 by Olivier Laviale
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand All @@ -28,4 +28,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

43 changes: 6 additions & 37 deletions Makefile
@@ -1,57 +1,26 @@
# customization

PACKAGE_NAME = ICanBoogie/DateTime
PACKAGE_VERSION = v1.2
PHPUNIT_VERSION = phpunit-5.7.phar
PHPUNIT_FILENAME = build/$(PHPUNIT_VERSION)
PHPUNIT = php $(PHPUNIT_FILENAME)
PHPUNIT = vendor/bin/phpunit

# do not edit the following lines

all: $(PHPUNIT_FILENAME) vendor

usage:
@echo "test: Runs the test suite.\ndoc: Creates the documentation.\nclean: Removes the documentation, the dependencies and the Composer files."

vendor:
@composer install

update:
@composer update

autoload: vendor
@composer dump-autoload

test-dependencies: $(PHPUNIT_FILENAME) vendor

$(PHPUNIT_FILENAME):
mkdir -p build
wget https://phar.phpunit.de/$(PHPUNIT_VERSION) -O $(PHPUNIT_FILENAME)
.PHONY: test-dependencies
test-dependencies: vendor

.PHONY: test
test: test-dependencies
@$(PHPUNIT)

.PHONY: test-coverage
test-coverage: test-dependencies
@mkdir -p build/coverage
@$(PHPUNIT) --coverage-html build/coverage

.PHONY: test-coveralls
test-coveralls: test-dependencies
@mkdir -p build/logs
composer require --dev php-coveralls/php-coveralls
@$(PHPUNIT) --coverage-clover build/logs/clover.xml
php vendor/bin/php-coveralls -v

doc: vendor
@mkdir -p build/docs
@apigen generate \
--source lib \
--destination build/docs/ \
--title "$(PACKAGE_NAME) $(PACKAGE_VERSION)" \
--template-theme "bootstrap"

clean:
@rm -fR build
@rm -fR vendor
@rm -f composer.lock

.PHONY: all autoload doc clean test test-coverage test-coveralls update
37 changes: 4 additions & 33 deletions README.md
@@ -1,7 +1,6 @@
# DateTime

[![Release](https://img.shields.io/packagist/v/ICanBoogie/DateTime.svg)](https://packagist.org/packages/icanboogie/datetime)
[![Build Status](https://img.shields.io/travis/ICanBoogie/DateTime.svg)](http://travis-ci.org/ICanBoogie/DateTime)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/DateTime.svg)](https://coveralls.io/r/ICanBoogie/DateTime)
[![Packagist](https://img.shields.io/packagist/dm/icanboogie/datetime.svg?maxAge=2592000)](https://packagist.org/packages/icanboogie/datetime)

Expand Down Expand Up @@ -344,16 +343,12 @@ echo $date->localize('fr')->as_medium; // 5 mai 2015 23:13:05





## Requirement

The package requires PHP 5.6 or later.





## Installation

The recommended way to install this package is through [Composer](https://getcomposer.org/):
Expand All @@ -368,19 +363,6 @@ If the package is not included, `RunTimeException` instances are thrown instead.





### Cloning the repository

The package is [available on GitHub](https://github.com/ICanBoogie/DateTime), its repository can be
cloned with the following command line:

$ git clone https://github.com/ICanBoogie/DateTime.git





## Documentation

The package is documented as part of the [ICanBoogie](http://icanboogie.org/) framework
Expand All @@ -397,28 +379,17 @@ The following classes are documented:



## Continuous Integration

The project is continuously tested by [GitHub actions](https://github.com/ICanBoogie/DateTime/actions).

## Testing

The test suite is ran with the `make test` command. [Composer](http://getcomposer.org/) is
automatically installed as well as all the dependencies required to run the suite. The package
directory can later be cleaned with the `make clean` command.

The package is continuously tested by [Travis CI](http://about.travis-ci.org/).

[![Build Status](https://travis-ci.org/ICanBoogie/DateTime.svg)](https://travis-ci.org/ICanBoogie/DateTime)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/DateTime.svg)](https://coveralls.io/r/ICanBoogie/DateTime)


[![Tests](https://github.com/ICanBoogie/DateTime/workflows/test/badge.svg?branch=master)](https://github.com/ICanBoogie/DateTime/actions?query=workflow%3Atest)



## License

**icanboogie/datetime** is licensed under the New BSD License - See the [LICENSE](LICENSE) file for details.


**ICanBoogie/DateTime** is released under the [BSD-3-Clause](LICENSE).



Expand Down
7 changes: 4 additions & 3 deletions composer.json
Expand Up @@ -3,13 +3,13 @@
"type": "library",
"description": "Extends the features of PHP DateTime and DateTimeZone",
"keywords": ["time", "date", "timezone"],
"homepage": "http://icanboogie.org/",
"homepage": "https://icanboogie.org/",
"license": "BSD-3-Clause",
"authors": [
{
"name": "Olivier Laviale",
"email": "olivier.laviale@gmail.com",
"homepage": "http://www.weirdog.com/",
"homepage": "https://olvlvl.com",
"role" : "Developer"
}
],
Expand All @@ -21,7 +21,8 @@
"php": ">=5.6.0"
},
"require-dev": {
"icanboogie/common": "~1.2"
"icanboogie/common": "^1.2",
"phpunit/phpunit": "^5.6"
},
"suggest": {
"icanboogie/common": "Allows finer exceptions to be thrown"
Expand Down
2 changes: 1 addition & 1 deletion lib/DateTime.php
Expand Up @@ -237,7 +237,7 @@ static public function from($source, $timezone = null)

if ($source instanceof \DateTime)
{
return new static($source->format(self::DB), $source->getTimezone());
return new static($source->format('Y-m-d\TH:i:s.u'), $source->getTimezone());
}

return new static($source, $timezone);
Expand Down

0 comments on commit 86d40d9

Please sign in to comment.