From 3b69289e8b3652a26b707e8094cfce3f875eeedc Mon Sep 17 00:00:00 2001 From: MaheswarReddy-Manyam Date: Tue, 18 Jun 2024 17:29:55 +0530 Subject: [PATCH] Add more PR checklist files --- .github/workflows/pr-code-coverage.yml | 58 +++++++++++++++++++++ .github/workflows/pr-code-sniff.yml | 50 ++++++++++++++++++ .github/workflows/pr-unit-tests.yml | 71 ++++++++++++++++++++++++++ 3 files changed, 179 insertions(+) create mode 100644 .github/workflows/pr-code-coverage.yml create mode 100644 .github/workflows/pr-code-sniff.yml create mode 100644 .github/workflows/pr-unit-tests.yml diff --git a/.github/workflows/pr-code-coverage.yml b/.github/workflows/pr-code-coverage.yml new file mode 100644 index 000000000..b98346371 --- /dev/null +++ b/.github/workflows/pr-code-coverage.yml @@ -0,0 +1,58 @@ +name: Run CI +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 + with: + fetch-depth: 100 + + - name: Checkout submodules + run: git submodule update --init --recursive + + - 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 + - name: Send code coverage to Codecov. + run: | + bash <(curl -s https://codecov.io/bash) -t 2c81bcb5-5d5d-4b82-a0d0-56bdfad8422d diff --git a/.github/workflows/pr-code-sniff.yml b/.github/workflows/pr-code-sniff.yml new file mode 100644 index 000000000..e65c5c6b9 --- /dev/null +++ b/.github/workflows/pr-code-sniff.yml @@ -0,0 +1,50 @@ +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: Checkout submodules + run: git submodule update --init --recursive + + - 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 wpadcenter_test root root 127.0.0.1 latest + + - name: Run code sniff + run: RUN_PHPCS=1 bash ./tests/bin/phpcs.sh diff --git a/.github/workflows/pr-unit-tests.yml b/.github/workflows/pr-unit-tests.yml new file mode 100644 index 000000000..22b9d29ca --- /dev/null +++ b/.github/workflows/pr-unit-tests.yml @@ -0,0 +1,71 @@ +name: Run unit tests on PR +on: + pull_request +jobs: + test: + name: PHP ${{ matrix.php }} WP ${{ matrix.wp }} + 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" ] + include: + - wp: nightly + php: '7.4' + - wp: '5.5' + php: 7.2 + - wp: '5.4' + php: 7.2 + 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: Checkout submodules + run: git submodule update --init --recursive + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + 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: Add PHP8 Compatibility. + run: | + if [ "$(php -r "echo version_compare(PHP_VERSION,'8.0','>=');")" ]; then + curl -L https://github.com/woocommerce/phpunit/archive/add-compatibility-with-php8-to-phpunit-7.zip -o /tmp/phpunit-7.5-fork.zip + unzip -d /tmp/phpunit-7.5-fork /tmp/phpunit-7.5-fork.zip + composer bin phpunit config --unset platform + composer bin phpunit config repositories.0 '{"type": "path", "url": "/tmp/phpunit-7.5-fork/phpunit-add-compatibility-with-php8-to-phpunit-7", "options": {"symlink": false}}' + composer bin phpunit require --dev -W phpunit/phpunit:@dev --ignore-platform-reqs + fi + - name: Init DB and WP + run: ./tests/bin/install.sh woo_test root root 127.0.0.1 ${{ matrix.wp }} + + - name: Run tests + run: ./vendor/bin/phpunit -c ./phpunit.xml