Skip to content

Commit fbfe321

Browse files
authored
Updated workflows - use cache (#4761)
* Updated workflows - use cache * revert test * typo * workflow * .gitignore * rector after phpstan
1 parent 82882a9 commit fbfe321

File tree

10 files changed

+92
-18
lines changed

10 files changed

+92
-18
lines changed

.github/workflows/check-files.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ on:
3434
description: "Count changed PHPStan files"
3535
value: ${{ jobs.check.outputs.phpstan }}
3636
phpunit-test:
37-
description: "Count changed PhpUnit test files"
37+
description: "Count changed PHPUnit test files"
3838
value: ${{ jobs.check.outputs.phpunit-test }}
3939
phpunit:
40-
description: "Count changed PhpUnit files"
40+
description: "Count changed PHPUnit files"
4141
value: ${{ jobs.check.outputs.phpunit }}
4242
# Allow manually triggering the workflow.
4343
workflow_dispatch:

.github/workflows/php-cs-fixer.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,20 @@ jobs:
3333
- name: Install dependencies
3434
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*
3535

36+
- name: Restore result cache
37+
uses: actions/cache/restore@v4
38+
with:
39+
path: .php-cs-fixer.cache
40+
key: php-cs-fixer-result-cache-${{ github.run_id }}
41+
restore-keys: |
42+
php-cs-fixer-result-cache-
43+
3644
- name: PHP-CS-Fixer
3745
run: php vendor/bin/php-cs-fixer fix --diff --dry-run
46+
47+
- name: Save result cache
48+
uses: actions/cache/save@v4
49+
if: always()
50+
with:
51+
path: .php-cs-fixer.cache
52+
key: php-cs-fixer-result-cache-${{ github.run_id }}

.github/workflows/phpcs.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,20 @@ jobs:
3333
- name: Install dependencies
3434
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*
3535

36+
- name: Restore result cache
37+
uses: actions/cache/restore@v4
38+
with:
39+
path: .phpcs.result.cache
40+
key: phpcs-result-cache-${{ github.run_id }}
41+
restore-keys: |
42+
phpcs-result-cache-
43+
3644
- name: PHPCodeSniffer
37-
run: php vendor/bin/phpcs -s -p --report=full --standard=.phpcs.dist.xml
45+
run: php vendor/bin/phpcs -s -p --cache=.phpcs.result.cache --report=full --standard=.phpcs.dist.xml
46+
47+
- name: Save result cache
48+
uses: actions/cache/save@v4
49+
if: always()
50+
with:
51+
path: .phpcs.result.cache
52+
key: phpcs-result-cache-${{ github.run_id }}

.github/workflows/phpmd.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,20 @@ jobs:
2828
- name: Install dependencies
2929
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*
3030

31+
- name: Restore result cache
32+
uses: actions/cache/restore@v4
33+
with:
34+
path: .phpmd.result-cache.php
35+
key: phpmd-result-cache-${{ github.run_id }}
36+
restore-keys: |
37+
phpmd-result-cache-
38+
3139
- name: PHPMD
32-
run: php vendor/bin/phpmd app/code/core/Mage/ github .phpmd.dist.xml --baseline-file .phpmd.dist.baseline.xml
40+
run: php vendor/bin/phpmd app/code/core/Mage/ github .phpmd.dist.xml --cache --baseline-file .phpmd.dist.baseline.xml
41+
42+
- name: Save result cache
43+
uses: actions/cache/save@v4
44+
if: always()
45+
with:
46+
path: .phpmd.result-cache.php
47+
key: phpmd-result-cache-${{ github.run_id }}

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ jobs:
4848
if: always()
4949
with:
5050
path: .phpstan.cache
51-
key: phpstan-result-cache-${{ github.run_id }}
51+
key: phpstan-result-cache-${{ github.run_id }}

.github/workflows/phpunit.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,28 +86,35 @@ jobs:
8686
--enable_charts 'yes' \
8787
--skip_url_validation 'yes'
8888
89+
- name: Restore result cache
90+
uses: actions/cache/restore@v4
91+
with:
92+
path: .phpunit.result.cache
93+
key: phpunit-result-cache-${{ matrix.php-versions }}-${{ matrix.mysql-version }}-${{ github.run_id }}
94+
restore-keys: |
95+
phpunit-result-cache-
96+
8997
- name: Run phpUnit
9098
run: php vendor/bin/phpunit --configuration .phpunit.dist.xml
9199

100+
- name: Save result cache
101+
uses: actions/cache/save@v4
102+
if: always()
103+
with:
104+
path: .phpunit.result.cache
105+
key: phpunit-result-cache-${{ matrix.php-versions }}-${{ matrix.mysql-version }}-${{ github.run_id }}
106+
92107
- name: Publish Unit Test Results
93108
uses: EnricoMi/publish-unit-test-result-action@v2
94109
if: always()
95110
with:
96111
github_token: ${{ secrets.GITHUB_TOKEN }}
97112
files: tests/logging/*.xml
98113

99-
- name: prepare SonarCloud Scan Data
100-
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }}
101-
run: |
102-
head tests/coverage/clover.xml
103-
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' tests/logging/junit.xml
104-
sed -i 's@'$GITHUB_WORKSPACE'/@/github/workspace/@g' tests/coverage/clover.xml
105-
head ./tests/coverage/clover.xml
106-
107114
- name: SonarCloud Scan
108115
uses: SonarSource/sonarcloud-github-action@master
109116
continue-on-error: true
110-
if: ${{ (matrix.php-versions == '7.4') && (matrix.mysql-version == '5.7') }} && SONAR_TOKEN
117+
if: ${{ (matrix.php-versions == '8.1') && (matrix.mysql-version == '5.7') }} && SONAR_TOKEN
111118
with:
112119
args: >
113120
-Dproject.settings=tests/sonar-project.properties

.github/workflows/rector.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,20 @@ jobs:
3333
- name: Install dependencies
3434
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*
3535

36+
- name: Restore result cache
37+
uses: actions/cache/restore@v4
38+
with:
39+
path: .rector.result.cache
40+
key: rector-result-cache-${{ github.run_id }}
41+
restore-keys: |
42+
rector-result-cache-
43+
3644
- name: Rector
3745
run: php vendor/bin/rector process --config .rector.php --dry-run
46+
47+
- name: Save result cache
48+
uses: actions/cache/save@v4
49+
if: always()
50+
with:
51+
path: .rector.result.cache
52+
key: rector-result-cache-${{ github.run_id }}

.github/workflows/workflow.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,14 @@ jobs:
121121

122122
rector:
123123
name: Rector
124-
needs: [check, php-cs-fixer]
124+
needs: [check, php-cs-fixer, phpstan]
125125
if: |
126126
needs.check.outputs.php > 0 ||
127127
needs.check.outputs.workflow > 0
128128
uses: ./.github/workflows/rector.yml
129129

130-
# DOES NOT run by default
131-
# runs on schedule or when workflow or unit tests changed
132130
unit_tests:
133-
name: Unit Tests (OpenMage)
131+
name: PHPUnit Tests
134132
needs: [check, php-cs-fixer]
135133
if: |
136134
needs.check.outputs.php > 0 ||

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,6 @@ app/etc/includes/ddev.xhgui.php
113113

114114
# local development
115115
.localdev
116+
117+
# rector
118+
.rector.result.cache

.rector.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
2+
23
declare(strict_types=1);
34

5+
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
46
use Rector\CodeQuality\Rector as CodeQuality;
57
use Rector\CodingStyle\Rector as CodingStyle;
68
use Rector\Config\RectorConfig;
@@ -19,6 +21,10 @@
1921

2022
try {
2123
return RectorConfig::configure()
24+
->withCache(
25+
cacheDirectory: '.rector.result.cache',
26+
cacheClass: FileCacheStorage::class,
27+
)
2228
->withPhpSets(
2329
php74: true,
2430
)

0 commit comments

Comments
 (0)