Skip to content

Build

Build #173

Workflow file for this run

name: Build
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '0 2 * * 0' # Weekly on Sundays at 02:00
jobs:
build:
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: false
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
ports:
- 3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
runs-on: ubuntu-latest
strategy:
matrix:
php-version: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
- name: Checkout code
uses: actions/checkout@v2
with:
path: multisafepay
- name: Get latest release tag of WooCommerce
id: latestrelease
run: |
echo "releasetag=$(curl -s https://api.github.com/repos/woocommerce/woocommerce/releases/latest | jq '.tag_name' | sed 's/\"//g')" >> $GITHUB_OUTPUT
- name: Download WooCommerce
run: |
RELEASE_TAG="${{ steps.latestrelease.outputs.releasetag }}"
BASE_URL="https://github.com/woocommerce/woocommerce/releases/download/${RELEASE_TAG}"
FILENAMES=("woocommerce.${RELEASE_TAG}.zip" "woocommerce.zip")
for filename in "${FILENAMES[@]}"; do
# --head: Fetches only the headers
# --fail: Returns an error code for HTTP responses with status 400 or higher
if curl --output /dev/null --silent --head --fail "${BASE_URL}/${filename}"; then
echo "Downloading ${filename}"
curl -L -o woocommerce.zip "${BASE_URL}/${filename}"
break
fi
done
if [ ! -f woocommerce.zip ] || [ ! -s woocommerce.zip ]; then
echo "Failed to download WooCommerce release. Script will be exited."
exit 1
fi
- name: Unzip WooCommerce
run: unzip woocommerce.zip
- name: Install composer for plugin
working-directory: multisafepay
run: composer install --dev
- name: Setup test environment
working-directory: multisafepay
shell: bash
run: bin/install-wp-tests.sh woocommerce_test root password 127.0.0.1:${{ job.services.mysql.ports['3306'] }}
- name: Run PHPUnit
working-directory: multisafepay
run: php vendor/bin/phpunit --coverage-clover=coverage.xml
- name: upload code coverage
working-directory: multisafepay
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
if: matrix.php-version == '7.4'