Add CRUD REST API for Form PDFs #1571
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PHPUnit Tests | |
on: | |
pull_request: | |
# Cancels all previous workflow runs for pull requests that have not completed. | |
concurrency: | |
# The concurrency group contains the workflow name and the branch name for pull requests | |
# or the commit hash for any other events. | |
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | |
cancel-in-progress: true | |
env: | |
GF_LICENSE: ${{ secrets.GF_LICENSE }} | |
jobs: | |
# Runs the PHPUnit tests for WordPress. | |
# | |
# Performs the following steps: | |
# - Set environment variables. | |
# - Sets up the environment variables needed for testing with memcached (if desired). | |
# - Downloads the built WordPress artifact from the previous job. | |
# - Unzips the artifact. | |
# - Installs NodeJS | |
# - Sets up caching for NPM. | |
# _ Installs NPM dependencies using install-changed to hash the `package.json` file. | |
# - Configures caching for Composer. | |
# _ Installs Composer dependencies (if desired). | |
# - Logs Docker debug information (about both the Docker installation within the runner). | |
# - Starts the WordPress Docker container. | |
# - Starts the memcached server after the Docker network has been created (if desired). | |
# - Logs WordPress Docker container debug information. | |
# - Logs debug general information. | |
# - Logs the running Docker containers. | |
# - Logs debug information about what's installed within the WordPress Docker containers. | |
# - Install WordPress within the Docker container. | |
# - Run the PHPUnit tests. | |
# - Reports test results to the Distributed Hosting Tests. | |
test-php: | |
name: ${{ matrix.php }}${{ matrix.multisite && ' multisite' || '' }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
php: [ '8.3', '8.2', '8.1', '8.0', '7.4', '7.3' ] | |
os: [ ubuntu-latest ] | |
multisite: [ false ] | |
include: | |
- php: '8.3' | |
os: ubuntu-latest | |
multisite: true | |
- php: '8.3' | |
os: ubuntu-latest | |
multisite: false | |
report: true | |
env: | |
WP_ENV_PHP_VERSION: ${{ matrix.php }} | |
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@v4 | |
# Docs: https://github.com/shivammathur/setup-php | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 7.4 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Setup Node JS | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Log debug information | |
run: | | |
npm --version | |
yarn --version | |
node --version | |
curl --version | |
git --version | |
svn --version | |
php --version | |
php -i | |
locale -a | |
- name: Install Dependencies | |
run: | | |
yarn | |
- name: Install / Setup Gravity PDF + WordPress | |
if: ${{ ! matrix.report }} | |
run: | | |
yarn env:install | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Install / Setup Gravity PDF + WordPress | |
if: ${{ matrix.report }} | |
run: | | |
PHP_ENABLE_XDEBUG=true yarn env:install | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Run PHPUnit tests | |
if: ${{ ! matrix.multisite }} | |
run: | | |
yarn test:php --do-not-cache-result --verbose | |
yarn test:php --group ajax --do-not-cache-result --verbose | |
- name: Run Multisite PHPUnit tests | |
if: ${{ matrix.multisite }} | |
run: | | |
yarn test:php:multisite --verbose | |
yarn test:php:multisite --group ajax --verbose | |
- name: Generate Code Coverage Report for PHP | |
if: ${{ matrix.report }} | |
run: | | |
yarn run test:php --do-not-cache-result --verbose --coverage-clover=/var/www/html/wp-content/plugins/gravity-pdf/tmp/coverage/report-xml/php-coverage1.xml | |
yarn run test:php --group ajax --do-not-cache-result --verbose --coverage-clover=/var/www/html/wp-content/plugins/gravity-pdf/tmp/coverage/report-xml/php-coverage2.xml | |
- name: Code Coverage Upload | |
uses: codecov/codecov-action@v4 | |
if: ${{ matrix.report }} | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
with: | |
files: tmp/coverage/report-xml/php-coverage1.xml | |