Skip to content

Commit 789ee07

Browse files
committed
Fix PHP workflows
1 parent 8224454 commit 789ee07

File tree

3 files changed

+41
-51
lines changed

3 files changed

+41
-51
lines changed

.github/workflows/php.yml

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,35 @@
11
# This file defines a reusable GitHub Actions workflow for PHP projects.
22
# It runs linting and unit tests across multiple PHP versions, only running tests if a test directory exists.
33

4-
name: Jobs
5-
64
on:
75
workflow_call:
86
inputs:
9-
php-version:
7+
php-versions:
108
required: false
119
type: string
1210
default: '["8.2", "8.3", "8.4"]'
1311

14-
1512
jobs:
16-
17-
phplint:
13+
lint:
1814
name: Lint
1915
strategy:
2016
matrix:
21-
php: ${{ fromJson(inputs.php-version) }}
22-
uses: icinga/github-actions/.github/workflows/phplint.yml@main
17+
php: ${{ fromJson(inputs.php-versions) }}
18+
uses: ./.github/workflows/phplint.yml
2319
with:
2420
php-version: ${{ matrix.php }}
25-
secrets: inherit
26-
2721

2822
test-exists:
2923
runs-on: ubuntu-latest
30-
name: test-exists
24+
name: Check unit tests exist
3125
outputs:
32-
has-tests: ${{ steps.check.outputs.exists }}
33-
26+
exists: ${{ steps.check.outputs.exists }}
3427
steps:
3528
- name: Checkout
3629
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: '1'
32+
3733
- name: Check directory
3834
id: check
3935
run: |
@@ -45,14 +41,13 @@ jobs:
4541
echo "exists=false" >> $GITHUB_OUTPUT
4642
fi
4743
48-
phpunit:
49-
name: Unit Test
44+
test:
45+
name: Unit tests
5046
needs: test-exists
51-
if: needs.test-exists.outputs.has-tests == 'true'
47+
if: needs.test-exists.outputs.exists == 'true'
5248
strategy:
5349
matrix:
54-
php: ${{ fromJson(inputs.php-version) }}
55-
uses: icinga/github-actions/.github/workflows/phpstan.yml
50+
php: ${{ fromJson(inputs.php-versions) }}
51+
uses: ./.github/workflows/phpunit.yml
5652
with:
5753
php-version: ${{ matrix.php }}
58-
secrets: inherit

.github/workflows/phplint.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
name: Lint
2-
31
on:
42
workflow_call:
53
inputs:
@@ -8,10 +6,9 @@ on:
86
required: true
97

108
jobs:
11-
static-analysis:
12-
name: Static analysis for version ${{ inputs.php-version }}
9+
lint:
10+
name: Lint PHP ${{ inputs.php-version }}
1311
runs-on: ubuntu-latest
14-
1512
steps:
1613
- name: Checkout
1714
uses: actions/checkout@v4

.github/workflows/phpunit.yml

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
name: PHP Unit Tests
2-
31
on:
42
workflow_call:
53
inputs:
@@ -8,32 +6,32 @@ on:
86
required: true
97

108
jobs:
11-
test:
12-
name: Unit tests with php ${{ inputs.php-version }}
13-
runs-on: ubuntu-latest
14-
15-
steps:
16-
- name: Checkout code base
17-
uses: actions/checkout@v4
9+
test:
10+
name: Unit tests PHP ${{ inputs.php-version }}
11+
runs-on: ubuntu-latest
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: '1'
1816

19-
- name: Setup PHP
20-
uses: shivammathur/setup-php@v2
21-
with:
22-
php-version: ${{ inputs.php-version }}
23-
tools: phpunit
17+
- name: Set up PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ inputs.php-version }}
21+
tools: phpunit
2422

25-
- name: Set up Icinga Web
26-
run: |
27-
git clone --depth 1 https://github.com/Icinga/icingaweb2.git _icingaweb2
28-
ln -s `pwd` _icingaweb2/modules/icingadb
23+
- name: Set up Icinga Web
24+
run: |
25+
git clone --depth 1 https://github.com/Icinga/icingaweb2.git _icingaweb2
26+
ln -s `pwd` _icingaweb2/modules/icingadb
2927
30-
- name: Set up Libraries
31-
run: |
32-
mkdir _libraries
33-
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git _libraries/ipl
34-
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git _libraries/vendor
28+
- name: Set up libraries
29+
run: |
30+
mkdir _libraries
31+
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-library.git _libraries/ipl
32+
git clone --depth 1 -b snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git _libraries/vendor
3533
36-
- name: PHPUnit
37-
env:
38-
ICINGAWEB_LIBDIR: _libraries
39-
run: phpunit --bootstrap _icingaweb2/test/php/bootstrap.php
34+
- name: PHPUnit
35+
env:
36+
ICINGAWEB_LIBDIR: _libraries
37+
run: phpunit --bootstrap _icingaweb2/test/php/bootstrap.php

0 commit comments

Comments
 (0)