This repository was archived by the owner on Oct 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (67 loc) · 2.41 KB
/
Copy pathworkflow_unit.yml
File metadata and controls
79 lines (67 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: PHPUnit Workflow
on:
workflow_call:
inputs:
directory:
required: true
type: string
testsuites:
required: true
type: string
coverage:
required: false
type: boolean
default: false
jobs:
phpunit:
runs-on: ubuntu-latest
name: Testsuite (${{ matrix.testsuite }})
strategy:
matrix:
testsuite: ${{ fromJSON(inputs.testsuites) }}
steps:
- uses: actions/checkout@v2
- name: Get composer cache directory
id: composer-cache
working-directory: ./${{ inputs.directory }}
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache Composer dependencies
uses: actions/cache@v2
id: cache
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Bit of a hardcode.
key: ${{ runner.os }}-${{ hashFiles('./api/composer.lock') }}-${{ hashFiles('./core/composer.lock') }}
- name: Setup PHP
if: ${{ inputs.coverage == false }}
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: none
tools: composer:v1
- name: Setup PHP with coverage
if: ${{ inputs.coverage == true }}
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
coverage: pcov
tools: composer:v1
- name: Install dependencies for ${{ inputs.directory }}
working-directory: ./${{ inputs.directory }}
run: composer install
- name: Run PHPUnit testsuite
if: ${{ inputs.coverage == false }}
working-directory: ./${{ inputs.directory }}
# Composer can't accept a testsuite with spaces in the name.
run: vendor/bin/phpunit --testsuite ${{ matrix.testsuite }}
- name: Run PHPUnit testsuite with coverage
if: ${{ inputs.coverage == true }}
working-directory: ./${{ inputs.directory }}
# Composer can't accept a testsuite with spaces in the name.
run: vendor/bin/phpunit --testsuite ${{ matrix.testsuite }} --coverage-php ./${{ inputs.directory }}-${{ matrix.testsuite }}-coverage.cov
- name: Upload coverage artifact
if: ${{ inputs.coverage == true }}
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: ./${{ inputs.directory }}/${{ inputs.directory }}-${{ matrix.testsuite }}-coverage.cov