Skip to content

Commit a1e89f9

Browse files
authored
Merge pull request #8 from integer-net/phpunit-action
Refactor Github Actions
2 parents 5386b95 + 799ce8a commit a1e89f9

12 files changed

+163
-152
lines changed

.github/autoload-tests.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/phpunit9-integration.xml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.1/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.2/phpunit.xsd"
44
colors="true"
55
columns="max"
66
beStrictAboutTestsThatDoNotTestAnything="false"
@@ -48,4 +48,11 @@
4848
<listener class="Magento\TestFramework\Event\PhpUnit"/>
4949
<listener class="Magento\TestFramework\ErrorLog\Listener"/>
5050
</listeners>
51-
</phpunit>
51+
<logging>
52+
<!-- need to specify absolute path to mounted directory, because Magento is installed in /tmp/m2 -->
53+
<log type="junit" target="/github/workspace/var/test-results/integration.xml"/>
54+
<!-- for phpunit 9.5 change to:
55+
<junit outputFile="/github/workspace/var/test-results/integration.xml"/>
56+
-->
57+
</logging>
58+
</phpunit>

.github/phpunit9-unit.xml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/coding-standards.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/integration.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/mess-detector.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/phpstan.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
phpstan:
11+
12+
name: PHPStan Static Analysis
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: '7.4'
22+
23+
- name: Validate composer.json and composer.lock
24+
run: composer validate --strict
25+
26+
- name: Cache Composer packages
27+
id: composer-cache
28+
uses: actions/cache@v2
29+
with:
30+
path: vendor
31+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
32+
restore-keys: |
33+
${{ runner.os }}-php-
34+
35+
- name: Install dependencies
36+
run: composer global config http-basic.repo.magento.com ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }} ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }} && composer install --prefer-dist --no-progress
37+
38+
- name: Run PHPStan
39+
run: vendor/bin/phpstan --no-progress
40+
41+
unit-tests:
42+
43+
name: Unit tests
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v2
48+
49+
- name: Setup PHP
50+
uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: '7.4'
53+
extensions: mbstring, intl
54+
coverage: xdebug
55+
56+
- name: Cache Composer packages
57+
id: composer-cache
58+
uses: actions/cache@v2
59+
with:
60+
path: vendor
61+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
62+
restore-keys: |
63+
${{ runner.os }}-php-
64+
65+
- name: Install dependencies
66+
run: composer global config http-basic.repo.magento.com ${{ secrets.MAGENTO_MARKETPLACE_USERNAME }} ${{ secrets.MAGENTO_MARKETPLACE_PASSWORD }} && composer install --prefer-dist --no-progress
67+
68+
- name: Run test suite
69+
run: composer test
70+
71+
- name: Upload Unit Test Results
72+
if: always()
73+
uses: actions/upload-artifact@v2
74+
with:
75+
name: Unit Test Results
76+
path: var/test-results/unit.xml
77+
78+
integration-tests:
79+
name: Magento 2 Integration Tests
80+
runs-on: ubuntu-latest
81+
services:
82+
mysql:
83+
image: mysql:5.7
84+
env:
85+
MYSQL_ROOT_PASSWORD: root
86+
ports:
87+
- 3306:3306
88+
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
89+
es:
90+
image: docker.io/wardenenv/elasticsearch:7.8
91+
ports:
92+
- 9200:9200
93+
env:
94+
'discovery.type': single-node
95+
'xpack.security.enabled': false
96+
ES_JAVA_OPTS: "-Xms64m -Xmx512m"
97+
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3
98+
steps:
99+
- uses: actions/checkout@v2
100+
- name: M2 Integration Tests with Magento 2 (Php7.4)
101+
uses: extdn/github-actions-m2/magento-integration-tests/7.4@master
102+
with:
103+
module_name: IntegerNet_ShippingPreselection
104+
composer_name: integer-net/magento2-shippingpreselection
105+
ce_version: '2.4.3'
106+
phpunit_file: .github/phpunit9-integration.xml
107+
- name: Upload Integration Test Results
108+
if: always()
109+
uses: actions/upload-artifact@v2
110+
with:
111+
name: Integration Test Results
112+
path: var/test-results/integration.xml
113+
114+
phpmd:
115+
name: Magento 2 Mess Detector
116+
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/checkout@v2
119+
- uses: extdn/github-actions-m2/magento-mess-detector@master
120+
121+
publish-test-results:
122+
name: "Publish Tests Results"
123+
needs:
124+
- unit-tests
125+
- integration-tests
126+
runs-on: ubuntu-latest
127+
if: always()
128+
129+
steps:
130+
- name: Download Artifacts
131+
uses: actions/download-artifact@v2
132+
with:
133+
path: artifacts
134+
135+
- name: Publish Test Results
136+
uses: EnricoMi/publish-unit-test-result-action@v1
137+
with:
138+
files: artifacts/**/*.xml
139+

.github/workflows/unit.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/composer.lock
44
/tests/phpunit.xml
55
.phpunit.result.cache
6+
/var

0 commit comments

Comments
 (0)