Skip to content

Commit

Permalink
Merge pull request #8 from integer-net/phpunit-action
Browse files Browse the repository at this point in the history
Refactor Github Actions
  • Loading branch information
schmengler authored Oct 28, 2021
2 parents 5386b95 + 799ce8a commit a1e89f9
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 152 deletions.
1 change: 0 additions & 1 deletion .github/autoload-tests.sh

This file was deleted.

11 changes: 9 additions & 2 deletions .github/phpunit9-integration.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.2/phpunit.xsd"
colors="true"
columns="max"
beStrictAboutTestsThatDoNotTestAnything="false"
Expand Down Expand Up @@ -48,4 +48,11 @@
<listener class="Magento\TestFramework\Event\PhpUnit"/>
<listener class="Magento\TestFramework\ErrorLog\Listener"/>
</listeners>
</phpunit>
<logging>
<!-- need to specify absolute path to mounted directory, because Magento is installed in /tmp/m2 -->
<log type="junit" target="/github/workspace/var/test-results/integration.xml"/>
<!-- for phpunit 9.5 change to:
<junit outputFile="/github/workspace/var/test-results/integration.xml"/>
-->
</logging>
</phpunit>
28 changes: 0 additions & 28 deletions .github/phpunit9-unit.xml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/coding-standards.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/integration.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .github/workflows/mess-detector.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/phpstan.yml

This file was deleted.

139 changes: 139 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Tests

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
phpstan:

name: PHPStan Static Analysis
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer global config http-basic.repo.magento.com ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }} ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }} && composer install --prefer-dist --no-progress

- name: Run PHPStan
run: vendor/bin/phpstan --no-progress

unit-tests:

name: Unit tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl
coverage: xdebug

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer global config http-basic.repo.magento.com ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }} ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }} && composer install --prefer-dist --no-progress

- name: Run test suite
run: composer test

- name: Upload Unit Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Unit Test Results
path: var/test-results/unit.xml

integration-tests:
name: Magento 2 Integration Tests
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
es:
image: docker.io/wardenenv/elasticsearch:7.8
ports:
- 9200:9200
env:
'discovery.type': single-node
'xpack.security.enabled': false
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v2
- name: M2 Integration Tests with Magento 2 (Php7.4)
uses: extdn/github-actions-m2/magento-integration-tests/7.4@master
with:
module_name: IntegerNet_ShippingPreselection
composer_name: integer-net/magento2-shippingpreselection
ce_version: '2.4.3'
phpunit_file: .github/phpunit9-integration.xml
- name: Upload Integration Test Results
if: always()
uses: actions/upload-artifact@v2
with:
name: Integration Test Results
path: var/test-results/integration.xml

phpmd:
name: Magento 2 Mess Detector
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: extdn/github-actions-m2/magento-mess-detector@master

publish-test-results:
name: "Publish Tests Results"
needs:
- unit-tests
- integration-tests
runs-on: ubuntu-latest
if: always()

steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
files: artifacts/**/*.xml

21 changes: 0 additions & 21 deletions .github/workflows/unit.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/composer.lock
/tests/phpunit.xml
.phpunit.result.cache
/var
10 changes: 6 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
"php": "~7.3||~7.4",
"magento/framework": "^103.0.0",
"magento/module-quote": "^101.2",
"magento/module-customer": "^103.0",
"bkubicki/magento2-unit-tests-doubles": "^1.2.0"

"magento/module-customer": "^103.0"
},
"require-dev": {
"roave/security-advisories": "dev-master",
Expand All @@ -49,9 +47,13 @@
"phpstan/phpstan": "^0.12.0",
"squizlabs/php_codesniffer": "^3.5",
"magento/magento-coding-standard": "@dev",
"bkubicki/magento2-unit-tests-doubles": "^1.2.0"
"bkubicki/magento2-unit-tests-doubles": "^1.2.0",
"bitexpert/phpstan-magento": "^0.9.0"
},
"scripts": {
"test": [
"vendor/bin/phpunit tests/unit --log-junit=var/test-results/unit.xml"
],
"post-install-cmd": [
"vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/"
],
Expand Down
11 changes: 8 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
parameters:
level: 6
level: 1
paths:
- src
- tests
ignoreErrors:
- '#(class|type) Magento\\TestFramework#i'
- '#(class|type) Magento\\\S*Factory#i'
- '#(method) Magento\\Framework\\Api\\ExtensionAttributesInterface#i'
bootstrapFiles:
- vendor/bitexpert/phpstan-magento/autoload.php
magento:
# usually not recommended to disable ;-)
checkServiceContracts: false
includes:
- vendor/bitexpert/phpstan-magento/extension.neon

0 comments on commit a1e89f9

Please sign in to comment.