-
Notifications
You must be signed in to change notification settings - Fork 3
131 lines (108 loc) · 4.74 KB
/
php-test-reusable.yml
File metadata and controls
131 lines (108 loc) · 4.74 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
119
120
121
122
123
124
125
126
127
128
129
130
131
name: PHP Tests Reusable Workflow
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
on:
# Reusable workflow
workflow_call:
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
inputs:
versions:
description: 'Version of the interpreter'
required: true
default: "['8.2']"
type: string
permissions: # Setting permissions for the token
contents: read # needed to fetch code
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#defaults
# Set the default shell for a run
defaults:
run:
shell: bash
# A list of the jobs that run in the workflow file.
jobs:
test: # The identifier of the job
name: Test on php ${{ matrix.php }} # The name of the job
runs-on: ubuntu-latest
strategy:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
matrix:
# 2 jobs will run, one for each include entry
# because we don't specify any matrix variables
# All configurations under include will run
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-adding-configurations
php: ${{ fromJson(github.event.inputs.versions) }}
fail-fast: false
env:
COMBO_HOME: lib/plugins/combo
steps:
- name: Phpunit ${{ matrix.php }}
run: |
echo "PHPUNIT_VERSION=${{ fromJson(env.PHPUNIT_BY_PHP)[matrix.php] }}" >> $GITHUB_ENV
env:
PHPUNIT_BY_PHP: '{"7.4":"8.5.33","8.2":"8.5.33"}'
# https://github.com/marketplace/actions/setup-php-action#matrix-setup
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: mbstring, intl, PDO, pdo_sqlite, pdo_mysql, pdo_pgsql, bz2
ini-values: pcre.jit=0
tools: phpunit:${{ env.PHPUNIT_VERSION }}
# Php Problem Matchers
# https://github.com/marketplace/actions/setup-php-action#problem-matchers
# Problem matchers are json configurations which identify errors and warnings in your logs
# and surface them prominently in the GitHub Actions UI by highlighting them and creating code annotations.
- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
# Cloning Dokuwiki
- name: Checkout Dokuwiki
uses: actions/checkout@v3
with:
repository: dokuwiki/dokuwiki
fetch-depth: '1' # th is the default value but this is more expressive
ref: 'stable' # The release branch
# Cloning this repository to the runner
# https://github.com/actions/checkout
- name: Checkout Combo
uses: actions/checkout@v3
with:
path: ${{ env.COMBO_HOME }}
# Runs command-line programs using the operating system's shell.
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- name: Post installation (Download Requirements)
run: |
chmod +x ${COMBO_HOME}/.github/bootstrap.sh
source ${COMBO_HOME}/.github/bootstrap.sh
# https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
env:
TOKEN: ${{ secrets.TOKEN }}
working-directory: .
shell: bash
# Node
# https://github.com/actions/setup-node/issues/160#issuecomment-642739512
# We don't specify the version to get the one that is on the image
# otherwise you get a time-out as it tries to download it and failed
- uses: actions/setup-node@v3
# with:
# node-version: latest
# Yarn (should happen after combo as we install in combo)
- name: Yarn install
run: |
npm install --global yarn
cd ${COMBO_HOME} && yarn install
# Get the list of locales
- name: Installed Locale
run: locale -a
# Composer is used since Kaos version (06/02/2024)
- name: Setup PHPUnit
run: |
cd _test
composer install --no-interaction --no-progress --no-suggest --prefer-dist
# No better formatter
# This one does not work: https://github.com/mheap/phpunit-matcher-action
# with verbose, you see the configuration file used at the beginning
- name: Test
run: |
phpunit --version
phpunit --stderr --configuration _test/phpunit.xml --verbose --debug --bootstrap ${COMBO_HOME}/_test/bootstrap.php ${COMBO_HOME}/_test