wordpress/.github/workflows/test-coverage.yml
Jonathan Desrosiers 4935d34e84 Build/Test Tools: Update actions within test workflows to the latest versions.
This updates two published GitHub actions to their latest versions:

- `actions/setup-node` from `v1` to `v2`.
- `styfle/cancel-workflow-action` from `0.5.0` to `0.8.0`.

See #50401.

git-svn-id: https://develop.svn.wordpress.org/trunk@50387 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-18 18:45:23 +00:00

141 lines
4.6 KiB
YAML

name: Code Coverage Report
on:
# Once daily at 00:00 UTC.
schedule:
- cron: '0 0 * * *'
env:
LOCAL_DIR: build
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: ${{ true }}
COMPOSER_INSTALL: ${{ false }}
# Controls which NPM script to use for running PHPUnit tests. Options ar `php` and `php-composer`.
PHPUNIT_SCRIPT: php
LOCAL_PHP: '7.4-fpm'
LOCAL_PHP_XDEBUG: true
LOCAL_PHP_MEMCACHED: ${{ false }}
jobs:
# Sets up WordPress for testing or development use.
#
# Performs the following steps:
# - Set environment variables.
# - Checks out the repository.
# - Checks out the WordPress Importer plugin (needed for the Core PHPUnit tests).
# - Logs debug information about the runner container.
# - Installs NodeJS 14.
# - Sets up caching for NPM.
# _ Installs NPM dependencies using install-changed to hash the `package.json` file.
# - Builds WordPress to run from the `build` directory.
# - Logs Docker debug information (about the Docker installation within the runner).
# - Starts the WordPress Docker container.
# - Logs debug general information.
# - Logs the running Docker containers.
# - Logs WordPress Docker container debug information.
# - Logs debug information about what's installed within the WordPress Docker containers.
# - Install WordPress within the Docker container.
# - Run the PHPUnit tests as a single site.
# - Upload the single site code coverage report to Codecov.io.
# - Run the PHPUnit tests as a multisite.
# - Upload the multisite code coverage report to Codecov.io.
test-coverage-report:
name: Generate a code coverage report
runs-on: ubuntu-latest
if: ${{ github.repository == 'WordPress/wordpress-develop' }}
steps:
- name: Configure environment variables
run: |
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout the WordPress Importer plugin
run: svn checkout -r 2387243 https://plugins.svn.wordpress.org/wordpress-importer/trunk/ tests/phpunit/data/plugins/wordpress-importer
- name: Log debug information
run: |
echo "$GITHUB_REF"
echo "$GITHUB_EVENT_NAME"
npm --version
node --version
curl --version
git --version
svn --version
php --version
php -i
locale -a
- name: Install NodeJS
uses: actions/setup-node@v2
with:
node-version: 14
- name: Cache NodeJS modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install Dependencies
run: npx install-changed --install-command="npm ci"
- name: Build WordPress
run: npm run build
- name: Docker debug information
run: |
docker -v
docker-compose -v
- name: Start Docker environment
run: |
npm run env:start
- name: General debug information
run: |
npm --version
node --version
curl --version
git --version
svn --version
- name: Log running Docker containers
run: docker ps -a
- name: WordPress Docker container debug information
run: |
docker-compose run --rm mysql mysql --version
docker-compose run --rm php php --version
docker-compose run --rm php php -m
docker-compose run --rm php php -i
docker-compose run --rm php locale -a
- name: Install WordPress
run: npm run env:install
- name: Run tests as a single site
run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c phpunit.xml.dist --coverage-clover wp-code-coverage-single-clover-${{ github.sha }}.xml
- name: Upload single site report to Codecov
uses: codecov/codecov-action@v1
with:
file: wp-code-coverage-single-clover-${{ github.sha }}.xml
flags: single,php
- name: Run tests as a multisite install
run: npm run test:${{ env.PHPUNIT_SCRIPT }} -- --verbose -c tests/phpunit/multisite.xml --coverage-clover wp-code-coverage-multisite-clover-${{ github.sha }}.xml
- name: Upload multisite report to Codecov
uses: codecov/codecov-action@v1
with:
file: wp-code-coverage-multisite-clover-${{ github.sha }}.xml
flags: multisite,php