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 May 29, 2021
1 parent f62604a commit 1f9e18f
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 121 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Expand Up @@ -11,3 +11,6 @@ indent_size = 4
[*.yml]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
6 changes: 4 additions & 2 deletions .gitattributes
@@ -1,7 +1,9 @@
.coveralls.yml export-ignore
* text=auto

.editorconfig export-ignore
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
.travis.yml export-ignore
Makefile export-ignore
phpunit.xml export-ignore
tests/ export-ignore
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,49 @@
name: test

on:
- push
- pull_request

jobs:
phpunit:
name: phpunit
runs-on: ubuntu-18.04
strategy:
matrix:
php-version:
- "7.1"
- "7.2"
- "7.3"
- "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 == '7.1' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
1 change: 1 addition & 0 deletions .gitignore
@@ -1,3 +1,4 @@
.phpunit.result.cache
build
composer.lock
vendor
21 changes: 0 additions & 21 deletions .travis.yml

This file was deleted.

25 changes: 11 additions & 14 deletions Dockerfile
@@ -1,24 +1,21 @@
FROM php:7.1-alpine
FROM php:7.1-cli-buster

RUN apk add --update --no-cache make $PHPIZE_DEPS && \
pecl install xdebug-2.6.1 && \
docker-php-ext-enable xdebug
RUN docker-php-ext-enable opcache

RUN echo $'\
xdebug.remote_autostart=1\n\
xdebug.remote_enable=1\n\
xdebug.remote_host=host.docker.internal\n\
RUN echo '\
xdebug.client_host=host.docker.internal\n\
xdebug.mode=develop\n\
xdebug.start_with_request=yes\n\
' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN echo $'\
RUN echo '\
date.timezone=UTC\n\
' >> /usr/local/etc/php/conf.d/php.ini

ENV PHP_IDE_CONFIG serverName=icanboogie-tests
ENV PHP_IDE_CONFIG serverName=icanboogie-session-tests
ENV COMPOSER_ALLOW_SUPERUSER 1

RUN curl -o /tmp/composer-setup.php https://getcomposer.org/installer && \
curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig && \
php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }" && \
php /tmp/composer-setup.php && \
RUN apt-get update && \
apt-get install unzip && \
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
mv composer.phar /usr/local/bin/composer
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,7 +1,7 @@
The icanboogie/session package is free software.
It is released under the terms of the following BSD License.

Copyright (c) 2015-2018 by Olivier Laviale
Copyright (c) 2015-2021 by Olivier Laviale
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
31 changes: 13 additions & 18 deletions Makefile
Expand Up @@ -2,46 +2,43 @@

PACKAGE_NAME = icanboogie/session
PACKAGE_VERSION = 2.0
PHPUNIT_VERSION = phpunit-7-4.phar
PHPUNIT = build/$(PHPUNIT_VERSION)
PHPUNIT = vendor/bin/phpunit

# do not edit the following lines

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

vendor:
@COMPOSER_ROOT_VERSION=$(PACKAGE_VERSION) composer install

.PHONY: update
update:
@COMPOSER_ROOT_VERSION=$(PACKAGE_VERSION) composer update

# testing

test-dependencies: vendor $(PHPUNIT)

$(PHPUNIT):
mkdir -p build
wget https://phar.phpunit.de/$(PHPUNIT_VERSION) -O $(PHPUNIT)
chmod +x $(PHPUNIT)

test-container:
@docker-compose run --rm app sh
@docker-compose down
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 --coverage-text

.PHONY: test-coveralls
test-coveralls: test-dependencies
@mkdir -p build/logs
@$(PHPUNIT) --coverage-clover build/logs/clover.xml

#doc
.PHONY: test-container
test-container:
@-docker-compose -f ./docker-compose.yml run --rm app bash
@docker-compose -f ./docker-compose.yml down -v

.PHONY: doc
doc: vendor
@mkdir -p build/docs
@apigen generate \
Expand All @@ -50,11 +47,9 @@ doc: vendor
--title "$(PACKAGE_NAME) v$(PACKAGE_VERSION)" \
--template-theme "bootstrap"

# utils

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

.PHONY: all autoload doc clean test test-coverage test-coveralls test-dependencies update
41 changes: 11 additions & 30 deletions README.md
@@ -1,7 +1,7 @@
# Session

[![Release](https://img.shields.io/packagist/v/icanboogie/session.svg)](https://packagist.org/packages/icanboogie/session)
[![Build Status](https://img.shields.io/travis/ICanBoogie/Session.svg)](http://travis-ci.org/ICanBoogie/Session)
[![Build Status](https://img.shields.io/github/workflow/status/ICanBoogie/Session/test)](https://github.com/ICanBoogie/Session/actions?query=workflow%3Atest)
[![Code Quality](https://img.shields.io/scrutinizer/g/ICanBoogie/Session.svg)](https://scrutinizer-ci.com/g/ICanBoogie/Session)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/Session.svg)](https://coveralls.io/r/ICanBoogie/Session)
[![Packagist](https://img.shields.io/packagist/dt/icanboogie/session.svg)](https://packagist.org/packages/icanboogie/session)
Expand Down Expand Up @@ -170,16 +170,16 @@ class UserController
* @var SessionSegment
*/
private $session;

public function __construct(SessionSegment $session)
{
$this->session = $session;
}

public function action_post_login()
{
// …

$this->session['user_id'] = $user->id;
}
}
Expand Down Expand Up @@ -301,7 +301,7 @@ When processing an unsafe request, make sure the session token is valid:
if (in_array($_SERVER['REQUEST_METHOD'], [ 'POST', 'PUT', 'DELETE' ]))
{
$token = isset($_POST['_session_token']) ? $_POST['_session_token'] : null;

if ($session->verify_token($token))
{
// Token is verified, we can proceed with the request.
Expand Down Expand Up @@ -334,26 +334,14 @@ The package requires PHP 7.1 or later.

## Installation

The recommended way to install this package is through [Composer](http://getcomposer.org/):

```
$ composer require icanboogie/session
```bash
composer require icanboogie/session
```





### Cloning the repository

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

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





## Documentation

The package is documented as part of the [ICanBoogie][] framework [documentation][]. You can
Expand All @@ -367,24 +355,17 @@ The directory can later be cleaned with the `make clean` command.

## Testing

The test suite is ran with the `make test` command. [PHPUnit](https://phpunit.de/) and
[Composer](http://getcomposer.org/) need to be globally available to run the suite. The command
installs dependencies as required. The `make test-coverage` command runs test suite and also creates
an HTML coverage report in `build/coverage`. The 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://img.shields.io/travis/ICanBoogie/Session.svg)](http://travis-ci.org/ICanBoogie/Session)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/Session.svg)](https://coveralls.io/r/ICanBoogie/Session)
Run `make test-container` to create and log into the test container, then run `make test` to run the
test suite. Alternatively, run `make test-coverage` to run the test suite with test coverage. Open
`build/coverage/index.html` to see the breakdown of the code coverage.





## License

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



Expand Down
10 changes: 9 additions & 1 deletion composer.json
Expand Up @@ -22,13 +22,21 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": "^7.1",
"php": ">=7.1",
"icanboogie/accessor": "^2.0|^3.0|^4.0"
},
"autoload": {
"psr-4": {
"ICanBoogie\\": "lib/",
"ICanBoogie\\Session\\": "lib/Session"
}
},
"autoload-dev": {
"psr-4": {
"ICanBoogie\\": "tests"
}
},
"require-dev": {
"phpunit/phpunit": "^7.5"
}
}
3 changes: 2 additions & 1 deletion docker-compose.yml
@@ -1,8 +1,9 @@
---
version: "2.1"
version: "3.2"
services:
app:
build: .
volumes:
- .:/app:delegated
- ~/.composer:/root/.composer
working_dir: /app

0 comments on commit 1f9e18f

Please sign in to comment.