Skip to content

Commit 7b1ccac

Browse files
ci: finetune when specific workflow steps shall run (#321)
1 parent 01903fa commit 7b1ccac

File tree

4 files changed

+112
-82
lines changed

4 files changed

+112
-82
lines changed

.github/workflows/auto-request-review.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,29 @@ on:
88
- reopened
99

1010
jobs:
11-
auto-request-review:
12-
name: Auto Request Review
11+
should-run:
1312
runs-on: ubuntu-latest
13+
outputs:
14+
run: ${{ steps.check.outputs.run }}
1415
steps:
1516
- name: Skip for repository owner
16-
id: check_owner
17-
if: github.event.pull_request.user.id == 4849482 # martin-georgiev
17+
id: check
1818
run: |
19-
echo "Skipping auto-review request for repository owner"
20-
exit 0
19+
if [ "${{ github.event.pull_request.user.id }}" = "4849482" ]; then
20+
echo "run=false" >> $GITHUB_OUTPUT
21+
echo "::notice::Skipping auto request review - repository owner PR"
22+
else
23+
echo "run=true" >> $GITHUB_OUTPUT
24+
echo "::notice::Auto request review will execute - the PR author is not the repository owner"
25+
fi
2126
27+
auto-request-review:
28+
needs: should-run
29+
if: needs.should-run.outputs.run == 'true'
30+
runs-on: ubuntu-latest
31+
name: Request a reviewer
32+
steps:
2233
- name: Request reviews based on configuration
23-
if: ${{ always() && steps.check_owner.outcome == 'skipped' }}
2434
uses: necojackarc/auto-request-review@e89da1a8cd7c8c16d9de9c6e763290b6b0e3d424 # v0.13.0
2535
with:
2636
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/ci.yml

Lines changed: 78 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,34 @@ name: CI
22

33
on:
44
pull_request:
5-
branches: [ "main" ]
6-
paths-ignore:
7-
- '.github/**'
8-
- '**/*.md'
9-
push:
10-
branches: [ "main" ]
11-
paths-ignore:
12-
- '.github/**'
13-
- '**/*.md'
5+
branches:
6+
- main
147

158
permissions:
169
contents: read
1710

1811
jobs:
19-
tests:
20-
name: "PHP ${{ matrix.php }} + Doctrine ORM ${{ matrix.doctrine-orm }} + Doctrine Lexer ${{ matrix.doctrine-lexer }}"
12+
should-run:
2113
runs-on: ubuntu-latest
14+
outputs:
15+
run: ${{ steps.check.outputs.run }}
16+
steps:
17+
- name: Skip for release-please
18+
id: check
19+
run: |
20+
if [ "${{ github.event.pull_request.user.id }}" = "41898282" ]; then
21+
echo "run=false" >> $GITHUB_OUTPUT
22+
echo "::notice::Skipping CI checks - release-please PR"
23+
else
24+
echo "run=true" >> $GITHUB_OUTPUT
25+
echo "::notice::CI checks will execute - the PR author is not the release-please bot"
26+
fi
2227
28+
tests:
29+
needs: should-run
30+
if: needs.should-run.outputs.run == 'true'
31+
runs-on: ubuntu-latest
32+
name: "PHP ${{ matrix.php }} + Doctrine ORM ${{ matrix.doctrine-orm }} + Doctrine Lexer ${{ matrix.doctrine-lexer }}"
2333
strategy:
2434
fail-fast: false
2535
matrix:
@@ -41,70 +51,70 @@ jobs:
4151
doctrine-lexer: '2.1'
4252

4353
steps:
44-
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
54+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
4555

46-
- name: Set up PHP with PECL extension
47-
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2
48-
with:
49-
php-version: ${{ matrix.php }}
50-
coverage: xdebug
51-
extensions: ctype, json, mbstring
52-
tools: composer
56+
- name: Set up PHP with PECL extension
57+
uses: shivammathur/setup-php@9e72090525849c5e82e596468b86eb55e9cc5401 # v2
58+
with:
59+
php-version: ${{ matrix.php }}
60+
coverage: xdebug
61+
extensions: ctype, json, mbstring
62+
tools: composer
5363

54-
- name: Validate composer.json and composer.lock
55-
run: composer validate --strict
64+
- name: Validate composer.json and composer.lock
65+
run: composer validate --strict
5666

57-
- name: Cache Composer packages
58-
id: composer-cache
59-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
60-
with:
61-
path: vendor
62-
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
63-
restore-keys: |
64-
${{ runner.os }}-php-
67+
- name: Cache Composer packages
68+
id: composer-cache
69+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
70+
with:
71+
path: vendor
72+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
73+
restore-keys: |
74+
${{ runner.os }}-php-
6575
66-
- name: Install Doctrine Lexer dependency
67-
run: |
68-
if [ "${{ matrix.doctrine-lexer }}" == "1.2" ]; then
69-
composer require doctrine/lexer "~1.2" --dev --prefer-dist --no-interaction --no-progress
70-
elif [ "${{ matrix.doctrine-lexer }}" == "2.1" ]; then
71-
composer require doctrine/lexer "~2.1" --dev --prefer-dist --no-interaction --no-progress
72-
elif [ "${{ matrix.doctrine-lexer }}" == "3.0" ]; then
73-
composer require doctrine/lexer "~3.0" --dev --prefer-dist --no-interaction --no-progress
74-
else
75-
composer update --prefer-dist --no-interaction --no-progress
76-
fi
76+
- name: Install Doctrine Lexer dependency
77+
run: |
78+
if [ "${{ matrix.doctrine-lexer }}" = "1.2" ]; then
79+
composer require doctrine/lexer "~1.2" --dev --prefer-dist --no-interaction --no-progress
80+
elif [ "${{ matrix.doctrine-lexer }}" = "2.1" ]; then
81+
composer require doctrine/lexer "~2.1" --dev --prefer-dist --no-interaction --no-progress
82+
elif [ "${{ matrix.doctrine-lexer }}" = "3.0" ]; then
83+
composer require doctrine/lexer "~3.0" --dev --prefer-dist --no-interaction --no-progress
84+
else
85+
composer update --prefer-dist --no-interaction --no-progress
86+
fi
7787
78-
- name: Install Doctrine ORM dependency
79-
run: |
80-
if [ "${{ matrix.doctrine-orm }}" == "2.14" ]; then
81-
composer require doctrine/orm "~2.14" --prefer-dist --no-interaction --no-progress --with-all-dependencies
82-
elif [ "${{ matrix.doctrine-orm }}" == "2.18" ]; then
83-
composer require doctrine/orm "~2.18" --prefer-dist --no-interaction --no-progress --with-all-dependencies
84-
elif [ "${{ matrix.doctrine-orm }}" == "3.0" ]; then
85-
composer require doctrine/orm "~3.0" --prefer-dist --no-interaction --no-progress --with-all-dependencies
86-
else
87-
composer update --prefer-dist --no-interaction --no-progress
88-
fi
88+
- name: Install Doctrine ORM dependency
89+
run: |
90+
if [ "${{ matrix.doctrine-orm }}" = "2.14" ]; then
91+
composer require doctrine/orm "~2.14" --prefer-dist --no-interaction --no-progress --with-all-dependencies
92+
elif [ "${{ matrix.doctrine-orm }}" = "2.18" ]; then
93+
composer require doctrine/orm "~2.18" --prefer-dist --no-interaction --no-progress --with-all-dependencies
94+
elif [ "${{ matrix.doctrine-orm }}" = "3.0" ]; then
95+
composer require doctrine/orm "~3.0" --prefer-dist --no-interaction --no-progress --with-all-dependencies
96+
else
97+
composer update --prefer-dist --no-interaction --no-progress
98+
fi
8999
90-
- name: Run static analysis
91-
run: composer run-static-analysis
92-
continue-on-error: ${{ matrix.continue-on-error || false }}
100+
- name: Run static analysis
101+
run: composer run-static-analysis
102+
continue-on-error: ${{ matrix.continue-on-error || false }}
93103

94-
- name: Check code style
95-
run: composer check-code-style
104+
- name: Check code style
105+
run: composer check-code-style
96106

97-
- name: Check for security vulnerabilities in 3rd party dependencies
98-
run: composer audit
107+
- name: Check for security vulnerabilities in 3rd party dependencies
108+
run: composer audit
99109

100-
- name: Run test suite
101-
run: composer run-tests-with-clover
110+
- name: Run test suite
111+
run: composer run-tests-with-clover
102112

103-
- name: Upload coverage results to Coveralls
104-
if: matrix.calculate-code-coverage == true
105-
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2
106-
with:
107-
github-token: ${{ secrets.GITHUB_TOKEN }}
108-
fail-on-error: false
109-
base-path: ./var/logs/test-coverage/
110-
flag-name: "PHP ${{ matrix.php }}"
113+
- name: Upload coverage results to Coveralls
114+
if: matrix.calculate-code-coverage == true
115+
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2
116+
with:
117+
github-token: ${{ secrets.GITHUB_TOKEN }}
118+
fail-on-error: false
119+
base-path: ./var/logs/test-coverage/
120+
flag-name: "PHP ${{ matrix.php }}"

.github/workflows/release-please.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ permissions:
1414

1515
jobs:
1616
release-please:
17-
name: Create new release PR
1817
runs-on: ubuntu-latest
18+
name: Create new release PR
1919
steps:
2020
- uses: googleapis/release-please-action@a02a34c4d625f9be7cb89156071d8567266a2445 # v4
2121
with:

.github/workflows/sloth.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,28 @@ permissions:
99
checks: read
1010

1111
jobs:
12-
sloth:
12+
should-run:
1313
runs-on: ubuntu-latest
14+
outputs:
15+
run: ${{ steps.check.outputs.run }}
1416
steps:
1517
- name: Skip for release-please
16-
id: check_release_please
17-
if: github.event.pull_request.user.id == 41898282 # release-please[bot]
18+
id: check
1819
run: |
19-
echo "skip=true" >> $GITHUB_OUTPUT
20-
echo "Skipping Sloth check for release-please PR"
20+
if [ "${{ github.event.pull_request.user.id }}" = "41898282" ]; then
21+
echo "run=false" >> $GITHUB_OUTPUT
22+
echo "::notice::Skipping Sloth - release-please PR"
23+
else
24+
echo "run=true" >> $GITHUB_OUTPUT
25+
echo "::notice::Sloth will execute - the PR author is not the release-please bot"
26+
fi
2127
28+
sloth:
29+
needs: should-run
30+
if: needs.should-run.outputs.run == 'true'
31+
runs-on: ubuntu-latest
32+
steps:
2233
- name: Run Sloth
23-
if: ${{ !steps.check_release_please.outputs.skip }}
2434
uses: lendable/sloth@e1fd9a2df2549f6e64188f274bc5d3b39d7842ed # 0.2.0
2535
with:
2636
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)