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 Jun 5, 2021
1 parent 482735f commit 25e999b
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 67 deletions.
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ insert_final_newline = true
indent_style = tab
indent_size = 4

[.travis.yml]
[*.yml]
indent_style = space
indent_size = 2

[*.md]
indent_style = space
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

.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
48 changes: 48 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: test

on:
- push
- pull_request

jobs:
phpunit:
name: phpunit
runs-on: ubuntu-18.04
strategy:
matrix:
php-version:
- "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.2' }}
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
20 changes: 0 additions & 20 deletions .travis.yml

This file was deleted.

9 changes: 1 addition & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#
# Shared stages for ICanBoogie packages
#
FROM php:7.2-cli-buster

RUN apt-get update && \
Expand All @@ -25,9 +22,5 @@ ENV COMPOSER_ALLOW_SUPERUSER 1

RUN apt-get update && \
apt-get install unzip && \
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
curl -s https://raw.githubusercontent.com/composer/getcomposer.org/76a7060ccb93902cd7576b67264ad91c8a2700e2/web/installer | php -- --quiet && \
mv composer.phar /usr/local/bin/composer

#
# Package specifics stages
#
13 changes: 6 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# customization

PACKAGE_NAME = icanboogie/bind-activerecord
PACKAGE_VERSION = 5.0
PHPUNIT = vendor/bin/phpunit

# do not edit the following lines
Expand All @@ -11,11 +10,11 @@ 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
@composer install

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

.PHONY: test-dependencies
test-dependencies: vendor
Expand All @@ -27,7 +26,7 @@ test: test-dependencies
.PHONY: test-coverage
test-coverage: test-dependencies
@mkdir -p build/coverage
@$(PHPUNIT) --coverage-html ../build/coverage
@$(PHPUNIT) --coverage-html ../build/coverage --coverage-text

.PHONY: test-coveralls
test-coveralls: test-dependencies
Expand All @@ -36,16 +35,16 @@ test-coveralls: test-dependencies

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

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

.PHONY: clean
Expand Down
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# bind-activerecord

[![Release](https://img.shields.io/packagist/v/ICanBoogie/bind-activerecord.svg)](https://packagist.org/packages/icanboogie/bind-activerecord)
[![Build Status](https://img.shields.io/travis/ICanBoogie/bind-activerecord.svg)](http://travis-ci.org/ICanBoogie/bind-activerecord)
[![Build Status](https://img.shields.io/github/workflow/status/ICanBoogie/bind-activerecord/test)](https://github.com/ICanBoogie/bind-activerecord/actions?query=workflow%3Atest)
[![Code Quality](https://img.shields.io/scrutinizer/g/ICanBoogie/bind-activerecord.svg)](https://scrutinizer-ci.com/g/ICanBoogie/bind-activerecord)
[![Code Coverage](https://img.shields.io/coveralls/ICanBoogie/bind-activerecord.svg)](https://coveralls.io/r/ICanBoogie/bind-activerecord)
[![Packagist](https://img.shields.io/packagist/dt/icanboogie/bind-activerecord.svg)](https://packagist.org/packages/icanboogie/bind-activerecord)
Expand Down Expand Up @@ -72,37 +72,37 @@ use ICanBoogie\ActiveRecord\Model;

return [

'connections' => [
'connections' => [

'primary' => [
'primary' => [

'dsn' => 'mysql:dbname=mydatabase',
'username' => 'root',
'password' => 'root',
'options' => [
'dsn' => 'mysql:dbname=mydatabase',
'username' => 'root',
'password' => 'root',
'options' => [

ConnectionOptions::TIMEZONE => '+02:00',
ConnectionOptions::TABLE_NAME_PREFIX => 'myprefix'
ConnectionOptions::TIMEZONE => '+02:00',
ConnectionOptions::TABLE_NAME_PREFIX => 'myprefix'

]
],
]
],

'cache' => 'sqlite:' . ICanBoogie\REPOSITORY . 'cache.sqlite'
'cache' => 'sqlite:' . ICanBoogie\REPOSITORY . 'cache.sqlite'

],
],

'models' => [
'models' => [

'nodes' => [
'nodes' => [

Model::SCHEMA => [
Model::SCHEMA => [

'id' => 'serial',
'title' => 'varchar'
'id' => 'serial',
'title' => 'varchar'

]
]
]
]
]
]
];
```

Expand Down Expand Up @@ -165,8 +165,8 @@ test suite. Alternatively, run `make test-coverage` to run the test suite with t



[documentation]: https://icanboogie.org/api/bind-activerecord/5.0/
[ConnectionCollection]: https://icanboogie.org/api/activerecord/5.0/class-ICanBoogie.ActiveRecord.ConnectionCollection.html
[ModelCollection]: https://icanboogie.org/api/activerecord/5.0/class-ICanBoogie.ActiveRecord.ModelCollection.html
[documentation]: https://icanboogie.org/api/bind-activerecord/master/
[ConnectionCollection]: https://icanboogie.org/api/activerecord/master/class-ICanBoogie.ActiveRecord.ConnectionCollection.html
[ModelCollection]: https://icanboogie.org/api/activerecord/master/class-ICanBoogie.ActiveRecord.ModelCollection.html
[icanboogie/activerecord]: https://github.com/ICanBoogie/ActiveRecord
[ICanBoogie]: https://github.com/ICanBoogie/ICanBoogie
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
"prefer-stable": true,
"prefer-dist": true,
"require": {
"php": "^7.2",
"php": ">=7.2",
"icanboogie/icanboogie": "^5.0",
"icanboogie/activerecord": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^8.5"
},
"autoload": {
"psr-4": {
"ICanBoogie\\Binding\\ActiveRecord\\": "lib"
Expand All @@ -51,8 +54,5 @@
},
"scripts": {
"post-autoload-dump": "ICanBoogie\\Autoconfig\\Hooks::on_autoload_dump"
},
"require-dev": {
"phpunit/phpunit": "^8.5"
}
}
6 changes: 4 additions & 2 deletions lib/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ static public function app_lazy_get_connections(Application $app): ConnectionCol
{
static $connections;

// We need to use ?: for the config to be created.
return $connections
?? $connections = new ConnectionCollection($app->configs['activerecord_connections'] ?? []);
?? $connections = new ConnectionCollection($app->configs['activerecord_connections'] ?: []);
}

/**
Expand All @@ -114,8 +115,9 @@ static public function app_lazy_get_models(Application $app): ModelCollection
{
static $models;

// We need to use ?: for the config to be created.
return $models
?? $models = new ModelCollection($app->connections, $app->configs['activerecord_models'] ?? []);
?? $models = new ModelCollection($app->connections, $app->configs['activerecord_models'] ?: []);
}

/**
Expand Down

0 comments on commit 25e999b

Please sign in to comment.