-
Notifications
You must be signed in to change notification settings - Fork 9
84 lines (84 loc) · 2.9 KB
/
Copy pathcode-validation.yml
File metadata and controls
84 lines (84 loc) · 2.9 KB
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
name: Run code validation checks
on:
pull_request:
jobs:
changed-files:
runs-on: ubuntu-latest
name: Gather Changelist
strategy:
matrix:
fetch-depth:
- 0
base-branch:
- "staging"
outputs:
all: ${{ steps.changes.outputs.all }}
php: ${{ steps.changes.outputs.php }}
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: ${{ matrix.fetch-depth }}
- name: Get changed files
id: changes
run: |
BASE_SHA="${{ github.event.before }}"
if [ "$BASE_SHA" = "0000000000000000000000000000000000000000" ]; then
BASE_SHA="${{ matrix.base-branch }}"
fi
if [[ ! -z "${{ github.event.pull_request.base.sha }}" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
fi
echo "all=$(git diff --name-only --diff-filter=ACMRT $BASE_SHA ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT
echo "php=$(git diff --name-only --diff-filter=ACMRT $BASE_SHA ${{ github.sha }} | grep -E '.ph(p|tml)$' | xargs)" >> $GITHUB_OUTPUT
validate-php:
runs-on: ubuntu-latest
name: Run php code validation and Unit tests
needs: changed-files
if: ${{needs.changed-files.outputs.php}}
strategy:
matrix:
node-version:
- 20
php-version: ["8.1", "8.2", "8.3", "8.4"]
dependencies:
- "highest"
composer-options:
- "--no-plugins --no-progress"
steps:
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
- name: Check out code
uses: actions/checkout@v4
- name: Setup Php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
ini-file: development
tools: composer:2.2, cs2pr
env:
COMPOSER_AUTH_JSON: |
{
"http-basic": {
"repo.magento.com": {
"username": "${{ secrets.REPO_MAGENTO_USER }}",
"password": "${{ secrets.REPO_MAGENTO_PASSWORD }}"
}
}
}
- name: Validate Composer Files
run: composer validate
- name: Run Composer install
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-options }}"
- name: Detect PhpCs violations
run: |
vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/,../../phpcompatibility/php-compatibility,../../magento/php-compatibility-fork
vendor/bin/phpcs --standard=Magento2 -q --report=checkstyle ${{needs.changed-files.outputs.php}} | cs2pr --graceful-warnings
- name: Run Unit test
run: |
vendor/bin/phpunit Test/Unit/Model/