mirror of
https://github.com/WordPress/five-for-the-future.git
synced 2025-07-04 18:05:45 +03:00
Tools: Move from Travis to GitHub Actions for CI checks (#154)
This commit is contained in:
parent
13a417ce8e
commit
ee8583d91d
4 changed files with 771 additions and 357 deletions
110
.github/workflows/ci.yml
vendored
Normal file
110
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,110 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches: [production]
|
||||
|
||||
jobs:
|
||||
phpcs:
|
||||
name: PHP CodeSniffer
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get Composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Set up Composer caching
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-composer-dependencies
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.4'
|
||||
coverage: none
|
||||
tools: composer, cs2pr
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: |
|
||||
composer install --prefer-dist --no-suggest --no-progress --no-ansi --no-interaction
|
||||
echo "${PWD}/mu-plugins/vendor/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Run PHPCS on changed files
|
||||
run: |
|
||||
touch $GITHUB_WORKSPACE/tmp.php
|
||||
export CHANGED_FILES=$(git diff --name-only --diff-filter=AM remotes/origin/${{ github.base_ref }} | tr '\n' ' ')
|
||||
phpcs -q -n --report=checkstyle $GITHUB_WORKSPACE/tmp.php $(echo $CHANGED_FILES) | cs2pr
|
||||
|
||||
phpunit:
|
||||
name: PHP Unit Tests
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-version: ['7.4']
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
env:
|
||||
MYSQL_ALLOW_EMPTY_PASSWORD: false
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_DATABASE: wcorg_test
|
||||
ports:
|
||||
- 3306/tcp
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Get Composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Set up Composer caching
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-composer-dependencies
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-version }}
|
||||
coverage: none
|
||||
tools: composer
|
||||
|
||||
- name: Install Composer dependencies
|
||||
run: |
|
||||
composer install --prefer-dist --no-suggest --no-progress --no-ansi --no-interaction
|
||||
echo "${PWD}/mu-plugins/vendor/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Start mysql service
|
||||
run: sudo /etc/init.d/mysql start
|
||||
|
||||
- name: Install WordPress
|
||||
run: |
|
||||
bash bin/install-wp-tests.sh wporg_5ftf_test root root 127.0.0.1 trunk
|
||||
|
||||
- name: Running unit tests
|
||||
run: composer run-script test -- -c phpunit.xml.dist
|
Loading…
Add table
Add a link
Reference in a new issue