Skip to content

Commit

Permalink
Merge pull request #6 from paragonie/ga
Browse files Browse the repository at this point in the history
Migrate off Travis CI
  • Loading branch information
paragonie-security authored Apr 19, 2021
2 parents a832900 + f913a62 commit 2d4e310
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 47 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

on: [push]

jobs:
old:
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-16.04']
php-versions: ['7.0']
phpunit-versions: ['6.5.14']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl
ini-values: post_max_size=256M, max_execution_time=180
tools: psalm, phpunit:${{ matrix.phpunit-versions }}

- name: Install dependencies
run: composer self-update --1; composer install

- name: PHPUnit tests
uses: php-actions/phpunit@v2
with:
memory_limit: 256M

moderate:
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.1', '7.2', '7.3']
phpunit-versions: ['latest']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, sodium
ini-values: post_max_size=256M, max_execution_time=180
tools: psalm, phpunit:${{ matrix.phpunit-versions }}

- name: Install dependencies
run: composer install

- name: Modernize dependencies
run: composer require --dev "phpunit/phpunit:>=4"

- name: PHPUnit tests
uses: php-actions/phpunit@v2
timeout-minutes: 30
with:
memory_limit: 256M

- name: Static Analysis
run: vendor/bin/psalm

modern:
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['7.4', '8.0']
phpunit-versions: ['latest']
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, sodium
ini-values: post_max_size=256M, max_execution_time=180
tools: psalm, phpunit:${{ matrix.phpunit-versions }}

- name: Install dependencies
run: composer install
- name: PHPUnit tests
uses: php-actions/phpunit@v2
timeout-minutes: 30
with:
memory_limit: 256M

- name: Static Analysis
run: vendor/bin/psalm
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ionizer

[![Build Status](https://travis-ci.org/paragonie/ionizer.svg?branch=master)](https://travis-ci.org/paragonie/ionizer)
[![Build Status](https://github.com/paragonie/ionizer/actions/workflows/ci.yml/badge.svg)](https://github.com/ionizer/actions)
[![Latest Stable Version](https://poser.pugx.org/paragonie/ionizer/v/stable)](https://packagist.org/packages/paragonie/ionizer)
[![Latest Unstable Version](https://poser.pugx.org/paragonie/ionizer/v/unstable)](https://packagist.org/packages/paragonie/ionizer)
[![License](https://poser.pugx.org/paragonie/ionizer/license)](https://packagist.org/packages/paragonie/ionizer)
Expand Down Expand Up @@ -29,7 +29,7 @@ composer require paragonie/ionizer
use ParagonIE\Ionizer\GeneralFilterContainer;
use ParagonIE\Ionizer\Filter\{
StringFilter,
WhiteList
AllowList
};

// Define properties to filter:
Expand All @@ -41,7 +41,7 @@ $ic->addFilter(
->addFilter('passphrase', new StringFilter())
->addFilter(
'domain',
new WhiteList('US-1', 'US-2', 'EU-1', 'EU-2')
new AllowList('US-1', 'US-2', 'EU-1', 'EU-2')
);

// Invoke the filter container on the array to get the filtered result:
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
},
"license": "ISC",
"require": {
"php": "^7",
"php": "^7|^8",
"paragonie/constant_time_encoding": "^2.1"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"vimeo/psalm": "^0|^1|^2"
"phpunit/phpunit": "^6.5|^7|^8|^9",
"vimeo/psalm": "^1|^2|^3|^4"
},
"support": {
"email": "[email protected]",
Expand Down
6 changes: 0 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
syntaxCheck="true"
>
<testsuites>
<testsuite name="Unit Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
7 changes: 7 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@
>
<projectFiles>
<directory name="src" />
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</projectFiles>
<issueHandlers>
<MoreSpecificImplementedParamType errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />
<NonInvariantDocblockPropertyType errorLevel="info" />
<RedundantCast errorLevel="info" />
<RedundantCastGivenDocblockType errorLevel="info" />
<UnnecessaryVarAnnotation errorLevel="info" />
</issueHandlers>
</psalm>
10 changes: 5 additions & 5 deletions src/Filter/WhiteList.php → src/Filter/AllowList.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@
use ParagonIE\Ionizer\InvalidDataException;

/**
* Class WhiteList
* Class AllowList
* @package ParagonIE\Ionizer\Filter
*/
class WhiteList extends InputFilter
class AllowList extends InputFilter
{
/**
* @var array<int, mixed>
*/
protected $allowedValues = [];

/**
* WhiteList constructor.
* @param mixed ...$values
* AllowList constructor.
* @param scalar ...$values
*/
public function __construct(...$values)
{
$this->addToWhiteList(...$values);
}

/**
* @param array<int, string|int|float|bool|null> values
* @param array<int, scalar> $values
* @return self
*/
protected function addToWhiteList(...$values)
Expand Down
4 changes: 3 additions & 1 deletion src/InputFilterContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public function addFilter(
* @return mixed
* @throws \Error
* @throws InvalidDataException
*
* @psalm-suppress UnusedVariable
*/
public function filterValue(string $key, $multiDimensional)
{
Expand Down Expand Up @@ -111,7 +113,7 @@ public function filterValue(string $key, $multiDimensional)
*/
public function getUnfilteredValue(string $key, array $multiDimensional = [])
{
/** @var array<ing, string> $pieces */
/** @var array<string, string> $pieces */
$pieces = Util::chunk($key, (string) static::SEPARATOR);

/** @var string|array<string, string|array> $value */
Expand Down
9 changes: 4 additions & 5 deletions tests/WhiteListTest.php → tests/AllowListTest.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?php

use ParagonIE\Ionizer\Filter\WhiteList;
use ParagonIE\Ionizer\Filter\AllowList;
use ParagonIE\Ionizer\GeneralFilterContainer;
use ParagonIE\Ionizer\InvalidDataException;
use PHPUnit\Framework\TestCase;


/**
* Class WhiteListTest
* Class AllowListTest
*/
class WhiteListTest extends TestCase
class AllowListTest extends TestCase
{
/**
* @covers WhiteList
* @throws Error
* @throws InvalidDataException
*/
Expand All @@ -21,7 +20,7 @@ public function testWhiteList()
$filter = (new GeneralFilterContainer())
->addFilter(
'test1',
(new WhiteList(
(new AllowList(
'abc',
'def',
'ghi'
Expand Down
4 changes: 2 additions & 2 deletions tests/ArrayFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
class ArrayFilterTest extends TestCase
{
/**
*
* @before
*/
public function setUp()
public function before()
{
if (!\class_exists('GenericFilterContainer')) {
require_once __DIR__ . '/Errata/GenericFilterContainer.php';
Expand Down

0 comments on commit 2d4e310

Please sign in to comment.