-
Notifications
You must be signed in to change notification settings - Fork 1
108 lines (92 loc) · 4.13 KB
/
module-with-static-and-unit-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: Static and Unit tests
on:
push:
branches:
- main
paths-ignore:
- '**.md'
schedule:
- cron: '25 08 * * *'
workflow_dispatch:
permissions:
contents: read
env:
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
static-and-unit-test-suite:
strategy:
fail-fast: false
matrix:
# First and last patch for the current and previous minor, greatest php version
include:
- m2-version: '2.3.0'
php-version: '7.2'
magento-repository: 'https://repo.magento.com/'
- m2-version: '2.3.7'
php-version: '7.4'
magento-repository: 'https://repo.magento.com/'
- m2-version: '2.4.0'
php-version: '7.4'
magento-repository: 'https://repo.magento.com/'
- m2-version: '2.4.7'
php-version: '8.3'
magento-repository: 'https://repo.magento.com/'
name: Static and unit test suite
runs-on: ubuntu-latest
env:
EXTENSION_PACKAGE_NAME: "okaeli/magento2-category-code"
EXTENSION_NAME: "Okaeli_CategoryCode"
EXTENSION_PATH: "okaeli-category-code"
EXTENSION_GITHUB_URL: "julienloizelet/magento2-category-code"
EXTENSION_REF: "v1.1.12"
steps:
- name: Clone current repository
uses: actions/checkout@v4
- name: Install Magento with DDEV
uses: ./
with:
php_version: ${{ matrix.php-version }}
magento_version: ${{ matrix.m2-version }}
composer_auth: ${{ secrets.M2_COMPOSER_AUTH }}
magento_repository: ${{ matrix.magento-repository }}
- name: Clone ${{ env.EXTENSION_NAME }} module files
uses: actions/checkout@v4
with:
path: my-own-modules/${{ env.EXTENSION_PATH }}
repository: ${{ env.EXTENSION_GITHUB_URL }}
ref: ${{ env.EXTENSION_REF }}
- name: Prepare composer repositories
run: |
ddev composer config --unset repositories.0
ddev exec --raw composer config repositories.0 '{"type": "path", "url":"my-own-modules/${{ env.EXTENSION_PATH }}/", "canonical": true, "options": {"symlink": false}}'
ddev exec --raw composer config repositories.1 '{"type": "composer", "url":"${{ matrix.magento-repository }}", "exclude": ["${{ env.EXTENSION_PACKAGE_NAME }}"]}'
- name: Add ${{ env.EXTENSION_NAME }} as composer dependency
run: ddev composer require ${{ env.EXTENSION_PACKAGE_NAME }}:@dev --no-interaction
- name: Add Coding Standard and PHPStan for Magento 2.3
if: contains(fromJson('["2.3.0"]'),matrix.m2-version)
run: |
ddev composer require squizlabs/php_codesniffer:^3.4 magento/magento-coding-standard
ddev exec vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/
ddev composer require --dev phpstan/phpstan:0.12.23 bitexpert/phpstan-magento:v0.10.0
mkdir dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan
cp .ddev/okaeli-add-on/magento2/custom_files/phpstan.neon dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon
- name: PHP CODE SNIFFER
run: |
ddev phpcs vendor/${{ env.EXTENSION_PACKAGE_NAME }}
- name: PHP MESS DETECTOR
run: ddev phpmd vendor/${{ env.EXTENSION_PACKAGE_NAME }}
env:
CONTINUE_ON_ERROR: ${{ startsWith(matrix.m2-version, '2.3') }}
continue-on-error: ${{ env.CONTINUE_ON_ERROR == 'true'}}
- name: PHPSTAN
run: |
ddev exec cat dev/tests/static/testsuite/Magento/Test/Php/_files/phpstan/phpstan.neon
ddev phpstan vendor/${{ env.EXTENSION_PACKAGE_NAME }} --debug
- name: Fix Unit Test for Magento 2.4.6
# @see https://github.com/magento/magento2/issues/36702
if: contains(fromJson('["2.4.6"]'),matrix.m2-version)
run: sed -i 's/allure\/allure.config.php/dev\/tests\/unit\/allure\/allure.config.php/g' dev/tests/unit/phpunit.xml.dist
- name: PHP UNIT
run: |
ddev phpunit vendor/${{ env.EXTENSION_PACKAGE_NAME }}/Test/Unit