Skip to content

Commit 0c3ab0f

Browse files
committed
Split out dependency install steps into composite action
Fix incorrect action paths shell must be defined for run steps in action.yml
1 parent 78d73d5 commit 0c3ab0f

File tree

2 files changed

+78
-134
lines changed

2 files changed

+78
-134
lines changed

.github/workflows/tests.yml

Lines changed: 26 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -256,40 +256,13 @@ jobs:
256256
run: .github/setup-database.sh "$DB" "$MYISAM"
257257
working-directory: ./phpBB3
258258

259-
- name: Set up Node.js
260-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
261-
uses: actions/setup-node@v4
259+
- name: Install Dependencies
260+
uses: phpbb-extensions/test-framework/actions/install-dependencies@3.3.x-experimental
262261
with:
263-
node-version: 20
264-
265-
- name: Cache NPM dependencies
266-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
267-
uses: actions/cache@v4
268-
with:
269-
path: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}/node_modules
270-
key: ${{ runner.os }}-node-${{ hashFiles('phpBB3/phpBB/ext/${{ env.EXTNAME }}/package-lock.json') }}
271-
restore-keys: |
272-
${{ runner.os }}-node-
273-
274-
- name: Run npm ci
275-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
276-
run: npm ci
277-
working-directory: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}
278-
279-
- name: Cache Composer dependencies
280-
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
281-
uses: actions/cache@v4
282-
with:
283-
path: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}/vendor
284-
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('phpBB3/phpBB/ext/${{ env.EXTNAME }}/composer.lock') }}
285-
restore-keys: |
286-
${{ runner.os }}-composer-${{ matrix.php }}-
287-
${{ runner.os }}-composer-
288-
289-
- name: Install Composer dependencies
290-
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
291-
run: composer install
292-
working-directory: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}
262+
RUN_NPM_INSTALL: ${{ inputs.RUN_NPM_INSTALL }}
263+
RUN_COMPOSER_INSTALL: ${{ inputs.RUN_COMPOSER_INSTALL }}
264+
EXTNAME: ${{ env.EXTNAME }}
265+
PHP_VERSION: ${{ matrix.php }}
293266

294267
- name: Setup PHPUnit files
295268
env:
@@ -431,40 +404,13 @@ jobs:
431404
run: .github/setup-database.sh "$DB" "$MYISAM"
432405
working-directory: ./phpBB3
433406

434-
- name: Set up Node.js
435-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
436-
uses: actions/setup-node@v4
407+
- name: Install Dependencies
408+
uses: phpbb-extensions/test-framework/actions/install-dependencies@3.3.x-experimental
437409
with:
438-
node-version: 20
439-
440-
- name: Cache NPM dependencies
441-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
442-
uses: actions/cache@v4
443-
with:
444-
path: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}/node_modules
445-
key: ${{ runner.os }}-node-${{ hashFiles('phpBB3/phpBB/ext/${{ env.EXTNAME }}/package-lock.json') }}
446-
restore-keys: |
447-
${{ runner.os }}-node-
448-
449-
- name: Run npm ci
450-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
451-
run: npm ci
452-
working-directory: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}
453-
454-
- name: Cache Composer dependencies
455-
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
456-
uses: actions/cache@v4
457-
with:
458-
path: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}/vendor
459-
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('phpBB3/phpBB/ext/${{ env.EXTNAME }}/composer.lock') }}
460-
restore-keys: |
461-
${{ runner.os }}-composer-${{ matrix.php }}-
462-
${{ runner.os }}-composer-
463-
464-
- name: Install Composer dependencies
465-
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
466-
run: composer install
467-
working-directory: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}
410+
RUN_NPM_INSTALL: ${{ inputs.RUN_NPM_INSTALL }}
411+
RUN_COMPOSER_INSTALL: ${{ inputs.RUN_COMPOSER_INSTALL }}
412+
EXTNAME: ${{ env.EXTNAME }}
413+
PHP_VERSION: ${{ matrix.php }}
468414

469415
- name: Setup PHPUnit files
470416
run: mkdir -p "phpBB/ext/$EXTNAME/.github" && cp .github/phpunit* "$_"
@@ -577,40 +523,13 @@ jobs:
577523
run: .github/setup-database.sh "$DB" "$MYISAM"
578524
working-directory: ./phpBB3
579525

580-
- name: Set up Node.js
581-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
582-
uses: actions/setup-node@v4
583-
with:
584-
node-version: 20
585-
586-
- name: Cache NPM dependencies
587-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
588-
uses: actions/cache@v4
589-
with:
590-
path: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}/node_modules
591-
key: ${{ runner.os }}-node-${{ hashFiles('phpBB3/phpBB/ext/${{ env.EXTNAME }}/package-lock.json') }}
592-
restore-keys: |
593-
${{ runner.os }}-node-
594-
595-
- name: Run npm ci
596-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
597-
run: npm ci
598-
working-directory: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}
599-
600-
- name: Cache Composer dependencies
601-
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
602-
uses: actions/cache@v4
526+
- name: Install Dependencies
527+
uses: phpbb-extensions/test-framework/actions/install-dependencies@3.3.x-experimental
603528
with:
604-
path: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}/vendor
605-
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('phpBB3/phpBB/ext/${{ env.EXTNAME }}/composer.lock') }}
606-
restore-keys: |
607-
${{ runner.os }}-composer-${{ matrix.php }}-
608-
${{ runner.os }}-composer-
609-
610-
- name: Install Composer dependencies
611-
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
612-
run: composer install
613-
working-directory: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}
529+
RUN_NPM_INSTALL: ${{ inputs.RUN_NPM_INSTALL }}
530+
RUN_COMPOSER_INSTALL: ${{ inputs.RUN_COMPOSER_INSTALL }}
531+
EXTNAME: ${{ env.EXTNAME }}
532+
PHP_VERSION: ${{ matrix.php }}
614533

615534
- name: Setup PHPUnit files
616535
run: mkdir -p "phpBB/ext/$EXTNAME/.github" && cp .github/phpunit* "$_"
@@ -733,48 +652,21 @@ jobs:
733652
Set-MpPreference -ExclusionPath "${env:PGDATA}" # Exclude PGDATA directory from Windows Defender
734653
Set-MpPreference -DisableRealtimeMonitoring $true
735654
736-
- name: Set up Node.js
737-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
738-
uses: actions/setup-node@v4
739-
with:
740-
node-version: 20
741-
742-
- name: Cache NPM dependencies
743-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
744-
uses: actions/cache@v4
655+
- name: Install Dependencies
656+
uses: phpbb-extensions/test-framework/actions/install-dependencies@3.3.x-experimental
745657
with:
746-
path: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}/node_modules
747-
key: ${{ runner.os }}-node-${{ hashFiles('phpBB3/phpBB/ext/${{ env.EXTNAME }}/package-lock.json') }}
748-
restore-keys: |
749-
${{ runner.os }}-node-
750-
751-
- name: Run npm ci
752-
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
753-
run: npm ci
754-
working-directory: .\phpBB3\phpBB\ext\${{ env.EXTNAME }}
755-
756-
- name: Cache Composer dependencies
757-
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
758-
uses: actions/cache@v4
759-
with:
760-
path: ./phpBB3/phpBB/ext/${{ env.EXTNAME }}/vendor
761-
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('phpBB3/phpBB/ext/${{ env.EXTNAME }}/composer.lock') }}
762-
restore-keys: |
763-
${{ runner.os }}-composer-${{ matrix.php }}-
764-
${{ runner.os }}-composer-
765-
766-
- name: Install Composer dependencies
767-
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
768-
run: composer install
769-
working-directory: .\phpBB3\phpBB\ext\${{ env.EXTNAME }}
658+
RUN_NPM_INSTALL: ${{ inputs.RUN_NPM_INSTALL }}
659+
RUN_COMPOSER_INSTALL: ${{ inputs.RUN_COMPOSER_INSTALL }}
660+
EXTNAME: ${{ env.EXTNAME }}
661+
PHP_VERSION: ${{ matrix.php }}
770662

771663
- name: Setup PHPUnit files
772664
run: |
773665
if (-not (Test-Path "phpBB\ext\$env:EXTNAME\.github")) {
774666
mkdir "phpBB\ext\$env:EXTNAME\.github"
775667
}
776668
Copy-Item ".github\phpunit*" -Destination "phpBB\ext\$env:EXTNAME\.github" -Force
777-
working-directory: .\phpBB3
669+
working-directory: ./phpBB3
778670

779671
- name: Run unit tests
780672
run: |
@@ -791,5 +683,5 @@ jobs:
791683
}
792684
793685
phpBB/vendor/bin/phpunit @args
794-
working-directory: .\phpBB3
686+
working-directory: ./phpBB3
795687
# END IIS & PostgreSQL on Windows Tests Job
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Install Dependencies
2+
description: Sets up Node.js, npm, and Composer for the extension
3+
4+
inputs:
5+
RUN_NPM_INSTALL:
6+
required: true
7+
RUN_COMPOSER_INSTALL:
8+
required: true
9+
EXTNAME:
10+
required: true
11+
PHP_VERSION:
12+
required: false
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Set up Node.js
18+
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
23+
- name: Cache NPM dependencies
24+
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
25+
uses: actions/cache@v4
26+
with:
27+
path: ./phpBB3/phpBB/ext/${{ inputs.EXTNAME }}/node_modules
28+
key: ${{ runner.os }}-node-${{ hashFiles(format('phpBB3/phpBB/ext/{0}/package-lock.json', inputs.EXTNAME)) }}
29+
restore-keys: |
30+
${{ runner.os }}-node-
31+
32+
- name: Run npm ci
33+
if: ${{ inputs.RUN_NPM_INSTALL == '1' }}
34+
run: npm ci
35+
shell: bash
36+
working-directory: ./phpBB3/phpBB/ext/${{ inputs.EXTNAME }}
37+
38+
- name: Cache Composer dependencies
39+
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
40+
uses: actions/cache@v4
41+
with:
42+
path: ./phpBB3/phpBB/ext/${{ inputs.EXTNAME }}/vendor
43+
key: ${{ runner.os }}-composer-${{ inputs.PHP_VERSION || 'default' }}-${{ hashFiles(format('phpBB3/phpBB/ext/{0}/composer.lock', inputs.EXTNAME)) }}
44+
restore-keys: |
45+
${{ runner.os }}-composer-${{ inputs.PHP_VERSION || 'default' }}-
46+
${{ runner.os }}-composer-
47+
48+
- name: Install Composer dependencies
49+
if: ${{ inputs.RUN_COMPOSER_INSTALL == '1' }}
50+
run: composer install
51+
shell: bash
52+
working-directory: ./phpBB3/phpBB/ext/${{ inputs.EXTNAME }}

0 commit comments

Comments
 (0)