cache-extensions 1.1.2 → 1.7.1
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.
- package/LICENSE +21 -21
- package/README.md +154 -133
- package/lib/cache.d.ts +2 -0
- package/lib/cache.js +59 -0
- package/lib/cache.js.map +1 -0
- package/lib/utils.d.ts +3 -0
- package/lib/utils.js +44 -0
- package/lib/utils.js.map +1 -0
- package/package.json +66 -54
- package/src/cache.ts +44 -11
- package/src/lists/bionic-libs +768 -737
- package/src/lists/darwin-deps +1 -0
- package/src/lists/darwin-extensions +19 -0
- package/src/lists/focal-libs +788 -753
- package/src/lists/linux-deps +4 -0
- package/src/scripts/cache.sh +124 -0
- package/src/scripts/darwin.sh +189 -0
- package/src/scripts/linux.sh +117 -0
- package/src/utils.ts +30 -23
- package/.eslintrc.json +0 -23
- package/.github/CODE_OF_CONDUCT.md +0 -76
- package/.github/CONTRIBUTING.md +0 -63
- package/.github/FUNDING.yml +0 -5
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -42
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -26
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -37
- package/.github/workflows/workflow.yml +0 -31
- package/.idea/cache-extensions.iml +0 -8
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.idea/workspace.xml +0 -217
- package/.prettierrc.json +0 -12
- package/__tests__/cache.test.ts +0 -60
- package/__tests__/utils.test.ts +0 -25
- package/action.yml +0 -19
- package/dist/index.js +0 -1701
- package/jest.config.js +0 -12
- package/src/extensions.sh +0 -96
- package/src/lists/bionic-php5.3-extensions +0 -71
- package/src/lists/bionic-php5.4-extensions +0 -75
- package/src/lists/bionic-php5.5-extensions +0 -75
- package/src/lists/bionic-php5.6-extensions +0 -67
- package/src/lists/bionic-php7.0-extensions +0 -64
- package/src/lists/bionic-php7.1-extensions +0 -93
- package/src/lists/bionic-php7.2-extensions +0 -93
- package/src/lists/bionic-php7.3-extensions +0 -93
- package/src/lists/bionic-php7.4-extensions +0 -91
- package/src/lists/bionic-php8.0-extensions +0 -72
- package/src/lists/focal-php5.3-extensions +0 -67
- package/src/lists/focal-php5.4-extensions +0 -74
- package/src/lists/focal-php5.5-extensions +0 -74
- package/src/lists/focal-php5.6-extensions +0 -66
- package/src/lists/focal-php7.0-extensions +0 -63
- package/src/lists/focal-php7.1-extensions +0 -63
- package/src/lists/focal-php7.2-extensions +0 -64
- package/src/lists/focal-php7.3-extensions +0 -64
- package/src/lists/focal-php7.4-extensions +0 -92
- package/src/lists/focal-php8.0-extensions +0 -71
- package/src/lists/xenial-libs +0 -728
- package/src/lists/xenial-php5.3-extensions +0 -70
- package/src/lists/xenial-php5.4-extensions +0 -74
- package/src/lists/xenial-php5.5-extensions +0 -74
- package/src/lists/xenial-php5.6-extensions +0 -98
- package/src/lists/xenial-php7.0-extensions +0 -93
- package/src/lists/xenial-php7.1-extensions +0 -93
- package/src/lists/xenial-php7.2-extensions +0 -93
- package/src/lists/xenial-php7.3-extensions +0 -93
- package/src/lists/xenial-php7.4-extensions +0 -91
- package/src/lists/xenial-php8.0-extensions +0 -72
- package/tsconfig.json +0 -63
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
step_log() {
|
|
2
|
+
message=$1
|
|
3
|
+
printf "\n\033[90;1m==> \033[0m\033[37;1m%s\033[0m\n" "$message"
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
add_log() {
|
|
7
|
+
mark=$1
|
|
8
|
+
shift
|
|
9
|
+
subjects=("$@")
|
|
10
|
+
for subject in "${subjects[@]}"; do
|
|
11
|
+
if [ "$mark" = "$tick" ]; then
|
|
12
|
+
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "Added $subject"
|
|
13
|
+
else
|
|
14
|
+
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "Failed to setup $subject"
|
|
15
|
+
fi
|
|
16
|
+
done
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get_api_version_from_repo() {
|
|
20
|
+
php_header="https://raw.githubusercontent.com/php/php-src/PHP-$version/main/php.h"
|
|
21
|
+
status_code=$(curl -sSL -o /tmp/php.h -w "%{http_code}" "$php_header")
|
|
22
|
+
if [ "$status_code" != "200" ]; then
|
|
23
|
+
curl -sSL --retry 5 "${php_header/PHP-$version/master}" | grep "PHP_API_VERSION" | cut -d' ' -f 3
|
|
24
|
+
else
|
|
25
|
+
grep "PHP_API_VERSION" /tmp/php.h | cut -d' ' -f 3
|
|
26
|
+
fi
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get_api_version() {
|
|
30
|
+
case $version in
|
|
31
|
+
5.3) echo "20090626" ;;
|
|
32
|
+
5.4) echo "20100525" ;;
|
|
33
|
+
5.5) echo "20121212" ;;
|
|
34
|
+
5.6) echo "20131226" ;;
|
|
35
|
+
7.0) echo "20151012" ;;
|
|
36
|
+
7.1) echo "20160303" ;;
|
|
37
|
+
7.2) echo "20170718" ;;
|
|
38
|
+
7.3) echo "20180731" ;;
|
|
39
|
+
7.4) echo "20190902" ;;
|
|
40
|
+
8.0) echo "20200930" ;;
|
|
41
|
+
8.1) echo "20210902" ;;
|
|
42
|
+
*) get_api_version_from_repo ;;
|
|
43
|
+
esac
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fix_ownership() {
|
|
47
|
+
dir=$1
|
|
48
|
+
sudo chown -R "$USER":"$(id -g -n)" "$(dirname "$dir")"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
add_config() {
|
|
52
|
+
dependent_extension=$1
|
|
53
|
+
dependency_extension=$2
|
|
54
|
+
echo "$dependency_extension" | sudo tee "${ext_config_directory:?}/$dependent_extension/$dependency_extension" >/dev/null 2>&1
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
extension_dir_darwin() {
|
|
58
|
+
api_version=$1
|
|
59
|
+
if [[ "${version:?}" =~ ${old_versions:?} ]]; then
|
|
60
|
+
echo "/opt/local/lib/php${version/./}/extensions/no-debug-non-zts-$api_version"
|
|
61
|
+
else
|
|
62
|
+
if [[ "$(sysctl -n hw.optional.arm64 2>/dev/null)" == "1" ]]; then
|
|
63
|
+
echo "/opt/homebrew/lib/php/pecl/$api_version"
|
|
64
|
+
else
|
|
65
|
+
echo "/usr/local/lib/php/pecl/$api_version"
|
|
66
|
+
fi
|
|
67
|
+
fi
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
extension_dir_linux() {
|
|
71
|
+
api_version=$1
|
|
72
|
+
if [[ "${version:?}" =~ ${old_versions:?} ]]; then
|
|
73
|
+
echo "/usr/local/php/$version/lib/php/extensions/no-debug-non-zts-$api_version"
|
|
74
|
+
else
|
|
75
|
+
echo "/usr/lib/php/$api_version"
|
|
76
|
+
fi
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
data() {
|
|
80
|
+
old_versions="5.[3-5]"
|
|
81
|
+
date='20211217'
|
|
82
|
+
if [ "$os" = "Linux" ]; then
|
|
83
|
+
. /etc/lsb-release
|
|
84
|
+
os=$os-$DISTRIB_CODENAME
|
|
85
|
+
api_version=$(get_api_version)
|
|
86
|
+
dir=$(extension_dir_linux "$api_version")
|
|
87
|
+
sudo mkdir -p "$dir/deps" && fix_ownership "$dir"
|
|
88
|
+
elif [ "$os" = "Darwin" ]; then
|
|
89
|
+
api_version=$(get_api_version)
|
|
90
|
+
dir=$(extension_dir_darwin "$api_version")
|
|
91
|
+
sudo mkdir -p "$dir/deps" && fix_ownership "$dir"
|
|
92
|
+
else
|
|
93
|
+
os="Windows"
|
|
94
|
+
dir='C:\\tools\\php\\ext'
|
|
95
|
+
fi
|
|
96
|
+
job="${GITHUB_REPOSITORY}-${GITHUB_WORKFLOW}-${GITHUB_JOB}"
|
|
97
|
+
key="$(echo -n "$extensions-$key-$job" | openssl dgst -sha256 | cut -d ' ' -f 2)"
|
|
98
|
+
key="$os"-"$version"-"$key"-"$date"
|
|
99
|
+
echo "$dir" > "${RUNNER_TEMP:?}"/dir
|
|
100
|
+
echo "$key" > "${RUNNER_TEMP:?}"/key
|
|
101
|
+
echo "::set-output name=dir::$dir"
|
|
102
|
+
echo "::set-output name=key::$key"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
dependencies() {
|
|
106
|
+
if [ "$os" = "Linux" ] || [ "$os" = "Darwin" ]; then
|
|
107
|
+
export tick="✓"
|
|
108
|
+
export cross="✗"
|
|
109
|
+
export ext_config_directory="/tmp/extcache"
|
|
110
|
+
export deps_cache_directory="${RUNNER_TOOL_CACHE}"/deps
|
|
111
|
+
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)
|
|
112
|
+
# shellcheck disable=SC1090
|
|
113
|
+
. "$script_dir/$(echo "$os" | tr '[:upper:]' '[:lower:]').sh"
|
|
114
|
+
setup_dependencies "$extensions" "$(cat "${RUNNER_TEMP:?}"/dir)"
|
|
115
|
+
fi
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
run=$1
|
|
119
|
+
extensions=$2
|
|
120
|
+
version=$3
|
|
121
|
+
key=$4
|
|
122
|
+
os=$(uname -s)
|
|
123
|
+
|
|
124
|
+
$run
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
fetch_brew_tap() {
|
|
2
|
+
tap=$1
|
|
3
|
+
tap_user=$(dirname "$tap")
|
|
4
|
+
tap_name=$(basename "$tap")
|
|
5
|
+
mkdir -p "$tap_dir/$tap_user"
|
|
6
|
+
curl -sL "https://github.com/$tap/archive/master.tar.gz" | sudo tar -xzf - -C "$tap_dir/$tap_user"
|
|
7
|
+
if [ -d "$tap_dir/$tap_user/$tap_name-master" ]; then
|
|
8
|
+
sudo mv "$tap_dir/$tap_user/$tap_name-master" "$tap_dir/$tap_user/$tap_name"
|
|
9
|
+
fi
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
add_brew_tap() {
|
|
13
|
+
tap=$1
|
|
14
|
+
if ! [ -d "$tap_dir/$tap" ]; then
|
|
15
|
+
if [ "${ImageOS:=}-${ImageVersion:=}" = "-" ]; then
|
|
16
|
+
brew tap --shallow "$tap" >/dev/null 2>&1
|
|
17
|
+
else
|
|
18
|
+
fetch_brew_tap "$tap" >/dev/null 2>&1
|
|
19
|
+
if ! [ -d "$tap_dir/$tap" ]; then
|
|
20
|
+
brew tap --shallow "$tap" >/dev/null 2>&1
|
|
21
|
+
fi
|
|
22
|
+
fi
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get_dependencies() {
|
|
27
|
+
extension=$1
|
|
28
|
+
list_deps="$(grep "$extension" "${script_dir:?}"/../lists/darwin-deps | cut -d '=' -f 2)"
|
|
29
|
+
formula_file="$tap_dir/$ext_tap/Formula/$extension@${version:?}.rb"
|
|
30
|
+
if [ -e "$formula_file" ]; then
|
|
31
|
+
formula_deps="$(grep "depends_on" "$formula_file" | cut -d '"' -f 2 | tr '\n' ' ')"
|
|
32
|
+
fi
|
|
33
|
+
deps=()
|
|
34
|
+
[[ -n "${list_deps[*]}" ]] && deps+=("${list_deps[@]}")
|
|
35
|
+
[[ -n "${formula_deps[*]}" ]] && deps+=("${formula_deps[@]}")
|
|
36
|
+
echo "${deps[@]}"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
filter_extensions() {
|
|
40
|
+
extensions_array=("$@")
|
|
41
|
+
filtered_extensions=()
|
|
42
|
+
for ext in "${extensions_array[@]}"; do
|
|
43
|
+
if grep -i -q -w "$ext" "${script_dir:?}"/../lists/darwin-extensions ||
|
|
44
|
+
grep -q "$ext=" "${script_dir:?}"/../lists/darwin-deps; then
|
|
45
|
+
filtered_extensions+=("$ext")
|
|
46
|
+
fi
|
|
47
|
+
done
|
|
48
|
+
echo "${filtered_extensions[@]}"
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setup_extensions_helper() {
|
|
52
|
+
dependent_extension=$1
|
|
53
|
+
dependency_extension=$2
|
|
54
|
+
extension_dir=$3
|
|
55
|
+
cached_extension="${deps_cache_directory:?}/$dependency_extension.so"
|
|
56
|
+
if ! [ -e "$cached_extension" ]; then
|
|
57
|
+
brew install "$dependency_extension@$version"
|
|
58
|
+
sudo find "$brew_cellar/$dependency_extension@${version:?}" -name "$dependency_extension.so" -exec cp {} "$cached_extension" \;
|
|
59
|
+
else
|
|
60
|
+
echo "Found $dependency_extension extension in cache"
|
|
61
|
+
sudo cp "$cached_extension" "$extension_dir/"
|
|
62
|
+
fi
|
|
63
|
+
add_config "$dependent_extension" "$dependency_extension"
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
setup_extensions() {
|
|
67
|
+
dependent_extension=$1
|
|
68
|
+
extension_dir=$2
|
|
69
|
+
shift 2
|
|
70
|
+
dependency_extensions_array=("$@")
|
|
71
|
+
sudo mkdir -p "$cache_directory"/"$extension"
|
|
72
|
+
echo "::group::Logs to set up extensions required for $extension"
|
|
73
|
+
for dependency_extension in "${dependency_extensions_array[@]}"; do
|
|
74
|
+
setup_extensions_helper "$dependent_extension" "$dependency_extension" "$extension_dir"
|
|
75
|
+
done
|
|
76
|
+
echo "::endgroup::"
|
|
77
|
+
add_log "${tick:?}" "${dependency_extensions_array[@]}"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
add_library_helper() {
|
|
81
|
+
dep_name=$1
|
|
82
|
+
cache_dir=$2
|
|
83
|
+
echo "$dep_name" | sudo tee -a "$cache_dir"/list >/dev/null 2>&1
|
|
84
|
+
(
|
|
85
|
+
cd "$brew_cellar" || exit 1
|
|
86
|
+
if command -v gtar >/dev/null; then
|
|
87
|
+
sudo gtar -I "zstd -T0" -cf "$cache_dir"/"$dep_name".tar.zst "$dep_name"
|
|
88
|
+
else
|
|
89
|
+
sudo tar -cf - "$dep_name" | zstd -T0 > "$cache_dir"/"$dep_name".tar.zst
|
|
90
|
+
fi
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
add_library() {
|
|
95
|
+
lib=$1
|
|
96
|
+
cache_dir=$2
|
|
97
|
+
brew list "$lib" &>/dev/null || brew install "$lib"
|
|
98
|
+
IFS=' ' read -r -a deps_array <<<"$(brew deps "$lib" | tr '\n' ' ')"
|
|
99
|
+
to_wait=()
|
|
100
|
+
for dep_name in "$lib" "${deps_array[@]}"; do
|
|
101
|
+
add_library_helper "$dep_name" "$cache_dir" &
|
|
102
|
+
to_wait+=($!)
|
|
103
|
+
done
|
|
104
|
+
wait "${to_wait[@]}"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
restore_library_helper() {
|
|
108
|
+
dep_name=$1
|
|
109
|
+
cache_dir=$2
|
|
110
|
+
if ! [ -d "$brew_cellar/$dep_name" ]; then
|
|
111
|
+
if command -v gtar >/dev/null; then
|
|
112
|
+
sudo gtar -I "zstd -d" -xf "$cache_dir"/"$dep_name".tar.zst -C "$brew_cellar"
|
|
113
|
+
else
|
|
114
|
+
sudo zstd -dq "$cache_dir"/"$dep_name".tar.zst && sudo tar -xf "$cache_dir"/"$dep_name".tar -C "$brew_cellar"
|
|
115
|
+
fi
|
|
116
|
+
fi
|
|
117
|
+
if ! [ -d "$brew_prefix/opt/$dep_name" ]; then
|
|
118
|
+
brew link --force --overwrite "$dep_name" 2>/dev/null || true
|
|
119
|
+
fi
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
restore_library() {
|
|
123
|
+
cache_dir=$1
|
|
124
|
+
to_wait=()
|
|
125
|
+
while read -r dep_name; do
|
|
126
|
+
restore_library_helper "$dep_name" "$cache_dir" &
|
|
127
|
+
to_wait+=($!)
|
|
128
|
+
done <"$cache_dir"/list
|
|
129
|
+
wait "${to_wait[@]}"
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
setup_libraries() {
|
|
133
|
+
extension=$1
|
|
134
|
+
shift 1
|
|
135
|
+
libraries_array=("$@")
|
|
136
|
+
ext_deps_dir="$deps_cache_directory/$extension"
|
|
137
|
+
sudo cp -a "$tap_dir"/"$ext_tap"/.github/deps/"$extension"/*.rb "$tap_dir"/"$core_tap"/Formula/ 2>/dev/null || true
|
|
138
|
+
sudo mkdir -p "$ext_deps_dir"
|
|
139
|
+
echo "::group::Logs to set up libraries required for $extension"
|
|
140
|
+
for lib in "${libraries_array[@]}"; do
|
|
141
|
+
if ! [ -e "$ext_deps_dir"/list ]; then
|
|
142
|
+
add_library "$lib" "$ext_deps_dir"
|
|
143
|
+
else
|
|
144
|
+
restore_library "$ext_deps_dir"
|
|
145
|
+
fi
|
|
146
|
+
done
|
|
147
|
+
echo "::endgroup::"
|
|
148
|
+
add_log "$tick" "${libraries_array[@]}"
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
setup_dependencies() {
|
|
152
|
+
extensions=$1
|
|
153
|
+
extension_dir=$2
|
|
154
|
+
cache_directory=/tmp/extcache
|
|
155
|
+
[[ -z "${extensions// /}" ]] && return
|
|
156
|
+
IFS=' ' read -r -a extensions_array <<<"$(echo "$extensions" | sed -e "s/pdo[_-]//g" -Ee "s/^|,\s*/ /g")"
|
|
157
|
+
IFS=' ' read -r -a extensions_array <<<"$(filter_extensions "${extensions_array[@]}")"
|
|
158
|
+
if [[ -n "${extensions_array[*]// /}" ]]; then
|
|
159
|
+
add_brew_tap "$php_tap"
|
|
160
|
+
add_brew_tap "$ext_tap"
|
|
161
|
+
# Remove once updated on the images
|
|
162
|
+
curl -o "$tap_dir"/"$core_tap"/Formula/ca-certificates.rb -sL https://raw.githubusercontent.com/"$core_tap"/master/Formula/ca-certificates.rb
|
|
163
|
+
for extension in "${extensions_array[@]}"; do
|
|
164
|
+
IFS=' ' read -r -a dependency_array <<<"$(get_dependencies "$extension")"
|
|
165
|
+
IFS=' ' read -r -a extension_array <<<"$(echo "${dependency_array[@]}" | grep -Eo "[a-z]*@" | sed 's/@//' | tr '\n' ' ')"
|
|
166
|
+
IFS=' ' read -r -a libraries_array <<<"${dependency_array[@]//shivammathur*/}"
|
|
167
|
+
if [[ -n "${libraries_array[*]// /}" ]]; then
|
|
168
|
+
step_log "Setup libraries for $extension"
|
|
169
|
+
setup_libraries "$extension" "${libraries_array[@]}"
|
|
170
|
+
fi
|
|
171
|
+
if [[ -n "${extension_array[*]// /}" ]] && [ "${skip_dependency_extensions:=}" != "true" ]; then
|
|
172
|
+
step_log "Setup extensions for $extension"
|
|
173
|
+
setup_extensions "$extension" "$extension_dir" "${extension_array[@]}"
|
|
174
|
+
fi
|
|
175
|
+
done
|
|
176
|
+
fi
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export HOMEBREW_CHANGE_ARCH_TO_ARM=1
|
|
180
|
+
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
|
181
|
+
export HOMEBREW_NO_AUTO_UPDATE=1
|
|
182
|
+
export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
|
|
183
|
+
|
|
184
|
+
brew_prefix="$(brew --prefix)"
|
|
185
|
+
brew_cellar="$brew_prefix/Cellar"
|
|
186
|
+
tap_dir="$(brew --repository)"/Library/Taps
|
|
187
|
+
core_tap=homebrew/homebrew-core
|
|
188
|
+
php_tap=shivammathur/homebrew-php
|
|
189
|
+
ext_tap=shivammathur/homebrew-extensions
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
link_apt_fast() {
|
|
2
|
+
if ! command -v apt-fast >/dev/null; then
|
|
3
|
+
sudo ln -sf /usr/bin/apt-get /usr/bin/apt-fast
|
|
4
|
+
fi
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
fetch_package() {
|
|
8
|
+
if ! [ -e /tmp/Packages ]; then
|
|
9
|
+
. /etc/os-release
|
|
10
|
+
deb_build_arch=$(dpkg-architecture -q DEB_BUILD_ARCH)
|
|
11
|
+
curl -o /tmp/Packages.gz -sL "http://ppa.launchpad.net/ondrej/php/ubuntu/dists/$VERSION_CODENAME/main/binary-$deb_build_arch/Packages.gz"
|
|
12
|
+
gzip -df /tmp/Packages.gz
|
|
13
|
+
fi
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get_dependencies() {
|
|
17
|
+
package=$1
|
|
18
|
+
prefix=$2
|
|
19
|
+
list_deps="$(grep "${package#*-}" "${script_dir:?}"/../lists/linux-deps | cut -d '=' -f 2 | grep -Eo "$prefix.*")"
|
|
20
|
+
package_deps="$(sed -e '/Package:\s'"$package$"'/,/^\s*$/!d' /tmp/Packages | grep -Eo "^Depends.*" | tr ',' '\n' | awk -v ORS='' '/^\s'"$prefix"'/{print$0}' | sed -e 's/([^()]*)//g' | sort | uniq | xargs echo -n)"
|
|
21
|
+
deps=()
|
|
22
|
+
[[ -n "${list_deps[*]}" ]] && deps+=("${list_deps[@]}")
|
|
23
|
+
[[ -n "${package_deps[*]}" ]] && deps+=("${package_deps[@]}")
|
|
24
|
+
echo "${deps[@]}"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get_package_link() {
|
|
28
|
+
package=$1
|
|
29
|
+
trunk="http://ppa.launchpad.net/ondrej/php/ubuntu"
|
|
30
|
+
file=$(sed -e '/Package:\s'"$package$"'/,/^\s*$/!d' /tmp/Packages | grep -Eo "^Filename.*" | cut -d' ' -f 2 | tr -d '\r')
|
|
31
|
+
echo "$trunk/$file"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setup_extensions_helper() {
|
|
35
|
+
dependency_extension=$1
|
|
36
|
+
extension_dir=$2
|
|
37
|
+
cached_extension="${deps_cache_directory:?}/$dependency_extension.so"
|
|
38
|
+
if ! [ -e "$extension_dir/$dependency_extension.so" ]; then
|
|
39
|
+
if ! [ -e "$cached_extension" ]; then
|
|
40
|
+
extension_package_link="$(get_package_link "php${version:?}-$dependency_extension")"
|
|
41
|
+
sudo curl -H "User-Agent: Debian APT-HTTP/GHA(ce)" -o "/tmp/$dependency_extension".deb -sL "$extension_package_link"
|
|
42
|
+
sudo dpkg-deb -x "/tmp/$dependency_extension".deb /
|
|
43
|
+
sudo cp "$extension_dir/$dependency_extension.so" "$cached_extension"
|
|
44
|
+
fix_ownership "$extension_dir"
|
|
45
|
+
else
|
|
46
|
+
sudo cp "$cached_extension" "$extension_dir/"
|
|
47
|
+
fi
|
|
48
|
+
fi
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setup_extensions() {
|
|
52
|
+
extension_dir=$1
|
|
53
|
+
IFS=' ' read -r -a dependency_extension_array <<<"$(echo "$2" | xargs -n1 | sort | uniq | xargs)"
|
|
54
|
+
to_wait=()
|
|
55
|
+
for dependency_extension in "${dependency_extension_array[@]}"; do
|
|
56
|
+
setup_extensions_helper "$dependency_extension" "$extension_dir" &
|
|
57
|
+
to_wait+=($!)
|
|
58
|
+
done
|
|
59
|
+
wait "${to_wait[@]}"
|
|
60
|
+
add_log "${tick:?}" "${dependency_extension_array[@]}"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
filter_libraries() {
|
|
64
|
+
libraries="$(echo "$1" | xargs -n1 | sort | uniq | xargs)"
|
|
65
|
+
for library in $libraries; do
|
|
66
|
+
if grep -i -q -w "$library" "${script_dir:?}"/../lists/"$VERSION_CODENAME"-libs; then
|
|
67
|
+
libraries=${libraries//$library/}
|
|
68
|
+
fi
|
|
69
|
+
done
|
|
70
|
+
echo "$libraries"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
setup_libraries() {
|
|
74
|
+
libraries=$1
|
|
75
|
+
if [[ -n "${libraries// /}" ]]; then
|
|
76
|
+
libraries=$(filter_libraries "$libraries")
|
|
77
|
+
if [[ -n "${libraries// /}" ]]; then
|
|
78
|
+
step_log "Setup libraries"
|
|
79
|
+
IFS=' ' read -r -a libraries_array <<<"$libraries"
|
|
80
|
+
link_apt_fast
|
|
81
|
+
echo "::group::Logs to set up required libraries"
|
|
82
|
+
sudo DEBIAN_FRONTEND=noninteractive apt-fast install --no-install-recommends --no-upgrade -y "${libraries_array[@]}"
|
|
83
|
+
ec="$?"
|
|
84
|
+
echo "::endgroup::"
|
|
85
|
+
if [ "$ec" -eq "0" ]; then mark="${tick:?}"; else mark="${cross:?}"; fi
|
|
86
|
+
add_log "$mark" "${libraries_array[@]}"
|
|
87
|
+
fi
|
|
88
|
+
fi
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setup_dependencies() {
|
|
92
|
+
extensions=$1
|
|
93
|
+
extension_dir=$2
|
|
94
|
+
[[ -z "${extensions// }" ]] && return
|
|
95
|
+
IFS=' ' read -r -a extensions_array <<<"$(echo "$extensions" | sed -e "s/pdo[_-]//g" -Ee "s/^|,\s*/ php$version-/g")"
|
|
96
|
+
. /etc/os-release
|
|
97
|
+
sudo rm -rf "${ext_config_directory:?}" || true
|
|
98
|
+
libraries=""
|
|
99
|
+
extension_packages=""
|
|
100
|
+
for extension_package in "${extensions_array[@]}"; do
|
|
101
|
+
fetch_package
|
|
102
|
+
libraries="$libraries $(get_dependencies "$extension_package" "lib")"
|
|
103
|
+
IFS=' ' read -r -a dependency_extension_packages_array <<<"$(get_dependencies "$extension_package" "php$version-")"
|
|
104
|
+
extension_packages="$extension_packages ${dependency_extension_packages_array[*]}"
|
|
105
|
+
extension_packages="${extension_packages//php$version-common/}"
|
|
106
|
+
for dependency_extension in "${dependency_extension_packages_array[@]}"; do
|
|
107
|
+
mkdir -p "$ext_config_directory/${extension_package#*-}"
|
|
108
|
+
add_config "${extension_package#*-}" "$dependency_extension"
|
|
109
|
+
done
|
|
110
|
+
done
|
|
111
|
+
if [[ -n "${libraries// /}" ]]; then
|
|
112
|
+
setup_libraries "$libraries"
|
|
113
|
+
fi
|
|
114
|
+
if [[ -n "${extension_packages// /}" ]] && [ "${skip_dependency_extensions:=}" != "true" ]; then
|
|
115
|
+
setup_extensions "$extension_dir" "${extension_packages//php$version-/}"
|
|
116
|
+
fi
|
|
117
|
+
}
|
package/src/utils.ts
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
|
-
import * as
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as spu from 'setup-php/lib/utils';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
|
-
* Function to get
|
|
6
|
-
*
|
|
7
|
-
* @param name
|
|
8
|
-
* @param mandatory
|
|
6
|
+
* Function to get outputs
|
|
9
7
|
*/
|
|
10
|
-
export async function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
switch (input) {
|
|
16
|
-
case '':
|
|
17
|
-
case undefined:
|
|
18
|
-
return core.getInput(name, {required: mandatory});
|
|
19
|
-
default:
|
|
20
|
-
return input;
|
|
21
|
-
}
|
|
8
|
+
export async function getOutput(output: string): Promise<string> {
|
|
9
|
+
return fs.readFileSync(
|
|
10
|
+
path.join(await spu.readEnv('RUNNER_TEMP'), output),
|
|
11
|
+
'utf8'
|
|
12
|
+
);
|
|
22
13
|
}
|
|
23
14
|
|
|
24
15
|
/**
|
|
@@ -27,10 +18,26 @@ export async function getInput(
|
|
|
27
18
|
* @param extension_csv
|
|
28
19
|
*/
|
|
29
20
|
export async function filterExtensions(extension_csv: string): Promise<string> {
|
|
30
|
-
return
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
return JSON.stringify(
|
|
22
|
+
extension_csv
|
|
23
|
+
.split(',')
|
|
24
|
+
.filter(extension => {
|
|
25
|
+
return extension.trim()[0] != ':';
|
|
26
|
+
})
|
|
27
|
+
.join(',')
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Function to get script call
|
|
33
|
+
*
|
|
34
|
+
* @param fn
|
|
35
|
+
* @param args
|
|
36
|
+
*/
|
|
37
|
+
export async function scriptCall(
|
|
38
|
+
fn: string,
|
|
39
|
+
...args: string[]
|
|
40
|
+
): Promise<string> {
|
|
41
|
+
const script: string = path.join(__dirname, '../src/scripts/cache.sh');
|
|
42
|
+
return ['bash', script, fn, ...args].join(' ');
|
|
36
43
|
}
|
package/.eslintrc.json
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": { "node": true, "jest": true },
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"parserOptions": { "ecmaVersion": 2019, "sourceType": "module" },
|
|
5
|
-
"extends": [
|
|
6
|
-
"eslint:recommended",
|
|
7
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
8
|
-
"plugin:@typescript-eslint/recommended",
|
|
9
|
-
"plugin:import/errors",
|
|
10
|
-
"plugin:import/warnings",
|
|
11
|
-
"plugin:import/typescript",
|
|
12
|
-
"plugin:prettier/recommended",
|
|
13
|
-
"prettier/@typescript-eslint"
|
|
14
|
-
],
|
|
15
|
-
"plugins": ["@typescript-eslint", "jest"],
|
|
16
|
-
"rules": {
|
|
17
|
-
"camelcase": "off",
|
|
18
|
-
"require-atomic-updates": "off",
|
|
19
|
-
"@typescript-eslint/ban-ts-ignore": "off",
|
|
20
|
-
"@typescript-eslint/camelcase": "off",
|
|
21
|
-
"@typescript-eslint/no-unused-vars": "off"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
-
contributors and maintainers pledge to making participation in our project and
|
|
7
|
-
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
-
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
|
9
|
-
level of experience, education, socio-economic status, nationality, personal
|
|
10
|
-
appearance, race, religion, or sexual identity and orientation.
|
|
11
|
-
|
|
12
|
-
## Our Standards
|
|
13
|
-
|
|
14
|
-
Examples of behavior that contributes to creating a positive environment
|
|
15
|
-
include:
|
|
16
|
-
|
|
17
|
-
* Using welcoming and inclusive language
|
|
18
|
-
* Being respectful of differing viewpoints and experiences
|
|
19
|
-
* Gracefully accepting constructive criticism
|
|
20
|
-
* Focusing on what is best for the community
|
|
21
|
-
* Showing empathy towards other community members
|
|
22
|
-
|
|
23
|
-
Examples of unacceptable behavior by participants include:
|
|
24
|
-
|
|
25
|
-
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
-
advances
|
|
27
|
-
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
-
* Public or private harassment
|
|
29
|
-
* Publishing others' private information, such as a physical or electronic
|
|
30
|
-
address, without explicit permission
|
|
31
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
-
professional setting
|
|
33
|
-
|
|
34
|
-
## Our Responsibilities
|
|
35
|
-
|
|
36
|
-
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
-
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
-
response to any instances of unacceptable behavior.
|
|
39
|
-
|
|
40
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
-
threatening, offensive, or harmful.
|
|
45
|
-
|
|
46
|
-
## Scope
|
|
47
|
-
|
|
48
|
-
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
-
when an individual is representing the project or its community. Examples of
|
|
50
|
-
representing a project or community include using an official project e-mail
|
|
51
|
-
address, posting via an official social media account, or acting as an appointed
|
|
52
|
-
representative at an online or offline event. Representation of a project may be
|
|
53
|
-
further defined and clarified by project maintainers.
|
|
54
|
-
|
|
55
|
-
## Enforcement
|
|
56
|
-
|
|
57
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
-
reported by contacting the project team at contact@shivammathur.com. All
|
|
59
|
-
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
-
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
-
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
-
Further details of specific enforcement policies may be posted separately.
|
|
63
|
-
|
|
64
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
-
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
-
members of the project's leadership.
|
|
67
|
-
|
|
68
|
-
## Attribution
|
|
69
|
-
|
|
70
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
-
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
72
|
-
|
|
73
|
-
[homepage]: https://www.contributor-covenant.org
|
|
74
|
-
|
|
75
|
-
For answers to common questions about this code of conduct, see
|
|
76
|
-
https://www.contributor-covenant.org/faq
|
package/.github/CONTRIBUTING.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Contributing to cache-extensions
|
|
2
|
-
|
|
3
|
-
## Contributor Code of Conduct
|
|
4
|
-
|
|
5
|
-
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
|
|
6
|
-
|
|
7
|
-
## Workflow
|
|
8
|
-
|
|
9
|
-
* Fork the project.
|
|
10
|
-
* Make your bug fix or feature addition.
|
|
11
|
-
* Add tests for it. This is important so we don't break it in a future version unintentionally.
|
|
12
|
-
* Send a pull request to the develop branch.
|
|
13
|
-
|
|
14
|
-
Please make sure that you have [set up your user name and email address](https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project.
|
|
15
|
-
|
|
16
|
-
Due to time constraints, you may not always get a quick response. Please do not take delays personal and feel free to remind.
|
|
17
|
-
|
|
18
|
-
## Coding Guidelines
|
|
19
|
-
|
|
20
|
-
This project comes with `.prettierrc.json` and `eslintrc.json` configuration files. Please run the following commands to format the code before committing it.
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
$ npm run format
|
|
24
|
-
$ npm run lint
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Using cache-extensions from a Git checkout
|
|
28
|
-
|
|
29
|
-
The following commands can be used to perform the initial checkout of cache-extensions:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
$ git clone https://github.com/shivammathur/cache-extensions.git
|
|
33
|
-
|
|
34
|
-
$ cd cache-extensions
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Install cache-extensions dependencies using [npm](https://www.npmjs.com/):
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
$ npm install
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Running the test suite
|
|
44
|
-
|
|
45
|
-
After following the steps shown above, The `cache-extensions` tests in the `__tests__` directory can be run using this command:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
$ npm test
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Creating a release
|
|
52
|
-
|
|
53
|
-
Create a release before you push your changes.
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
$ npm run release
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Reporting issues
|
|
60
|
-
|
|
61
|
-
Please submit the issue using the appropriate template provided for a bug report or a feature request:
|
|
62
|
-
|
|
63
|
-
* [Issues](https://github.com/shivammathur/cache-extensions/issues)
|