Skip to content

Commit

Permalink
Replace Travis CI with GitHub Actions (#193)
Browse files Browse the repository at this point in the history
* Add PHPUnit GitHub workflow

* Add lint GitHub workflow

* Add dependabot.yml
  • Loading branch information
ocean90 authored Nov 2, 2020
1 parent c90b5a0 commit b79da73
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 88 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
20 changes: 20 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
updates:
- package-ecosystem: "composer"
directory: "/"
schedule:
interval: "daily"
time: "04:00"
timezone: "Europe/Zurich"
open-pull-requests-limit: 10
reviewers:
- "ocean90"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
time: "04:00"
timezone: "Europe/Zurich"
open-pull-requests-limit: 10
reviewers:
- "ocean90"
54 changes: 54 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Lint

on:
pull_request:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
coverage: none
tools: composer, cs2pr

- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Get Composer home directory
id: composer-home
run: |
echo "::set-output name=dir::$(composer config home)"
- name: Cache PHP dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install PHP dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
composer global require ergebnis/composer-normalize
echo "${PWD}/vendor/bin" >> $GITHUB_PATH
echo "${{ steps.composer-home.outputs.dir }}/vendor/bin" >> $GITHUB_PATH
- name: Lint PHP files
run: phpcs -q --report=checkstyle | cs2pr

- name: Analyze PHP files
run: composer run-script analyze

- name: Lint composer.json
run: composer normalize --dry-run
116 changes: 116 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: PHPUnit

on:
push:
branches:
- master
pull_request:

jobs:
phpunit:
name: PHPUnit (PHP ${{ matrix.php }}, WordPress ${{ matrix.wordpress }}, GlotPress ${{ matrix.glotpress }})
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
services:
mysql:
image: mysql:5.7
ports:
- 3306/tcp
env:
MYSQL_ROOT_PASSWORD: password
# Set health checks to wait until mysql has started
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 3
strategy:
matrix:
os: [ ubuntu-latest ]
php: [ '7.4', '7.3', '7.2' ]
wordpress: [ 'latest', 'nightly' ]
glotpress: [ 'develop' ]
experimental: [ false ]
include:
# - php: '8.0'
# os: ubuntu-latest
# experimental: true
- os: ubuntu-latest
php: '7.4'
wordpress: 'latest'
glotpress: 'develop'
experimental: false
coverage: true
- os: ubuntu-latest
php: '7.1'
wordpress: 'latest'
glotpress: 'latest'
experimental: false
- os: ubuntu-latest
php: '7.1'
wordpress: 'nightly'
glotpress: 'latest'
experimental: false

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Set PHP_COVERAGE
run: |
if [ ${{ matrix.coverage }} == 'true' ]; then
echo "PHP_COVERAGE=xdebug" >> $GITHUB_ENV
else
echo "PHP_COVERAGE=none" >> $GITHUB_ENV
fi
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: ${{ env.PHP_COVERAGE }}
tools: composer

- name: Get Composer cache directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache PHP dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mkdir -p bin
mv wp-cli.phar bin/wp
echo "WP_CLI_BIN_DIR=${PWD}/bin" >> $GITHUB_ENV
- name: Install dependencies
run: |
composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader
echo "${PWD}/vendor/bin" >> $GITHUB_PATH
- name: Install WordPress test setup
env:
WP_VERSION: ${{ matrix.wordpress }}
GP_VERSION: ${{ matrix.glotpress }}
MYSQL_PORT: ${{ job.services.mysql.ports[3306] }}
run: bash bin/install-wp-tests.sh wordpress_test root password "127.0.0.1:$MYSQL_PORT" "$WP_VERSION" "$GP_VERSION"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run tests
run: composer run-script test

- name: Upload coverage to Codecov
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v1
87 changes: 0 additions & 87 deletions .travis.yml

This file was deleted.

0 comments on commit b79da73

Please sign in to comment.