Skip to content

Commit

Permalink
Convert Travis CI to GitHub Actions (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo authored Jul 20, 2020
1 parent dc4f726 commit a1440ca
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 38 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Tests

on:
push:
branches:
- master
pull_request:

jobs:
phpUnitTests:
runs-on: ubuntu-latest
name: Unit Tests / PHP ${{ matrix.phpVersions }}
strategy:
max-parallel: 6
matrix:
phpVersions: ['7.2', '7.3', '7.4']
fail-fast: false
env:
phpExtensions: mbstring, intl, gd, xml, sqlite
cacheKey: ext-cache-v1
octoberCmsRelease: develop
steps:
- name: Checkout changes
uses: actions/checkout@v2
with:
path: user-plugin

- name: Setup cache environment
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.phpVersions }}
extensions: ${{ env.phpExtensions }}
key: ${{ env.cacheKey }}

- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}

- name: Install PHP and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.phpVersions }}
extensions: ${{ env.phpExtensions }}
tools: composer
coverage: none

- name: Install October CMS
run: |
wget https://github.com/octobercms/october/archive/${{ env.octoberCmsRelease }}.zip
unzip ${{ env.octoberCmsRelease }}.zip
shopt -s dotglob
mv october-${{ env.octoberCmsRelease }}/* ./
shopt -u dotglob
cp config/cms.php config/testing/cms.php
mkdir -p plugins/rainlab
mv user-plugin plugins/rainlab/user
- name: Get Composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-

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

- name: Run linting
run: ./vendor/bin/parallel-lint plugins/rainlab/user

- name: Run unit tests
run: |
cd plugins/rainlab/user
../../../vendor/bin/phpunit
27 changes: 0 additions & 27 deletions .travis.yml

This file was deleted.

3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,5 @@
"php": ">=5.5.9",
"composer/installers": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7"
},
"minimum-stability": "dev"
}
7 changes: 3 additions & 4 deletions tests/PluginTestCase.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php namespace RainLab\User\Tests;

use App;
use Artisan;
use Illuminate\Foundation\AliasLoader;
use PluginTestCase as BasePluginTestCase;
use Illuminate\Foundation\AliasLoader;
use RainLab\User\Models\Settings;

abstract class PluginTestCase extends BasePluginTestCase
Expand All @@ -17,7 +16,7 @@ abstract class PluginTestCase extends BasePluginTestCase

/**
* Perform test case set up.
*
*
* @return void
*/
public function setUp()
Expand All @@ -34,7 +33,7 @@ public function setUp()
$alias = AliasLoader::getInstance();
$alias->alias('Auth', 'RainLab\User\Facades\Auth');

App::singleton('user.auth', function() {
App::singleton('user.auth', function () {
return \RainLab\User\Classes\AuthManager::instance();
});
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/facades/AuthFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class AuthFacadeTest extends PluginTestCase
{
public function test_registering_a_user()
public function testRegisteringAUser()
{
// register a user
$user = Auth::register([
Expand All @@ -26,7 +26,7 @@ public function test_registering_a_user()
$this->assertEquals('[email protected]', $user->email);
}

public function test_registering_a_user_with_auto_activation()
public function testRegisteringAUserWithAutoActivation()
{
// register a user with the auto-activate flag
$user = Auth::register([
Expand All @@ -43,7 +43,7 @@ public function test_registering_a_user_with_auto_activation()
$this->assertTrue(Auth::check());
}

public function test_registering_a_guest()
public function testRegisteringAGuest()
{
// register a guest
$guest = Auth::registerGuest(['email' => '[email protected]']);
Expand All @@ -57,7 +57,7 @@ public function test_registering_a_guest()
$this->assertEquals('[email protected]', $guest->email);
}

public function test_login_and_checking_authentication()
public function testLoginAndCheckingAuthentication()
{
// we should not be authenticated
$this->assertFalse(Auth::check());
Expand Down

0 comments on commit a1440ca

Please sign in to comment.