setup-php 2.13.0 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +990 -922
  3. package/lib/config.d.ts +3 -0
  4. package/lib/config.js +71 -71
  5. package/lib/config.js.map +1 -1
  6. package/lib/coverage.d.ts +5 -0
  7. package/lib/coverage.js +97 -87
  8. package/lib/coverage.js.map +1 -1
  9. package/lib/extensions.d.ts +4 -0
  10. package/lib/extensions.js +214 -200
  11. package/lib/extensions.js.map +1 -1
  12. package/lib/fetch.d.ts +1 -0
  13. package/lib/fetch.js +63 -0
  14. package/lib/fetch.js.map +1 -0
  15. package/lib/install.d.ts +2 -0
  16. package/lib/install.js +75 -81
  17. package/lib/install.js.map +1 -1
  18. package/lib/tools.d.ts +23 -0
  19. package/lib/tools.js +367 -386
  20. package/lib/tools.js.map +1 -1
  21. package/lib/utils.d.ts +21 -0
  22. package/lib/utils.js +261 -291
  23. package/lib/utils.js.map +1 -1
  24. package/package.json +67 -56
  25. package/src/config.ts +82 -82
  26. package/src/configs/brew_extensions +31 -0
  27. package/src/configs/composer.env +2 -0
  28. package/src/configs/ini/jit.ini +3 -0
  29. package/src/configs/ini/php.ini +2 -0
  30. package/src/configs/ini/xdebug.ini +1 -0
  31. package/src/configs/os_releases.csv +19 -17
  32. package/src/configs/php-versions.json +6 -5
  33. package/src/configs/php_packages +12 -0
  34. package/src/configs/{php.json → pm/php.json} +29 -29
  35. package/src/configs/{phpunit.json → pm/phpunit.json} +24 -24
  36. package/src/configs/tools.json +278 -235
  37. package/src/configs/tools_schema.json +125 -114
  38. package/src/coverage.ts +144 -142
  39. package/src/extensions.ts +367 -349
  40. package/src/fetch.ts +54 -0
  41. package/src/install.ts +66 -82
  42. package/src/scripts/darwin.sh +285 -249
  43. package/src/scripts/extensions/add_extensions.ps1 +194 -0
  44. package/src/scripts/extensions/add_extensions.sh +184 -0
  45. package/src/scripts/{ext → extensions}/blackfire.ps1 +32 -32
  46. package/src/scripts/{ext → extensions}/blackfire.sh +22 -21
  47. package/src/scripts/{ext → extensions}/couchbase.sh +43 -43
  48. package/src/scripts/{ext → extensions}/cubrid.sh +60 -60
  49. package/src/scripts/extensions/extension_map.php +132 -0
  50. package/src/scripts/{ext → extensions}/firebird.ps1 +19 -19
  51. package/src/scripts/{ext → extensions}/firebird.sh +39 -35
  52. package/src/scripts/{ext → extensions}/gearman.sh +22 -22
  53. package/src/scripts/{ext → extensions}/geos.sh +17 -17
  54. package/src/scripts/{ext → extensions}/http.ps1 +54 -54
  55. package/src/scripts/{ext → extensions}/http.sh +109 -120
  56. package/src/scripts/{ext → extensions}/intl.sh +23 -23
  57. package/src/scripts/{ext → extensions}/ioncube.ps1 +33 -32
  58. package/src/scripts/{ext → extensions}/ioncube.sh +21 -19
  59. package/src/scripts/{ext → extensions}/oci.ps1 +85 -60
  60. package/src/scripts/{ext → extensions}/oci.sh +65 -63
  61. package/src/scripts/{ext → extensions}/patches/firebird.sh +11 -11
  62. package/src/scripts/{ext → extensions}/patches/geos.sh +7 -7
  63. package/src/scripts/{ext → extensions}/patches/http.sh +11 -11
  64. package/src/scripts/{ext → extensions}/patches/pdo_oci.sh +6 -6
  65. package/src/scripts/{ext → extensions}/patches/phpize.sh +26 -26
  66. package/src/scripts/{ext → extensions}/patches/protobuf.sh +4 -4
  67. package/src/scripts/{ext → extensions}/phalcon.ps1 +54 -54
  68. package/src/scripts/{ext → extensions}/phalcon.sh +58 -58
  69. package/src/scripts/{ext → extensions}/source.sh +145 -144
  70. package/src/scripts/extensions/sqlsrv.sh +15 -0
  71. package/src/scripts/linux.sh +269 -256
  72. package/src/scripts/tools/add_tools.ps1 +239 -26
  73. package/src/scripts/tools/add_tools.sh +175 -20
  74. package/src/scripts/tools/blackfire.ps1 +19 -19
  75. package/src/scripts/tools/blackfire.sh +40 -39
  76. package/src/scripts/tools/grpc_php_plugin.ps1 +21 -21
  77. package/src/scripts/tools/grpc_php_plugin.sh +58 -58
  78. package/src/scripts/tools/ppa.sh +192 -151
  79. package/src/scripts/tools/protoc.ps1 +38 -38
  80. package/src/scripts/tools/protoc.sh +28 -28
  81. package/src/scripts/tools/symfony.ps1 +14 -0
  82. package/src/scripts/tools/symfony.sh +13 -0
  83. package/src/scripts/unix.sh +186 -0
  84. package/src/scripts/win32.ps1 +352 -494
  85. package/src/tools.ts +512 -538
  86. package/src/utils.ts +415 -500
  87. package/.eslintrc.json +0 -16
  88. package/.github/CODE_OF_CONDUCT.md +0 -76
  89. package/.github/CONTRIBUTING.md +0 -70
  90. package/.github/FUNDING.yml +0 -7
  91. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
  92. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
  93. package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
  94. package/.github/SECURITY.md +0 -29
  95. package/.github/workflows/docs.yml +0 -77
  96. package/.github/workflows/node-workflow.yml +0 -51
  97. package/.github/workflows/workflow.yml +0 -78
  98. package/.idea/workspace.xml +0 -113
  99. package/.prettierrc.json +0 -12
  100. package/__tests__/config.test.ts +0 -52
  101. package/__tests__/coverage.test.ts +0 -110
  102. package/__tests__/extensions.test.ts +0 -263
  103. package/__tests__/install.test.ts +0 -175
  104. package/__tests__/tools.test.ts +0 -524
  105. package/__tests__/utils.test.ts +0 -307
  106. package/action.yml +0 -29
  107. package/dist/index.js +0 -3051
  108. package/examples/bedrock.yml +0 -32
  109. package/examples/blackfire-player.yml +0 -31
  110. package/examples/blackfire.yml +0 -31
  111. package/examples/cakephp-mysql.yml +0 -114
  112. package/examples/cakephp-postgres.yml +0 -112
  113. package/examples/cakephp.yml +0 -92
  114. package/examples/codeigniter.yml +0 -34
  115. package/examples/laravel-mysql.yml +0 -74
  116. package/examples/laravel-postgres.yml +0 -74
  117. package/examples/laravel.yml +0 -42
  118. package/examples/lumen-mysql.yml +0 -74
  119. package/examples/lumen-postgres.yml +0 -74
  120. package/examples/lumen.yml +0 -38
  121. package/examples/phalcon-mysql.yml +0 -74
  122. package/examples/phalcon-postgres.yml +0 -73
  123. package/examples/sage.yml +0 -57
  124. package/examples/slim-framework.yml +0 -34
  125. package/examples/symfony-mysql.yml +0 -57
  126. package/examples/symfony-postgres.yml +0 -55
  127. package/examples/symfony.yml +0 -39
  128. package/examples/yii2-mysql.yml +0 -73
  129. package/examples/yii2-postgres.yml +0 -71
  130. package/examples/zend-framework.yml +0 -36
  131. package/jest.config.js +0 -12
  132. package/lib/sapi.js +0 -64
  133. package/src/scripts/common.sh +0 -314
  134. package/tsconfig.json +0 -18
@@ -1,307 +0,0 @@
1
- import * as fs from 'fs';
2
- import * as path from 'path';
3
- import * as utils from '../src/utils';
4
-
5
- jest.mock('@actions/core', () => ({
6
- getInput: jest.fn().mockImplementation(key => {
7
- return ['setup-php'].indexOf(key) !== -1 ? key : '';
8
- })
9
- }));
10
-
11
- async function cleanup(path: string): Promise<void> {
12
- fs.unlink(path, error => {
13
- if (error) {
14
- console.log(error);
15
- }
16
- });
17
- }
18
-
19
- describe('Utils tests', () => {
20
- it('checking readEnv', async () => {
21
- process.env['test'] = 'setup-php';
22
- process.env['test-hyphen'] = 'setup-php';
23
- expect(await utils.readEnv('test')).toBe('setup-php');
24
- expect(await utils.readEnv('TEST')).toBe('setup-php');
25
- expect(await utils.readEnv('test_hyphen')).toBe('setup-php');
26
- expect(await utils.readEnv('TEST_HYPHEN')).toBe('setup-php');
27
- expect(await utils.readEnv('undefined')).toBe('');
28
- });
29
-
30
- it('checking getInput', async () => {
31
- process.env['test'] = 'setup-php';
32
- expect(await utils.getInput('test', false)).toBe('setup-php');
33
- expect(await utils.getInput('setup-php', false)).toBe('setup-php');
34
- expect(await utils.getInput('DoesNotExist', false)).toBe('');
35
- await expect(async () => {
36
- await utils.getInput('DoesNotExist', true);
37
- }).rejects.toThrow('Input required and not supplied: DoesNotExist');
38
- });
39
-
40
- it('checking fetch', async () => {
41
- const manifest = await utils.getManifestURL();
42
- let response: Record<string, string> = await utils.fetch(manifest);
43
- expect(response.error).toBe(undefined);
44
- expect(response.data).toContain('latest');
45
-
46
- response = await utils.fetch(manifest, 'invalid_token');
47
- expect(response.error).not.toBe(undefined);
48
- expect(response.data).toBe(undefined);
49
- });
50
-
51
- it('checking getManifestURL', async () => {
52
- expect(await utils.getManifestURL()).toContain('php-versions.json');
53
- });
54
-
55
- it('checking parseVersion', async () => {
56
- jest
57
- .spyOn(utils, 'fetch')
58
- .mockImplementation(
59
- async (url, token?): Promise<Record<string, string>> => {
60
- if (!token || token === 'valid_token') {
61
- return {data: `{ "latest": "8.0", "5.x": "5.6", "url": "${url}" }`};
62
- } else {
63
- return {error: 'Invalid token'};
64
- }
65
- }
66
- );
67
- expect(await utils.parseVersion('latest')).toBe('8.0');
68
- expect(await utils.parseVersion('7')).toBe('7.0');
69
- expect(await utils.parseVersion('7.4')).toBe('7.4');
70
- expect(await utils.parseVersion('5.x')).toBe('5.6');
71
- expect(await utils.parseVersion('4.x')).toBe(undefined);
72
- });
73
-
74
- it('checking asyncForEach', async () => {
75
- const array: Array<string> = ['a', 'b', 'c'];
76
- let concat = '';
77
- await utils.asyncForEach(
78
- array,
79
- async function (str: string): Promise<void> {
80
- concat += str;
81
- }
82
- );
83
- expect(concat).toBe('abc');
84
- });
85
-
86
- it('checking asyncForEach', async () => {
87
- expect(await utils.color('error')).toBe('31');
88
- expect(await utils.color('success')).toBe('32');
89
- expect(await utils.color('any')).toBe('32');
90
- expect(await utils.color('warning')).toBe('33');
91
- });
92
-
93
- it('checking readFile', async () => {
94
- const darwin: string = fs.readFileSync(
95
- path.join(__dirname, '../src/scripts/darwin.sh'),
96
- 'utf8'
97
- );
98
- const linux: string = fs.readFileSync(
99
- path.join(__dirname, '../src/scripts/linux.sh'),
100
- 'utf8'
101
- );
102
- const win32: string = fs.readFileSync(
103
- path.join(__dirname, '../src/scripts/win32.ps1'),
104
- 'utf8'
105
- );
106
- expect(await utils.readFile('darwin.sh', 'src/scripts')).toBe(darwin);
107
- expect(await utils.readFile('darwin.sh', 'src/scripts')).toBe(darwin);
108
- expect(await utils.readFile('linux.sh', 'src/scripts')).toBe(linux);
109
- expect(await utils.readFile('linux.sh', 'src/scripts')).toBe(linux);
110
- expect(await utils.readFile('win32.ps1', 'src/scripts')).toBe(win32);
111
- expect(await utils.readFile('win32.ps1', 'src/scripts')).toBe(win32);
112
- });
113
-
114
- it('checking writeScripts', async () => {
115
- const testString = 'sudo apt-get install php';
116
- const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || '';
117
- const script_path: string = path.join(runner_dir, 'test.sh');
118
- await utils.writeScript('test.sh', testString);
119
- await fs.readFile(
120
- script_path,
121
- function (error: Error | null, data: Buffer) {
122
- expect(testString).toBe(data.toString());
123
- }
124
- );
125
- await cleanup(script_path);
126
- });
127
-
128
- it('checking extensionArray', async () => {
129
- expect(await utils.extensionArray('a, b, php_c, php-d')).toEqual([
130
- 'a',
131
- 'b',
132
- 'c',
133
- 'd'
134
- ]);
135
-
136
- expect(await utils.extensionArray('')).toEqual([]);
137
- expect(await utils.extensionArray(' ')).toEqual([]);
138
- });
139
-
140
- it('checking INIArray', async () => {
141
- expect(await utils.CSVArray('a=1, b=2, c=3')).toEqual([
142
- 'a=1',
143
- 'b=2',
144
- 'c=3'
145
- ]);
146
- expect(await utils.CSVArray('\'a=1,2\', "b=3, 4", c=5, d=~e~')).toEqual([
147
- 'a=1,2',
148
- 'b=3, 4',
149
- 'c=5',
150
- "d='~e~'"
151
- ]);
152
- expect(await utils.CSVArray('a=\'1,2\', b="3, 4", c=5')).toEqual([
153
- 'a=1,2',
154
- 'b=3, 4',
155
- 'c=5'
156
- ]);
157
- expect(
158
- await utils.CSVArray('a=E_ALL, b=E_ALL & ~ E_ALL, c="E_ALL", d=\'E_ALL\'')
159
- ).toEqual(['a=E_ALL', 'b=E_ALL & ~ E_ALL', 'c=E_ALL', 'd=E_ALL']);
160
- expect(await utils.CSVArray('')).toEqual([]);
161
- expect(await utils.CSVArray(' ')).toEqual([]);
162
- });
163
-
164
- it('checking log', async () => {
165
- const message = 'Test message';
166
-
167
- let warning_log: string = await utils.log(message, 'win32', 'warning');
168
- expect(warning_log).toEqual('printf "\\033[33;1m' + message + ' \\033[0m"');
169
- warning_log = await utils.log(message, 'linux', 'warning');
170
- expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
171
- warning_log = await utils.log(message, 'darwin', 'warning');
172
- expect(warning_log).toEqual('echo "\\033[33;1m' + message + '\\033[0m"');
173
-
174
- let error_log: string = await utils.log(message, 'win32', 'error');
175
- expect(error_log).toEqual('printf "\\033[31;1m' + message + ' \\033[0m"');
176
- error_log = await utils.log(message, 'linux', 'error');
177
- expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
178
- error_log = await utils.log(message, 'darwin', 'error');
179
- expect(error_log).toEqual('echo "\\033[31;1m' + message + '\\033[0m"');
180
-
181
- let success_log: string = await utils.log(message, 'win32', 'success');
182
- expect(success_log).toEqual('printf "\\033[32;1m' + message + ' \\033[0m"');
183
- success_log = await utils.log(message, 'linux', 'success');
184
- expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
185
- success_log = await utils.log(message, 'darwin', 'success');
186
- expect(success_log).toEqual('echo "\\033[32;1m' + message + '\\033[0m"');
187
-
188
- let step_log: string = await utils.stepLog(message, 'win32');
189
- expect(step_log).toEqual('Step-Log "Test message"');
190
- step_log = await utils.stepLog(message, 'linux');
191
- expect(step_log).toEqual('step_log "Test message"');
192
- step_log = await utils.stepLog(message, 'darwin');
193
- expect(step_log).toEqual('step_log "Test message"');
194
- step_log = await utils.stepLog(message, 'openbsd');
195
- expect(step_log).toContain('Platform openbsd is not supported');
196
-
197
- let add_log: string = await utils.addLog(
198
- 'tick',
199
- 'xdebug',
200
- 'enabled',
201
- 'win32'
202
- );
203
- expect(add_log).toEqual('Add-Log "tick" "xdebug" "enabled"');
204
- add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'linux');
205
- expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
206
- add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'darwin');
207
- expect(add_log).toEqual('add_log "tick" "xdebug" "enabled"');
208
- add_log = await utils.addLog('tick', 'xdebug', 'enabled', 'openbsd');
209
- expect(add_log).toContain('Platform openbsd is not supported');
210
- });
211
-
212
- it('checking getExtensionPrefix', async () => {
213
- expect(await utils.getExtensionPrefix('extensionDoesNotExist')).toEqual(
214
- 'extension'
215
- );
216
- expect(await utils.getExtensionPrefix('xsl')).toEqual('extension');
217
- expect(await utils.getExtensionPrefix('xdebug')).toEqual('zend_extension');
218
- expect(await utils.getExtensionPrefix('xdebug3')).toEqual('zend_extension');
219
- expect(await utils.getExtensionPrefix('opcache')).toEqual('zend_extension');
220
- });
221
-
222
- it('checking suppressOutput', async () => {
223
- expect(await utils.suppressOutput('win32')).toEqual(' >$null 2>&1');
224
- expect(await utils.suppressOutput('linux')).toEqual(' >/dev/null 2>&1');
225
- expect(await utils.suppressOutput('darwin')).toEqual(' >/dev/null 2>&1');
226
- expect(await utils.suppressOutput('openbsd')).toContain(
227
- 'Platform openbsd is not supported'
228
- );
229
- });
230
-
231
- it('checking getUnsupportedLog', async () => {
232
- expect(await utils.getUnsupportedLog('ext', '5.6', 'linux')).toContain(
233
- 'add_log "$cross" "ext" "ext is not supported on PHP 5.6"'
234
- );
235
- });
236
-
237
- it('checking getCommand', async () => {
238
- expect(await utils.getCommand('linux', 'tool')).toBe('add_tool ');
239
- expect(await utils.getCommand('darwin', 'tool')).toBe('add_tool ');
240
- expect(await utils.getCommand('win32', 'tool')).toBe('Add-Tool ');
241
- expect(await utils.getCommand('openbsd', 'tool')).toContain(
242
- 'Platform openbsd is not supported'
243
- );
244
- });
245
-
246
- it('checking joins', async () => {
247
- expect(await utils.joins('a', 'b', 'c')).toBe('a b c');
248
- });
249
-
250
- it('checking scriptExtension', async () => {
251
- expect(await utils.scriptExtension('linux')).toBe('.sh');
252
- expect(await utils.scriptExtension('darwin')).toBe('.sh');
253
- expect(await utils.scriptExtension('win32')).toBe('.ps1');
254
- expect(await utils.scriptExtension('openbsd')).toContain(
255
- 'Platform openbsd is not supported'
256
- );
257
- });
258
-
259
- it('checking scriptTool', async () => {
260
- expect(await utils.scriptTool('linux')).toBe('bash');
261
- expect(await utils.scriptTool('darwin')).toBe('bash');
262
- expect(await utils.scriptTool('win32')).toBe('pwsh');
263
- expect(await utils.scriptTool('openbsd')).toContain(
264
- 'Platform openbsd is not supported'
265
- );
266
- });
267
-
268
- it('checking customPackage', async () => {
269
- const script_path: string = path.join('ext', 'pkg.sh');
270
- expect(await utils.customPackage('pkg', 'ext', '1.2.3', 'linux')).toContain(
271
- script_path + '\nadd_pkg 1.2.3'
272
- );
273
- expect(
274
- await utils.customPackage('pdo_pkg', 'ext', '1.2.3', 'linux')
275
- ).toContain(script_path + '\nadd_pkg 1.2.3');
276
- expect(
277
- await utils.customPackage('pkg8', 'ext', '1.2.3', 'linux')
278
- ).toContain(script_path + '\nadd_pkg 1.2.3');
279
- });
280
-
281
- it('checking parseExtensionSource', async () => {
282
- expect(
283
- await utils.parseExtensionSource(
284
- 'ext-org-name/repo-name@release',
285
- 'extension'
286
- )
287
- ).toContain(
288
- '\nadd_extension_from_source ext https://github.com org-name repo-name release extension'
289
- );
290
- expect(
291
- await utils.parseExtensionSource(
292
- 'ext-https://sub.domain.tld/org/repo@release',
293
- 'extension'
294
- )
295
- ).toContain(
296
- '\nadd_extension_from_source ext https://sub.domain.tld org repo release extension'
297
- );
298
- expect(
299
- await utils.parseExtensionSource(
300
- 'ext-https://sub.domain.XN--tld/org/repo@release',
301
- 'extension'
302
- )
303
- ).toContain(
304
- '\nadd_extension_from_source ext https://sub.domain.XN--tld org repo release extension'
305
- );
306
- });
307
- });
package/action.yml DELETED
@@ -1,29 +0,0 @@
1
- name: 'Setup PHP Action'
2
- author: shivammathur
3
- description: 'GitHub Action for PHP'
4
- branding:
5
- color: 'purple'
6
- icon: 'play-circle'
7
- inputs:
8
- php-version:
9
- description: 'Setup PHP version.'
10
- default: '8.0'
11
- required: true
12
- extensions:
13
- description: 'Setup PHP extensions.'
14
- required: false
15
- ini-values:
16
- description: 'Add values to php.ini.'
17
- required: false
18
- coverage:
19
- description: 'Setup code coverage driver.'
20
- required: false
21
- tools:
22
- description: 'Setup popular tools globally.'
23
- required: false
24
- outputs:
25
- php-version:
26
- description: 'PHP version in semver format'
27
- runs:
28
- using: 'node12'
29
- main: 'dist/index.js'