use github actions instead of travis ci

This commit is contained in:
terrafrost 2023-02-10 13:26:59 -06:00
parent ad7a7d5c8f
commit 8e8b214820
3 changed files with 111 additions and 39 deletions

76
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,76 @@
name: CI
on: [push, pull_request]
permissions:
contents: read # to fetch code (actions/checkout)
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.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
tests:
name: Tests
timeout-minutes: 10
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 --no-interaction --no-cache
- name: Make Tests Compatiable With PHPUnit 9+
if: contains(fromJSON('["7.3", "7.4", "8.0", "8.1", "8.2"]'), matrix.php-version)
run: php tests/make_compatible_with_phpunit9.php
- name: Setup Secure Shell Functional Tests
if: matrix.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: vendor/bin/phpunit
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
php-version: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
exclude:
# PHP 5.3 / 5.4 on windows don't have openssl or curl installed, which prevents composer from running
- os: windows-latest
php-version: '5.3'
- os: windows-latest
php-version: '5.4'

View File

@ -1,39 +0,0 @@
language: php
matrix:
include:
- php: 5.4
dist: trusty
- php: 5.5.9
dist: trusty
- php: 5.5
dist: trusty
- php: 5.6
dist: xenial
- php: 7.0
dist: xenial
- php: 7.1
dist: xenial
- php: 7.2
dist: xenial
- php: 7.3
dist: xenial
- php: 7.4
dist: xenial
- php: 8.0
dist: bionic
- php: 8.1
dist: bionic
before_install: true
install:
- phpenv config-rm xdebug.ini
- eval `ssh-agent -s`
- travis/setup-secure-shell.sh
- sh -c "if [ '$TRAVIS_PHP_VERSION' != 'hhvm' -a `php -r "echo (int) version_compare(PHP_VERSION, '7.0', '<');"` = "1" ]; then travis/install-php-extensions.sh; fi"
- travis/setup-composer.sh
script:
- sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.5' ]; then vendor/bin/phing -f build/build.xml sniff; fi"
- travis/run-phpunit.sh

View File

@ -0,0 +1,35 @@
<?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 = array(
'~n setUpBeforeClass\(\)~' => 'n setUpBeforeClass(): void',
'~n setUp\(\)~' => 'n setUp(): void',
'~n tearDown\(\)~' => 'n tearDown(): void',
'~(n assertIsArray\([^\)]*\))~' => '$1: void',
'~(n assertIsString\([^\)]*\))~' => '$1: void',
'~(n assertStringContainsString\([^\)]*\))~' => '$1: void',
'~(n assertStringNotContainsString\([^\)]*\))~' => '$1: void',
'~^class Unit_Crypt_(AES|Hash|RSA)_~m' => 'class ',
'~^class Unit_File_X509_~m' => 'class ',
'~^class Unit_Math_BigInteger_~m' => 'class ',
'~^class Unit_(Crypt|File|Math|Net)_~m' => 'class ',
'~^class Functional_Net__~m' => 'class ',
'~extends Unit_Crypt_Hash_(SHA512Test|SHA256Test)~' => 'extends $1'
);
$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());
}
}
}