Init #2
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: Tests | |
on: [push] | |
jobs: | |
php-unit-tests: | |
name: PHP Unit Tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
php-version: [7.4, 8.0, 8.1] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.php-version }} | |
extensions: json, mbstring, xml, zip | |
coverage: pcov | |
tools: composer:v2, phpunit:9.5 | |
- name: Update project dependencies | |
env: | |
REPO_USR: ${{ secrets.REPO_USR }} | |
REPO_PSW: ${{ secrets.REPO_PSW }} | |
run: | | |
composer config repositories.0 composer https://repo.magento.com | |
composer config http-basic.repo.magento.com "$REPO_USR" "$REPO_PSW" | |
composer install --prefer-dist --no-progress --no-suggest | |
- name: Run unit tests | |
run: vendor/bin/phpunit -c phpunit.xml.dist | |
- name: Upload code coverage | |
uses: codecov/codecov-action@v2 | |
with: | |
file: ./coverage.xml | |
flags: unittests | |
fail_ci_if_error: false | |
javascript-tests: | |
name: JavaScript Tests | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
run: npm install | |
- name: Run JavaScript tests | |
run: npm test | |
- name: Upload code coverage | |
uses: codecov/codecov-action@v2 | |
with: | |
file: ./coverage/lcov.info | |
flags: javascripttests | |
fail_ci_if_error: false | |
php-integration-tests: | |
name: PHP Integration Tests | |
runs-on: ubuntu-latest | |
needs: php-unit-tests | |
if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'integration-tests') }} | |
services: | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ROOT_PASSWORD: root | |
MYSQL_DATABASE: magento_test | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Checkout Magento | |
uses: actions/checkout@v2 | |
with: | |
repository: magento/magento2 | |
path: magento | |
- name: Checkout module | |
uses: actions/checkout@v2 | |
with: | |
path: magento/app/code/Nosto/Tagging | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 7.4 | |
extensions: json, mbstring, xml, intl, gd, zip, soap, pdo_mysql | |
coverage: pcov | |
tools: composer:v2, phpunit:9.5 | |
- name: Install Magento | |
working-directory: magento | |
run: | | |
composer install --prefer-dist --no-progress | |
bin/magento setup:install --base-url=http://localhost/ --db-host=127.0.0.1 --db-name=magento_test --db-user=root --db-password=root --admin-firstname=Admin --admin-lastname=User [email protected] --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/New_York --use-rewrites=1 --backend-frontname=admin | |
- name: Run integration tests | |
working-directory: magento/app/code/Nosto/Tagging | |
run: vendor/bin/phpunit -c phpunit.integration.xml.dist |