forked from OpenMage/magento-lts
-
Notifications
You must be signed in to change notification settings - Fork 0
196 lines (177 loc) · 7.63 KB
/
check-files.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: File checker
on:
workflow_call:
outputs:
composer:
description: "Count changed Composer files"
value: ${{ jobs.check.outputs.composer }}
js:
description: "Count changed JS files"
value: ${{ jobs.check.outputs.js }}
php:
description: "Count changed PHP files"
value: ${{ jobs.check.outputs.php }}
phtml:
description: "Count changed Template files"
value: ${{ jobs.check.outputs.phtml }}
xml:
description: "Count changed XML files"
value: ${{ jobs.check.outputs.xml }}
workflow:
description: "Count changed Workflow files"
value: ${{ jobs.check.outputs.workflow }}
phpcs:
description: "Count changed PHPCS files"
value: ${{ jobs.check.outputs.phpcs }}
php-cs-fixer:
description: "Count changed PHP-CS-Fixer files"
value: ${{ jobs.check.outputs.php-cs-fixer }}
phpmd:
description: "Count changed PHPMD files"
value: ${{ jobs.check.outputs.phpmd }}
phpstan:
description: "Count changed PHPStan files"
value: ${{ jobs.check.outputs.phpstan }}
phpunit-test:
description: "Count changed PhpUnit test files"
value: ${{ jobs.check.outputs.phpunit-test }}
phpunit:
description: "Count changed PhpUnit files"
value: ${{ jobs.check.outputs.phpunit }}
# Allow manually triggering the workflow.
workflow_dispatch:
jobs:
check:
name: Changed
runs-on: [ubuntu-latest]
outputs:
composer: ${{ steps.changes-composer.outputs.composer }}
js: ${{ steps.changes-js.outputs.js }}
php: ${{ steps.changes-php.outputs.php }}
phtml: ${{ steps.all.outputs.phtml }}
xml: ${{ steps.changes-xml.outputs.xml }}
workflow: ${{ steps.changes-workflow.outputs.workflow }}
phpcs: ${{ steps.changes-phpcs.outputs.phpcs }}
php-cs-fixer: ${{ steps.changes-php-cs-fixer.outputs.php-cs-fixer }}
phpmd: ${{ steps.changes-phpstan.outputs.phpmd }}
phpstan: ${{ steps.changes-phpstan.outputs.phpstan }}
phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }}
phpunit: ${{ steps.changes-phpunit.outputs.phpunit }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Get changed files
id: changed-files-specific
uses: tj-actions/changed-files@v45
with:
files: |
composer.*
*.php
**/*.php
**/*.phtml
**/*.xml
**/*.js
.github/workflows/**
**phpcs**
**php-cs-fixer**
**phpmd**
**phpstan**
.rector.php
tests/
phpunit*
- name: Check if composer files changed
id: changes-composer
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
echo "One or more files have changed."
count="$(grep -oE "composer.*" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count Composer file(s) changed"
echo "composer=$count" >> $GITHUB_OUTPUT
- name: Check if JS files changed
id: changes-js
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "*.js" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count JS file(s) changed"
echo "js=$count" >> $GITHUB_OUTPUT
- name: Check if PHP files changed
id: changes-php
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "*.php" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHP file(s) changed"
echo "php=$count" >> $GITHUB_OUTPUT
- name: Check if Template files changed
id: changes-phtml
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "*.phtml" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count Template file(s) changed"
echo "phtml=$count" >> $GITHUB_OUTPUT
- name: Check if XML files changed
id: changes-xml
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "*.xml" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count XML file(s) changed"
echo "xml=$count" >> $GITHUB_OUTPUT
- name: Check if Workflow files changed
id: changes-workflow
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE ".github/workflows/**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count Workflow file(s) changed"
echo "workflow=$count" >> $GITHUB_OUTPUT
- name: Check if PHPCS test files changed
id: changes-phpcs
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**phpcs**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPCS file(s) changed"
echo "phpcs=$count" >> $GITHUB_OUTPUT
- name: Check if PHP-CS-Fixer files changed
id: changes-php-cs-fixer
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**php-cs-fixer**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHP-CS-Fixer file(s) changed"
echo "php-cs-fixer=$count" >> $GITHUB_OUTPUT
- name: Check if PHPMD files changed
id: changes-phpmd
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**phpmd**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPMD file(s) changed"
echo "phpmd=$count" >> $GITHUB_OUTPUT
- name: Check if PHPStan files changed
id: changes-phpstan
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**phpstan**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPStan file(s) changed"
echo "phpstan=$count" >> $GITHUB_OUTPUT
- name: Check if PHPUnit test files changed
id: changes-phpunit-test
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "tests/" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count UnitTest test file(s) changed"
echo "phpunit-test=$count" >> $GITHUB_OUTPUT
- name: Check if PHPUnit files changed
id: changes-phpunit
if: steps.changed-files-specific.outputs.any_modified == 'true'
run: |
count="$(grep -oE "**phpunit**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
echo "$count PHPUnit file(s) changed"
echo "phpunit=$count" >> $GITHUB_OUTPUT