-
Notifications
You must be signed in to change notification settings - Fork 0
118 lines (115 loc) · 3.8 KB
/
php_lib_pull_requests.yml
File metadata and controls
118 lines (115 loc) · 3.8 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: Pull Request
on:
workflow_call:
inputs:
PHP_LINT:
description: 'Toggle for the PHP lint step'
required: false
default: true
type: boolean
# Some libraries don't have unit tests and thus don't vendor phpunit
PHP_UNIT:
description: 'Toggle for the PHP unit test step'
required: false
default: true
type: boolean
PHP_UNIT_TESTSUITE:
description: ''
required: false
default: ''
type: string
SETUP_PHP_EXTENSIONS:
description: 'The extensions to enable while setting up PHP (csv)'
required: false
default: ""
type: string
SETUP_PHP_TOOLS:
description: 'The tools to enable while setting up PHP (csv)'
required: false
default: "composer:v1"
type: string
SETUP_PHP_COVERAGE:
description: 'The coverage tool to enable while setting up PHP (csv)'
required: false
default: "xdebug"
type: string
COMPOSER_WORKING_DIRECTORY:
description: 'Working directory for installing composer and running linting and unit tests'
required: false
default: "."
type: string
COMPOSER_OPTIONS:
description: 'composer options to use'
required: false
default: "--ignore-platform-reqs"
type: string
secrets:
COMPOSER_AUTH:
description: 'Auth JSON for Composer'
required: true
CODECOV_TOKEN:
description: 'Token for Codecov'
required: true
jobs:
commitlint:
#
# ensures commit messages follow conventional commits
#
runs-on: ubuntu-latest
steps:
# checkout the commits to lint.
- uses: actions/checkout@v3
with:
fetch-depth: 0
# setup node, needed to lint commits.
- uses: actions/setup-node@v1
with:
node-version: 18
# Install needed libraries to lint commits.
- run: npm install --save-dev @commitlint/{config-conventional@v18.6.0,cli}
# Lint the commits.
- run: npx commitlint --from=${{ github.event.pull_request.base.sha }}
test:
#
# ensure php standards and tests pass
#
runs-on: ubuntu-latest
strategy:
matrix:
# List of php versions to test on.
php-version: ['7.0']
steps:
# Checkout php code to test.
- name: Checkout repo
uses: actions/checkout@v3
# Setup PHP for each version in the matrix.
- name: Setup PHP
uses: shivammathur/setup-php@v2 # https://github.com/marketplace/actions/setup-php-action
with:
php-version: ${{ matrix.php-version }}
extensions: ${{ inputs.SETUP_PHP_EXTENSIONS }}
tools: ${{ inputs.SETUP_PHP_TOOLS }}
coverage: ${{ inputs.SETUP_PHP_COVERAGE }}
# Vendor PHP code.
- name: Composer
env:
COMPOSER_AUTH: '${{ secrets.COMPOSER_AUTH }}'
run: composer install -d ${{ inputs.COMPOSER_WORKING_DIRECTORY }} ${{ inputs.COMPOSER_OPTIONS }}
# Run PHP linter.
- name: php lint
if: ${{ inputs.PHP_LINT }}
run: ${{ inputs.COMPOSER_WORKING_DIRECTORY }}/vendor/bin/phpcs -s --extensions=php
# Run PHP unit tests.
- name: phpunit
if: ${{ inputs.PHP_UNIT }}
run: ${{ inputs.COMPOSER_WORKING_DIRECTORY }}/vendor/bin/phpunit --log-junit junit.xml --coverage-clover coverage.xml --testsuite ${{ inputs.PHP_UNIT_TESTSUITE }}
- name: Upload test coverage results to Codecov
if: ${{ inputs.PHP_UNIT }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ inputs.PHP_UNIT }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}