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
@@ -0,0 +1,186 @@
1
+ # Variables
2
+ export tick="✓"
3
+ export cross="✗"
4
+ export curl_opts=(-sL)
5
+ export old_versions="5.[3-5]"
6
+ export jit_versions="8.[0-9]"
7
+ export nightly_versions="8.[2-9]"
8
+ export xdebug3_versions="7.[2-4]|8.[0-9]"
9
+ export latest="releases/latest/download"
10
+ export github="https://github.com/shivammathur"
11
+ export jsdeliver="https://cdn.jsdelivr.net/gh/shivammathur"
12
+ export setup_php="https://setup-php.com"
13
+
14
+ if [ -n "${GITHUB_ACTIONS}" ]; then
15
+ export GROUP='::group::'
16
+ export END_GROUP='::endgroup::'
17
+ else
18
+ export GROUP=''
19
+ export END_GROUP=''
20
+ fi
21
+
22
+ # Function to log start of a operation.
23
+ step_log() {
24
+ message=$1
25
+ printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
26
+ }
27
+
28
+ # Function to log result of a operation.
29
+ add_log() {
30
+ mark=$1
31
+ subject=$2
32
+ message=$3
33
+ if [ "$mark" = "$tick" ]; then
34
+ printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
35
+ else
36
+ printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
37
+ [ "$fail_fast" = "true" ] && exit 1
38
+ fi
39
+ }
40
+
41
+ # Function to set output on GitHub Actions.
42
+ set_output() {
43
+ name=$1
44
+ value=$2
45
+ if [ "${GITHUB_ACTIONS}" = "true" ]; then
46
+ echo "::set-output name=${name}::${value}"
47
+ fi
48
+ }
49
+
50
+ # Function to read env inputs.
51
+ read_env() {
52
+ update="${update:-${UPDATE:-false}}"
53
+ fail_fast="${fail_fast:-${FAIL_FAST:-false}}"
54
+ [[ -z "${ImageOS}" && -z "${ImageVersion}" ]] && _runner=self-hosted || _runner=github
55
+ runner="${runner:-${RUNNER:-$_runner}}"
56
+
57
+ if [[ "$runner" = "github" && $_runner = "self-hosted" ]]; then
58
+ fail_fast=true
59
+ add_log "$cross" "Runner" "Runner set as github in self-hosted environment"
60
+ fi
61
+ }
62
+
63
+ # Function to download a file using cURL.
64
+ # mode: -s pipe to stdout, -v save file and return status code
65
+ # execute: -e save file as executable
66
+ get() {
67
+ mode=$1
68
+ execute=$2
69
+ file_path=$3
70
+ shift 3
71
+ links=("$@")
72
+ if [ "$mode" = "-s" ]; then
73
+ sudo curl "${curl_opts[@]}" "${links[0]}"
74
+ else
75
+ for link in "${links[@]}"; do
76
+ status_code=$(sudo curl -w "%{http_code}" -o "$file_path" "${curl_opts[@]}" "$link")
77
+ [ "$status_code" = "200" ] && break
78
+ done
79
+ [ "$execute" = "-e" ] && sudo chmod a+x "$file_path"
80
+ [ "$mode" = "-v" ] && echo "$status_code"
81
+ fi
82
+ }
83
+
84
+ # Function to get shell profile.
85
+ get_shell_profile() {
86
+ case "$SHELL" in
87
+ *bash*)
88
+ echo "${HOME}/.bashrc"
89
+ ;;
90
+ *zsh*)
91
+ echo "${HOME}/.zshrc"
92
+ ;;
93
+ *)
94
+ echo "${HOME}/.profile"
95
+ ;;
96
+ esac
97
+ }
98
+
99
+ # Function to add a path to the PATH variable.
100
+ add_path() {
101
+ path_to_add=$1
102
+ [ ! -d "$path_to_add" ] && [[ ":$PATH:" == *":$path_to_add:"* ]] && return
103
+ if [[ -n "$GITHUB_PATH" ]]; then
104
+ echo "$path_to_add" | tee -a "$GITHUB_PATH" >/dev/null 2>&1
105
+ else
106
+ profile=$(get_shell_profile)
107
+ ([ -e "$profile" ] && grep -q ":$path_to_add\"" "$profile" 2>/dev/null) || echo "export PATH=\"\${PATH:+\${PATH}:}\"$path_to_add" | sudo tee -a "$profile" >/dev/null 2>&1
108
+ fi
109
+ export PATH="${PATH:+${PATH}:}$path_to_add"
110
+ }
111
+
112
+ # Function to add environment variables using a PATH.
113
+ add_env_path() {
114
+ env_path=$1
115
+ [ -e "$env_path" ] || return
116
+ if [[ -n "$GITHUB_ENV" ]]; then
117
+ cat "$env_path" >> "$GITHUB_ENV"
118
+ else
119
+ profile=$(get_shell_profile)
120
+ cat "$env_path" >> "$profile"
121
+ fi
122
+ }
123
+
124
+ # Function to add an environment variable.
125
+ add_env() {
126
+ env_name=$1
127
+ env_value=$2
128
+ if [[ -n "$GITHUB_ENV" ]]; then
129
+ echo "$env_name=$env_value" | tee -a "$GITHUB_ENV" >/dev/null 2>&1
130
+ else
131
+ profile=$(get_shell_profile)
132
+ echo "export $env_name=\"$env_value\"" | sudo tee -a "$profile" >/dev/null 2>&1
133
+ fi
134
+ export "$env_name"="$env_value"
135
+ }
136
+
137
+ # Function to download and run scripts from GitHub releases with jsdeliver fallback.
138
+ run_script() {
139
+ repo=$1
140
+ shift
141
+ args=("$@")
142
+ get -q -e /tmp/install.sh "$github/$repo/$latest/install.sh" "$jsdeliver/$repo@main/scripts/install.sh" "$setup_php/$repo/install.sh"
143
+ bash /tmp/install.sh "${args[@]}"
144
+ }
145
+
146
+ # Function to install required packages on self-hosted runners.
147
+ self_hosted_setup() {
148
+ if [ "$runner" = "self-hosted" ]; then
149
+ if [[ "${version:?}" =~ $old_versions ]]; then
150
+ add_log "$cross" "PHP" "PHP $version is not supported on self-hosted runner"
151
+ exit 1
152
+ else
153
+ self_hosted_helper >/dev/null 2>&1
154
+ fi
155
+ fi
156
+ }
157
+
158
+ # Function to configure PHP
159
+ configure_php() {
160
+ add_php_config
161
+ ini_config_dir="${src:?}"/configs/ini
162
+ ini_files=("$ini_config_dir"/php.ini)
163
+ [[ "$version" =~ $jit_versions ]] && ini_files+=("$ini_config_dir"/jit.ini)
164
+ [[ "$version" =~ $xdebug3_versions ]] && ini_files+=("$ini_config_dir"/xdebug.ini)
165
+ cat "${ini_files[@]}" | sudo tee -a "${pecl_file:-${ini_file[@]}}" >/dev/null 2>&1
166
+ }
167
+
168
+ # Function to get PHP version in semver format.
169
+ php_semver() {
170
+ grep -Eo 'version="[0-9]+(\.[0-9]+){2}((-?[a-zA-Z]+([0-9]+)?)?){2}' "${php_config:?}" | cut -d '"' -f 2
171
+ }
172
+
173
+ # Function to get ini_path.
174
+ php_ini_path() {
175
+ cut -d '"' -f 2 < <(grep "ini_path=" "$php_config" || php --ini | grep '(php.ini)' | sed -e "s|.*: s*||")
176
+ }
177
+
178
+ # Function to get the tag for a php version.
179
+ php_src_tag() {
180
+ commit=$(php_extra_version | grep -Eo "[0-9a-zA-Z]+")
181
+ if [[ -n "${commit}" ]]; then
182
+ echo "$commit"
183
+ else
184
+ echo "php-${semver:?}"
185
+ fi
186
+ }