Skip to content

Commit

Permalink
Merge pull request woocommerce#29070 from woocommerce/enhancement/28924
Browse files Browse the repository at this point in the history
Add CI for code coverage and code sniff on GitHub actions.
  • Loading branch information
claudiosanches authored Feb 10, 2021
2 parents 69c5d42 + 4a39b00 commit 734f54c
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pr-build-and-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:

- name: Add comment
uses: actions/github-script@v3
if: "woocommerce" == {{ github.repository_owner }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/pr-code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Run code coverage on PR
on:
pull_request
jobs:
test:
name: Code coverage (PHP 7.4, WP Latest)
timeout-minutes: 15
runs-on: ubuntu-latest
services:
database:
image: mysql:5.6
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer
extensions: mysql
coverage: none

- name: Tool versions
run: |
php --version
composer --version
- name: Get cached composer directories
uses: actions/cache@v2
with:
path: |
./packages
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}

- name: Setup and install composer
run: composer install

- name: Init DB and WP
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 latest

- name: Run unit tests with code coverage. Allow to fail.
run: |
RUN_CODE_COVERAGE=1 bash ./tests/bin/phpunit.sh
exit 0
49 changes: 49 additions & 0 deletions .github/workflows/pr-code-sniff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Run code sniff on PR
on:
pull_request
jobs:
test:
name: Code sniff (PHP 7.4, WP Latest)
timeout-minutes: 15
runs-on: ubuntu-latest
services:
database:
image: mysql:5.6
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer
extensions: mysql
coverage: none

- name: Tool versions
run: |
php --version
composer --version
- name: Get cached composer directories
uses: actions/cache@v2
with:
path: |
./packages
./vendor
key: ${{ runner.os }}-${{ hashFiles('./composer.lock') }}

- name: Setup and install composer
run: composer install

- name: Init DB and WP
run: ./tests/bin/install.sh woo_test root root 127.0.0.1 latest

- name: Run code sniff
run: RUN_PHPCS=1 bash ./tests/bin/phpcs.sh
1 change: 1 addition & 0 deletions .github/workflows/pr-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
wp: [ "latest" ]
Expand Down

0 comments on commit 734f54c

Please sign in to comment.