Skip to content

Commit

Permalink
Use Github Actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Dec 7, 2020
1 parent ec6460c commit 85d94fa
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 90 deletions.
1 change: 0 additions & 1 deletion .coveralls.yml
@@ -1,3 +1,2 @@
service_name: travis-ci
coverage_clover: coverage.xml # file generated by phpunit
json_path: coverage.json # file generated by php-coveralls
1 change: 1 addition & 0 deletions .distignore
Expand Up @@ -21,6 +21,7 @@ Thumbs.db

# Directories
.git
.github
.idea
.make
assets
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,60 @@
name: Cyr2Lat CI

on: [ push, pull_request ]

jobs:
run:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
php-version: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
name: PHP ${{ matrix.php-version }} on ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies and update PHPUnit
run: |
composer install
make update-phpunit
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run code sniffer
run: vendor/bin/phpcs --colors

- name: Run PHPUnit tests
if: ${{ matrix.php-version != '7.4' }}
run: vendor/bin/phpunit --configuration tests/phpunit/phpunit.xml

- name: Run PHPUnit tests with coverage
if: ${{ matrix.php-version == '7.4' }}
run: vendor/bin/phpunit --configuration tests/phpunit/phpunit.xml --coverage-clover coverage.xml

- name: Run Coveralls for PHPUnit tests
if: ${{ matrix.php-version == '7.4' }}
env:
COVERALLS_RUN_LOCALLY: true
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: vendor/bin/php-coveralls -v

- name: Run JEST with coverage and Coveralls
if: ${{ matrix.php-version == '7.4' }}
env:
COVERALLS_RUN_LOCALLY: true
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
cd src
yarn
yarn run build:dev
yarn run coveralls
cd ..
18 changes: 10 additions & 8 deletions .gitignore
@@ -1,16 +1,18 @@
.DS_Store
Thumbs.db
wp-cli.local.yml
build/
coverage/
dist/
node_modules/
dist/**
build/**
tests/**/*.cache
vendor/
!composer.lock
*.lock
*.opt
*.sql
*.tar.gz
*.zip
*.lock
*.opt
.DS_Store
.idea/
!composer.lock
.phpcs.cache
Thumbs.db
coverage.*
wp-cli.local.yml
65 changes: 54 additions & 11 deletions .make/update-phpunit.sh
Expand Up @@ -2,7 +2,7 @@
# This file updates phpunit library depending on current php version, or using 1st argument.
# Usage:
# composer-update.sh - to update phpunit library for current php version (or do nothing if already updated)
# composer-update.sh x.x - to force update phpunit library for specific php version, where x.x = 5|7|5.6|7.0|7.1|7.2|7.3|7.4
# composer-update.sh x.x - to force update phpunit library for specific php version, where x.x = 5.6|7.0|7.1|7.2|7.3|7.4|8.0

if [[ $1 == '' ]]; then
PHP_VERSION=$(php -v | tac | tail -n 1 | cut -d " " -f 2 | cut -c 1-3)
Expand All @@ -11,30 +11,61 @@ if [[ $1 == '' ]]; then
CURRENT_PHP_UNIT='5.7'
fi

if grep -qE 'version.+6\.5' 'vendor/phpunit/phpunit/src/Runner/Version.php'; then
CURRENT_PHP_UNIT='6.5'
fi

if grep -qE 'version.+7\.5' 'vendor/phpunit/phpunit/src/Runner/Version.php'; then
CURRENT_PHP_UNIT='7.5'
fi

if grep -qE 'version.+8\.5' 'vendor/phpunit/phpunit/src/Runner/Version.php'; then
CURRENT_PHP_UNIT='8.5'
fi

if grep -qE 'version.+9\.5' 'vendor/phpunit/phpunit/src/Runner/Version.php'; then
CURRENT_PHP_UNIT='9.5'
fi

echo "CURRENT_PHP_UNIT: $CURRENT_PHP_UNIT"
else
PHP_VERSION=$1
fi

echo "PHP_VERSION: $PHP_VERSION"

if [[ $PHP_VERSION == '5' || $PHP_VERSION == '5.6' || $PHP_VERSION == '7.0' || $PHP_VERSION == '7.1' ]]; then
if [[ $PHP_VERSION == '5.6' ]]; then
PHP_UNIT='5.7'
fi

if [[ $PHP_VERSION == '7' || $PHP_VERSION == '7.2' || $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' ]]; then
if [[ $PHP_VERSION == '7.0' ]]; then
PHP_UNIT='6.5'
fi

if [[ $PHP_VERSION == '7.1' ]]; then
PHP_UNIT='7.5'
fi

if [[ $PHP_VERSION == '7.2' ]]; then
PHP_UNIT='8.5'
fi

if [[ $PHP_VERSION == '7.3' || $PHP_VERSION == '7.4' || $PHP_VERSION == '8.0' ]]; then
PHP_UNIT='9.5'
fi

if [[ $PHP_UNIT == '' ]]; then
echo "Wrong PHP version: $PHP_VERSION"
exit 1
fi

# Restore test files to the current branch version.
git checkout -- tests

if [[ $PHP_UNIT == '5.7' || $PHP_UNIT == '6.5' || $PHP_UNIT == '7.5' ]]; then
find tests -type f -exec sed -i "s/: void / /g" {} \;
fi

if [[ $CURRENT_PHP_UNIT == "$PHP_UNIT" ]]; then
# Do nothing if current version of phpunit is the same as required. Important on CI.
# Anytime force update available specifying first argument like 'composer-update.sh 7'
Expand All @@ -44,21 +75,33 @@ fi
echo "Building with phpunit-$PHP_UNIT"

if [[ $PHP_UNIT == '5.7' ]]; then
composer config repositories.patchwork '{"type": "vcs", "url": "https://github.com/OnTheGoSystems/patchwork.git", "no-api": true}'
composer config github-protocols https
composer config platform.php 5.6
composer remove --dev --with-all-dependencies lucatume/function-mocker phpunit/phpunit 10up/wp_mock
composer require --dev lucatume/function-mocker:dev-test-on-windows phpunit/phpunit 10up/wp_mock
fi

composer remove --dev antecedent/patchwork sebastian/phpcpd phpunit/phpunit 10up/wp_mock lucatume/function-mocker symfony/console phpunit/php-timer
composer require --dev antecedent/patchwork:^2.0 sebastian/phpcpd:^3.0 phpunit/phpunit:^5.7 10up/wp_mock:~0.2 lucatume/function-mocker:~1.3 symfony/console:^3.4.36 phpunit/php-timer:^1.0.9
if [[ $PHP_UNIT == '6.5' ]]; then
composer config platform.php 7.0
composer remove --dev --with-all-dependencies lucatume/function-mocker phpunit/phpunit 10up/wp_mock symfony/config php-coveralls/php-coveralls
composer require --dev lucatume/function-mocker:dev-test-on-windows phpunit/phpunit 10up/wp_mock symfony/config php-coveralls/php-coveralls
fi

if [[ $PHP_UNIT == '7.5' ]]; then
composer config repositories.patchwork '{"type": "vcs", "url": "https://github.com/antecedent/patchwork.git", "no-api": true}'
composer config github-protocols https
composer config platform.php 7.1
composer remove --dev --with-all-dependencies lucatume/function-mocker phpunit/phpunit 10up/wp_mock
composer require --dev lucatume/function-mocker:dev-test-on-windows phpunit/phpunit 10up/wp_mock
fi

if [[ $PHP_UNIT == '8.5' ]]; then
composer config platform.php 7.2
composer remove --dev --with-all-dependencies lucatume/function-mocker phpunit/phpunit 10up/wp_mock
composer require --dev lucatume/function-mocker:dev-php8 phpunit/phpunit 10up/wp_mock
fi

composer remove --dev antecedent/patchwork sebastian/phpcpd phpunit/phpunit 10up/wp_mock lucatume/function-mocker phpunit/php-timer
composer require --dev antecedent/patchwork:^2.1 sebastian/phpcpd:^4.1 phpunit/phpunit:^7.5 10up/wp_mock:^0.4 lucatume/function-mocker:^1.3 symfony/console:^4.4 phpunit/php-timer:^2.1
if [[ $PHP_UNIT == '9.5' ]]; then
composer config platform.php 7.3
composer remove --dev --with-all-dependencies lucatume/function-mocker phpunit/phpunit 10up/wp_mock
composer require --dev lucatume/function-mocker:dev-php8 phpunit/phpunit 10up/wp_mock
fi

RESULT=$?
Expand Down
68 changes: 0 additions & 68 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions src/package.json
Expand Up @@ -5,7 +5,7 @@
"build:dev": "webpack --mode development",
"build:prod": "webpack -p --env production --mode production",
"test": "jest",
"coveralls": "jest --coverage && cat .src/tests/coverage/lcov.info | coveralls"
"coveralls": "jest --coverage && cat coverage/lcov.info | coveralls"
},
"jest": {
"automock": false,
Expand Down Expand Up @@ -33,7 +33,7 @@
"babel-preset-env": "~1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"coveralls": "~3.0.9",
"coveralls": "^3.1.0",
"eslint": "^6.7.2",
"eslint-config-standard": "~14.1.0",
"eslint-config-wordpress": "^2.0.0",
Expand Down

0 comments on commit 85d94fa

Please sign in to comment.