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