Skip to content

Commit 6a3a69e

Browse files
authored
ci: Re-use actions (#909)
1 parent 4cf769c commit 6a3a69e

File tree

7 files changed

+64
-77
lines changed

7 files changed

+64
-77
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: 'Install a vendor-bin tool'
2+
3+
description: >
4+
Install a tool installed via bamarni/composer-bin-plugin and runs the associated Makefile command to ensure the
5+
target is up to date.
6+
7+
inputs:
8+
vendor-bin-tool:
9+
required: true
10+
type: string
11+
makefile-command:
12+
required: true
13+
type: string
14+
15+
runs:
16+
using: composite
17+
steps:
18+
- name: Install PHP-CS-Fixer
19+
uses: ramsey/composer-install@v2
20+
with:
21+
working-directory: 'vendor-bin/${{ inputs.vendor-bin-tool }}'
22+
23+
- name: Ensure PHP-CS-Fixer Makefile target is up to date
24+
run: make ${{ inputs.makefile-command }}
25+
shell: sh
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: 'Install Composer dependencies'
2+
3+
description: >
4+
Install the dependencies installed via Composer.
5+
6+
runs:
7+
using: composite
8+
steps:
9+
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
10+
- name: Configure composer root version
11+
run: |
12+
. ./.composer-root-version
13+
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
14+
shell: sh
15+
16+
- name: Install Composer dependencies
17+
uses: ramsey/composer-install@v2

.github/workflows/composer-root-version.yaml

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,17 @@ jobs:
2828
tools: composer
2929
coverage: none
3030

31-
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
32-
- name: Configure composer root version
33-
run: |
34-
source .composer-root-version
35-
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
36-
37-
- name: Install the Composer (root) dependencies
38-
uses: ramsey/composer-install@v2
31+
- name: Install Composer dependencies
32+
uses: ./.github/actions/install-vendor
3933

4034
- name: Ensure that the root dependencies are updated correctly
4135
run: make vendor_install
4236

4337
- name: Install PHP-CS-Fixer
44-
uses: ramsey/composer-install@v2
38+
uses: ./.github/actions/install-tool
4539
with:
46-
working-directory: 'vendor-bin/php-cs-fixer'
47-
48-
- name: Ensure that PHP-CS-Fixer dependencies are updated correctly
49-
run: make php_cs_fixer_install
40+
vendor-bin-tool: php-cs-fixer
41+
makefile-command: php_cs_fixer_install
5042

5143
- name: Install the Composer dependencies
5244
uses: ramsey/composer-install@v2

.github/workflows/e2e-tests.yaml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,8 @@ jobs:
3939
tools: composer
4040
coverage: none
4141

42-
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
43-
- name: Configure composer root version
44-
run: |
45-
source .composer-root-version
46-
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
47-
4842
- name: Install Composer dependencies
49-
uses: ramsey/composer-install@v2
43+
uses: ./.github/actions/install-vendor
5044

5145
- name: Build PHAR
5246
run: make build
@@ -121,13 +115,8 @@ jobs:
121115
# This is necessary when installing a tool with a specific version
122116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123117

124-
- name: Configure composer root version
125-
run: |
126-
source .composer-root-version
127-
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
128-
129118
- name: Install Composer dependencies
130-
uses: ramsey/composer-install@v2
119+
uses: ./.github/actions/install-vendor
131120

132121
- name: Retrieve built PHAR
133122
uses: actions/download-artifact@v3

.github/workflows/lint.yaml

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,14 @@ jobs:
2828
tools: composer
2929
coverage: none
3030

31-
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
32-
- name: Configure composer root version
33-
run: |
34-
source .composer-root-version
35-
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
36-
3731
- name: Install Composer dependencies
38-
uses: ramsey/composer-install@v2
32+
uses: ./.github/actions/install-vendor
3933

4034
- name: Install PHP-CS-Fixer
41-
uses: ramsey/composer-install@v2
35+
uses: ./.github/actions/install-tool
4236
with:
43-
working-directory: 'vendor-bin/php-cs-fixer'
44-
45-
- name: Ensure PHP-CS-Fixer Makefile target is up to date
46-
run: make php_cs_fixer_install
37+
vendor-bin-tool: php-cs-fixer
38+
makefile-command: php_cs_fixer_install
4739

4840
- run: make cs_lint
4941
phpstan:
@@ -60,22 +52,14 @@ jobs:
6052
tools: composer
6153
coverage: none
6254

63-
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
64-
- name: Configure composer root version
65-
run: |
66-
source .composer-root-version
67-
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
68-
6955
- name: Install Composer dependencies
70-
uses: ramsey/composer-install@v2
56+
uses: ./.github/actions/install-vendor
7157

7258
- name: Install PHPStan
73-
uses: ramsey/composer-install@v2
59+
uses: ./.github/actions/install-tool
7460
with:
75-
working-directory: 'vendor-bin/phpstan'
76-
77-
- name: Ensure PHPStan Makefile target is up to date
78-
run: make phpstan_install
61+
vendor-bin-tool: phpstan
62+
makefile-command: phpstan_install
7963

8064
- run: make phpstan
8165
rector:
@@ -92,22 +76,14 @@ jobs:
9276
tools: composer
9377
coverage: none
9478

95-
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
96-
- name: Configure composer root version
97-
run: |
98-
source .composer-root-version
99-
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
100-
10179
- name: Install Composer dependencies
102-
uses: ramsey/composer-install@v2
80+
uses: ./.github/actions/install-vendor
10381

104-
- name: Install PHPStan
105-
uses: ramsey/composer-install@v2
82+
- name: Install Rector
83+
uses: ./.github/actions/install-tool
10684
with:
107-
working-directory: 'vendor-bin/rector'
108-
109-
- name: Ensure PHPStan Makefile target is up to date
110-
run: make rector_install
85+
vendor-bin-tool: rector
86+
makefile-command: rector_install
11187

11288
- run: make rector_lint
11389

.github/workflows/release.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,8 @@ jobs:
3737
tools: composer
3838
coverage: none
3939

40-
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
41-
- name: Configure composer root version
42-
run: |
43-
source .composer-root-version
44-
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
45-
4640
- name: Install Composer dependencies
47-
uses: ramsey/composer-install@v2
41+
uses: ./.github/actions/install-vendor
4842

4943
- name: Configure the PHP platform
5044
run: composer config platform.php $(php -r 'echo phpversion();') && composer update --lock

.github/workflows/tests.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,8 @@ jobs:
8282
tools: composer
8383
coverage: none
8484

85-
# https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions#setting-an-environment-variable
86-
- name: Configure composer root version
87-
run: |
88-
source .composer-root-version
89-
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> $GITHUB_ENV
90-
9185
- name: Install Composer dependencies
92-
uses: ramsey/composer-install@v2
86+
uses: ./.github/actions/install-vendor
9387

9488
- name: Run tests
9589
run: make phpunit

0 commit comments

Comments
 (0)