Skip to content

Commit

Permalink
GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-worman committed Mar 6, 2022
1 parent 6a6e80b commit 9430e2f
Show file tree
Hide file tree
Showing 15 changed files with 169 additions and 203 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: CI
on: [push, pull_request]
jobs:
lint:
name: Lint
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: php-parallel-lint/php-parallel-lint:1
- name: Lint
run: parallel-lint --show-deprecated build phpseclib tests
strategy:
fail-fast: false
matrix:
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
quality_tools:
name: Quality Tools
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: squizlabs/php_codesniffer:3, friendsofphp/php-cs-fixer:3, vimeo/psalm:4
- name: Composer Install
run: composer install --classmap-authoritative --no-interaction --no-cache
- name: PHP_CodeSniffer
run: phpcs --standard=build/php_codesniffer.xml
- name: PHP CS Fixer
run: php-cs-fixer fix --config=build/php-cs-fixer.php --diff --dry-run --using-cache=no
- name: Psalm
run: psalm --config=build/psalm.xml --no-cache --long-progress --report-show-info=false
tests:
name: Tests
timeout-minutes: 10
continue-on-error: ${{ matrix.experimental }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Composer Install
run: composer install --classmap-authoritative --no-interaction --no-cache
- name: Make Tests Compatiable With New PHPUnit Versions
if: matrix.php-version != '5.6' && matrix.php-version != '7.0'
run: php tests/make_compatible_with_new_phpunit_versions.php
- name: Setup Secure Shell Functional Tests
if: runner.os == 'ubuntu-latest'
run: |
PHPSECLIB_SSH_USERNAME='phpseclib'
PHPSECLIB_SSH_PASSWORD='EePoov8po1aethu2kied1ne0'
sudo useradd --create-home --base-dir /home "$PHPSECLIB_SSH_USERNAME"
echo "$PHPSECLIB_SSH_USERNAME:$PHPSECLIB_SSH_PASSWORD" | sudo chpasswd
ssh-keygen -t rsa -b 1024 -f "$HOME/.ssh/id_rsa" -q -N ""
eval `ssh-agent -s`
ssh-add "$HOME/.ssh/id_rsa"
sudo mkdir -p "/home/$PHPSECLIB_SSH_USERNAME/.ssh/"
sudo cp "$HOME/.ssh/id_rsa.pub" "/home/$PHPSECLIB_SSH_USERNAME/.ssh/authorized_keys"
sudo ssh-keyscan -t rsa localhost > "/tmp/known_hosts"
sudo cp "/tmp/known_hosts" "/home/$PHPSECLIB_SSH_USERNAME/.ssh/known_hosts"
sudo chown "$PHPSECLIB_SSH_USERNAME:$PHPSECLIB_SSH_USERNAME" "/home/$PHPSECLIB_SSH_USERNAME/.ssh/" -R
echo "PHPSECLIB_SSH_HOSTNAME=localhost" >> $GITHUB_ENV
echo "PHPSECLIB_SSH_USERNAME=$PHPSECLIB_SSH_USERNAME" >> $GITHUB_ENV
echo "PHPSECLIB_SSH_PASSWORD=$PHPSECLIB_SSH_PASSWORD" >> $GITHUB_ENV
echo "PHPSECLIB_SSH_HOME=/home/phpseclib" >> $GITHUB_ENV
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV
- name: PHPUnit
run: |
env
vendor/bin/phpunit --verbose --configuration tests/phpunit.xml
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
php-version: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
experimental: [false]
include:
- {os: ubuntu-latest, php-version: '8.2', experimental: true}
- {os: windows-latest, php-version: '8.2', experimental: true}
- {os: macos-latest, php-version: '8.2', experimental: true}
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# phpseclib - PHP Secure Communications Library

[![Build Status](https://travis-ci.com/phpseclib/phpseclib.svg?branch=master)](https://travis-ci.com/github/phpseclib/phpseclib)
[![CI Status](https://github.com/phpseclib/phpseclib/actions/workflows/ci.yml/badge.svg?branch=master&event=push "CI Status")](https://github.com/phpseclib/phpseclib)

## Supporting phpseclib

Expand Down Expand Up @@ -82,19 +82,17 @@ Special Thanks to our $50+ sponsors!:
3. Install Development Dependencies
```sh
composer install
composer install --no-interaction --working-dir=build
```

4. Create a Feature Branch

5. Run continuous integration checks:
```sh
vendor/bin/phpunit

# The following tools are from the build specific composer.json using the most recent PHP version:
build/vendor/bin/phpcs --standard=build/phpcs_ruleset.xml
build/vendor/bin/php-cs-fixer fix --config=build/php-cs-fixer.php --diff --dry-run
build/vendor/bin/psalm --config=build/psalm.xml --no-cache --long-progress --report-show-info=false --output-format=text
composer global require php:^8.1 squizlabs/php_codesniffer friendsofphp/php-cs-fixer vimeo/psalm
phpcs --standard=build/php_codesniffer.xml
php-cs-fixer fix --config=build/php-cs-fixer.php --diff --dry-run --using-cache=no
psalm --config=build/psalm.xml --no-cache --long-progress --report-show-info=false --output-format=text
vendor/bin/phpunit --verbose --configuration tests/phpunit.xml
```

6. Send us a Pull Request
15 changes: 0 additions & 15 deletions build/composer.json

This file was deleted.

File renamed without changes.
9 changes: 6 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@
}
],
"require": {
"php": ">=5.6.1",
"paragonie/constant_time_encoding": "^1|^2",
"paragonie/random_compat": "^1.4|^2.0|^9.99.99",
"php": ">=5.6.1"
"paragonie/random_compat": "^1.4|^2.0|^9.99.99"
},
"require-dev": {
"phpunit/phpunit": "^5.7|^6.0|^9.4"
"phpunit/phpunit": "*"
},
"suggest": {
"ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.",
Expand All @@ -76,5 +76,8 @@
"psr-4": {
"phpseclib3\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true
}
}
21 changes: 0 additions & 21 deletions phpunit.xml.dist

This file was deleted.

2 changes: 1 addition & 1 deletion tests/Unit/Crypt/RSA/CreateKeyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use phpseclib3\Crypt\RSA\PublicKey;
use phpseclib3\Tests\PhpseclibTestCase;

class CreateKeyTestRSA extends PhpseclibTestCase
class CreateKeyTest extends PhpseclibTestCase
{
public function testCreateKey()
{
Expand Down
17 changes: 10 additions & 7 deletions tests/Unit/Crypt/RSA/ModeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,16 @@ public function testHash()
public function testPKCS1SigWithoutNull()
{
$rsa = PublicKeyLoader::load([
'n' => new BigInteger('0xE932AC92252F585B3A80A4DD76A897C8B7652952FE788F6EC8DD640587A1EE5647670A8AD
4C2BE0F9FA6E49C605ADF77B5174230AF7BD50E5D6D6D6D28CCF0A886A514CC72E51D209CC7
72A52EF419F6A953F3135929588EBE9B351FCA61CED78F346FE00DBB6306E5C2A4C6DFC3779
AF85AB417371CF34D8387B9B30AE46D7A5FF5A655B8D8455F1B94AE736989D60A6F2FD5CADB
FFBD504C5A756A2E6BB5CECC13BCA7503F6DF8B52ACE5C410997E98809DB4DC30D943DE4E81
2A47553DCE54844A78E36401D13F77DC650619FED88D8B3926E3D8E319C80C744779AC5D6AB
E252896950917476ECE5E8FC27D5F053D6018D91B502C4787558A002B9283DA7', 16),
'n' => new BigInteger(
'E932AC92252F585B3A80A4DD76A897C8B7652952FE788F6EC8DD640587A1EE5647670A8AD' .
'4C2BE0F9FA6E49C605ADF77B5174230AF7BD50E5D6D6D6D28CCF0A886A514CC72E51D209CC7' .
'72A52EF419F6A953F3135929588EBE9B351FCA61CED78F346FE00DBB6306E5C2A4C6DFC3779' .
'AF85AB417371CF34D8387B9B30AE46D7A5FF5A655B8D8455F1B94AE736989D60A6F2FD5CADB' .
'FFBD504C5A756A2E6BB5CECC13BCA7503F6DF8B52ACE5C410997E98809DB4DC30D943DE4E81' .
'2A47553DCE54844A78E36401D13F77DC650619FED88D8B3926E3D8E319C80C744779AC5D6AB' .
'E252896950917476ECE5E8FC27D5F053D6018D91B502C4787558A002B9283DA7',
16
),
'e' => new BigInteger('3')
]);

Expand Down
31 changes: 31 additions & 0 deletions tests/make_compatible_with_new_phpunit_versions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/** @var iterable<SplFileInfo> $files */
$files = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator(__DIR__));
foreach ($files as $file) {
if ($file->getExtension() === 'php' && $file->getPathname() !== __FILE__) {
$fileContents = file_get_contents($file->getPathname());
if ($fileContents === false) {
throw new \RuntimeException('file_get_contents() failed: ' . $file->getPathname());
}
$patternToReplacementMap = [
'~ function setUpBeforeClass\(\)~' => ' function setUpBeforeClass(): void',
'~ function setUp\(\)~' => ' function setUp(): void',
'~ function tearDown\(\)~' => ' function tearDown(): void',
'~ function assertIsArray\(\$actual, \$message = \'\'\)~' => ' function assertIsArray($actual, string $message = \'\'): void',
'~ function assertIsResource\(\$actual, \$message = \'\'\)~' => ' function assertIsResource($actual, string $message = \'\'): void',
'~ function assertIsObject\(\$actual, \$message = \'\'\)~' => ' function assertIsObject($actual, string $message = \'\'): void',
'~ function assertIsString\(\$actual, \$message = \'\'\)~' => ' function assertIsString($actual, string $message = \'\'): void',
'~ function assertStringContainsString\(\$needle, \$haystack, \$message = \'\'\)~' => ' function assertStringContainsString(string $needle, string $haystack, string $message = \'\'): void',
'~ function assertStringNotContainsString\(\$needle, \$haystack, \$message = \'\'\)~' => ' function assertStringNotContainsString(string $needle, string $haystack, string $message = \'\'): void',
];
$updatedFileContents = preg_replace(
array_keys($patternToReplacementMap),
array_values($patternToReplacementMap),
$fileContents
);
if (file_put_contents($file->getPathname(), $updatedFileContents) === false) {
throw new \RuntimeException('file_put_contents() failed: ' . $file->getPathname());
}
}
}
21 changes: 21 additions & 0 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="bootstrap.php"
colors="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<testsuites>
<testsuite name="phpseclib Unit Test Suite">
<directory>./Unit/</directory>
</testsuite>
<testsuite name="phpseclib Functional Test Suite">
<directory>./Functional/</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory>../phpseclib/</directory>
</include>
</coverage>
</phpunit>
25 changes: 0 additions & 25 deletions travis/install-php-extensions.sh

This file was deleted.

45 changes: 0 additions & 45 deletions travis/run-phpunit.sh

This file was deleted.

6 changes: 0 additions & 6 deletions travis/setup-composer.sh

This file was deleted.

Loading

0 comments on commit 9430e2f

Please sign in to comment.